4 ms·
In the words of Douglas Crockford, Javascript is Lisp in C's Clothing. http://javascript.crockford.com/javascript.html http://javascript.crockford.com/javascrip
by wildster 15y ago
In the words of Douglas Crockford, Javascript is Lisp in C's Clothing. http://javascript.crockford.com/javascript.html http://javascript.crockford.com/javascript.html
- 2nd_planet 15y agoLISt Processing without code represented as lists... doesn't quite work; but i still see the pint being made here.
- jhuni 15y agoLisp isn't about just any sort of list, it is about nested lists, aka trees. JavaScript programs commonly manipulate XML trees.
- rbanffy 15y agoStill, the XML JavaScript manipulates is data, not the program doing the manipulation or the language itself. When you understand what you can do if they are all the same thing, you'll be enlightened.
- frou_dh 15y ago...and it still makes no sense no matter how often it's repeated to flatter JavaScript.
- tikhonj 15y agoI think it does, actually. When I took a Scheme class based on SICP, we implemented a Scheme interpreter as well as looking at an OOP system using lambdas. Writing that interpreter is the first time JavaScript's scoping rules made sense to me viscerally--they're exactly the same as Scheme's. The OOP system we used was also really similar to what you can do with JavaScript; it just used closures to save state. It wasn't exactly the same, but it was similar. Ultimately, I find that JavaScript is much closer to Scheme than other dynamic scripting languages I've used like Python and Perl.
- groovy2shoes 15y agoJavaScript's scoping rules aren't the same as Scheme's -- variables are scoped at the function level rather than the block level.
- tikhonj 15y agoThat's how it works in Scheme too--you only get a new scope if you either have a lambda or an implicit lambda.
- groovy2shoes 15y agoSure, but in Scheme every block is an implicit lambda. In JavaScript, blocks are justs sections of code.
- jhuni 15y agoJavaScript has the most important dynamic features of Lisp (GC, dynamic typing, first class functions, conditionals, eval, etc). JavaScript, is even a pretty solid tree processing language, because most JavaScript programs manipulate XML trees. XML is basically S-expressions with hundreds of pounds of useless clothing (end tags, attributes, etc) weighing it down. Considering all this I think what Douglas Crockford said is completely accurate, JavaScript is Lisp in C's clothing. That would also make CoffeeScript Lisp with fairly nice clothing.
- spacemanaki 15y ago> JavaScript has the most important dynamic features of Lisp (GC, dynamic typing, first class functions, conditionals, eval, etc). The reason this doesn't hold up is because there are a bunch of other languages that also have most of those features of Lisp, and some of them are older than JS. Python, Ruby, and Perl all have similar features. Every language has conditionals now so it's not even worth mentioning. Even Java has GC, broken closures, and reflection. > JavaScript, is even a pretty solid tree processing language, because most JavaScript programs manipulate XML trees. XML is basically S-expressions with hundreds of pounds of useless clothing (end tags, attributes, etc) weighing it down. You can manipulate XML in Java and C, does that also make Java Lisp in C's clothing, or C Lisp in C's clothing? Lisp macros manipulate code as trees, but that doesn't mean that any language that can manipulate trees is a Lisp. XML isn't JavaScript code, it's just data. The trees that Lisp macros manipulate is data and also Lisp code. > Considering all this I think what Douglas Crockford said is completely accurate, JavaScript is Lisp in C's clothing. It's not "completely accurate". It's mostly inaccurate. It's a cute pithy platitude, but it's not really helpful. Just Google "code is data" and see what kinds of confusion is out there about this. Apology to Douglas Crockford, who does good work. I actually came back to Lisp through his JavaScript lectures, so I feel a bit bad being harsh.
- jhuni 15y agoYou can do anything in any Turing-complete language. JavaScript not only can manipulate trees, it often does. Of course, rather or not you see Lisp in it depends upon how you are identifying Lisp.
- groovy2shoes 15y agoWhile it's true that Brendan Eich's development of JavaScript was influenced by Scheme, Netscape insisted that the language had to look like Java. It's not just the syntax that's different, but the semantics as well. The hallmark of Lisp is code-as-data, data-as-code; JavaScript certainly can't claim that. I like JavaScript (for the most part), but it's wrong to call it "Lisp in C clothing".