Hacker News new | comments | show | ask | jobs | submit login

To quote Douglas Crockford on JavaScript, "Lisp in C's Clothing"



Before I learned a Lisp, I agreed with that statement. Now, I think nothing could be further from the truth.


Indeed. Lisp is a simple language that can be completely defined in half a page. A naive implementation takes less than a thousand lines of code. The language is homoiconic, i.e, there's no difference between programs and data -- everything is a list. This enables programmers to perform complex transformations on code using macros. Lisp compilers such as SBCL generate code that is almost as fast as C++. Oh, and the original Lisp as described by McCarthy is strictly rooted in mathematics. If you limit yourself to writing only a subset of Common Lisp/Scheme -- one that emphasizes immutability and recursive functions on lists of symbols -- it is possible to use formal methods to prove the correctness of your code.

None of that is true for JS. I don't think Crockford thought his remark through.


As a lisp (Scheme and Clojure) user who nonetheless takes issue with this statement:

1. Modern (JS) runtimes have JITs that can generate code almost as fast as C++.

2. You can write purely functional code in JS.

3. JS has arguably less features than R5RS Scheme, which itself is hard to fit on half a page.


What do you mean by point 2? Unless you don't plan on doing any I/O, you can't write purely functional code in JS. Not that you can in Lisp either...


I meant that there is nothing about JS that prohibits writing pure functions and reaping all the associated benefits (formal reasoning, etc.)


If it ain't got macros, then it ain't a Lisp. Javascript is definitely no Lisp, but I really like that it allows function composition, which is somehow reminiscent of a Lisp. f(g(h(x))); instead of (f (g (h x)))


Um, pretty much every C-derived language supports function composition, and uses that syntax for it. Am I missing something?


You're right. I meant to say passing first-class functions as arguments, rather than pointers to functions as you would in C or an object method as you would in Java.


I agree. I think this "JS is Lisp" nonsense is a pretty little platitude that many developers use simply because they don't know any better.


Crockford goes on to clarify that Javascript is really a combination of Java syntax, Self inheritance, and Scheme-like lexical scoping.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: