It's nice to see such a rational comparison of languages. So often, I see blogs written by people who only understand one language and blindly compare its' elegant solutions to arcane versions in another language because they don't understand the other enough to recognize their blunder. This post, on the other hand, is written by somebody with a strong understanding of both languages and how to approach the same problem with two different hats.
So, rather than another "Lisp rocks, Java sucks" post, we get to read a intellectually sound argument. Refreshing.
Please don't conclude that lisp-2 is a bad idea until you've considered that:
• there are disadvantages as well as advantages to lisp-1; and
• there is nothing about lisp-2-ness itself that requires the verbosity of (funcall #'…)-ing in Common Lisp:
Firstly, even in Common Lisp, (funcall (lambda …) …) and (funcall 'car list) are valid. (And many implementations allow ((lambda …) …) — though I can't remember whether the standard defines this.)
Secondly, funcall can be renamed something shorter (e.g. fun).
And finally, for those lispers not against a little syntax, a lisp-2 could define some syntax so that one could write, e.g. (#f …) for (funcall f …) and (##f …) for (funcall 'f …).
I'm not very literate in functional programming ... so excuse such a dumb question. But I'm curious why you write the recursing function duplicated? eg. isn't this version of your code equivalent?
function Y(X) {
var fn = function(procedure) {
return X(function(arg) {
return procedure(procedure)(arg);
});
};
return fn(fn);
}
Or am I missing something vital here about how it is all working? The shorter version seems clearer to me (not that any of this is clear to me), and functionally equivalent.
Somebody, please, kill the author of that article!
If you are green, then you should think about effectiveness of your code. I mean, how much watts your code will use. Ideal program should produce result without using of any computation at all. Programs with lazy evaluation is very close to that ideal. Y Combinator is very green in such languages. But Y Combinator in call-by-value languages? Code, which produces code, to run code, which produces new code, to run code, which produces new code, ...? Author want to boil our planet?
So, rather than another "Lisp rocks, Java sucks" post, we get to read a intellectually sound argument. Refreshing.