4 ms·
I learned JavaScript before "The Good Parts" was printed and more importantly after I had been writing a lot of Common Lisp. I remember being really shocked an
by Homunculiheaded 13y ago
I learned JavaScript before "The Good Parts" was printed and more importantly after I had been writing a lot of Common Lisp. I remember being really shocked and excited when I realized how much JS had in common with lisp given that my expectation when learning it was that I was in for an awful time.
I think the origins of the "JavaScript is Scheme!" meme have more to do with the fact that you can pretty trivially re-implement all of the code from the Little Schemer (including the applicative order y-combinator) in JavaScript, than any of the reasons mentioned here. JavaScript still, imho, has nicer closures and lambdas than most mainstream programming languages.
Actually, thinking back on it, I remember having a conversation with Prof. Daniel Friedman about how similar the two language are and I believe his response was something along the lines of: if you have the lambda calculus, what else do you need?
Final nitpick: most of the "Y isn't really a lisp!" (another meme) articles I've read always miss what I think is the biggest thing missing from all languages compared to any lisp: symbolic expressions. To me this is the single most underrated feature of lisp that almost no other programming languages offer.
- why-el 13y agoThe points in the article are still not addressed in your comment. The exercises in TLS can be programmed in pretty much any one of the mainstream, dynamically-typed and lexically scoped languages (beginning with Ruby, which I have partially done). The author is right; the hype around the phrase is unjustified and js programmers should focus on the true merits of Javascript alone.
- Homunculiheaded 13y agoI actually agree that the "JavaScript is Scheme!" meme is over used today. My comment was more pointing out where I felt the meme's origins had come from. It really wasn't that long ago that mentioning dynamic programming languages would get scoffed at by "real" programmers. Today, with underscore.js being pretty standard, it's trite to say "Hey! JavaScript has lambdas, closures and first class functions!" But that was not always the case.
- voyou 13y agoThat's true, but that any "dynamically-typed and lexically scoped languages" with closures and first-class functions could be considered mainstream is fairly new. Crockford wrote "JavaScript: The World's Most Misunderstood Programming Language", which I think is the source of the idea that JavaScript is like Scheme, back in 2001. At that point, Ruby was almost unknown, Python was fairly minor, PHP didn't have closures or first-class functions; the other major programming languages were statically-typed things like C++ and Java. So I think it's worth remembering that it's really a very recent development that we can now treat it as obvious that a language like JavaScript would contain the things it has in common with Scheme.
- stplsd 13y agoPerl was big in 2001 and had closures and first-class functions. And let's not forget great book Higher-Order Perl: Transforming Programs with Programs http://hop.perl.plover.com/ http://hop.perl.plover.com/
- anonymous 13y agoWell, Perl is on a level not many languages dare touch. If I'm not mistaken, you can execute arbitrary code during compilation and generate arbitrary source. Which in turn might be executed to generate more stuff...
- tokenrove 13y agoSo, just like Lisp, then.
- vinceguidry 13y agoYou can do that with any language that has an eval function. Eval takes a string and feeds it into the interpreter.
- vinceguidry 13y agoFor some reason I didn't see that he'd said, "during compilation". Perl is an interpreted language, so there's no compilation stage. A compiled language is modified in this way using a preprocessor. It doesn't really make sense to claim it's possible to inject code during compilation, that's the entire purpose of a compiler, to generate machine code from a syntax tree. But code generation and execution during runtime, which is what I think you meant, is capable in any language with eval().
- mistercow 13y ago>The exercises in TLS can be programmed in pretty much any one of the mainstream, dynamically-typed and lexically scoped languages (beginning with Ruby, which I have partially done). That's spurious. Anything that can be implemented in one Turing complete language can be implemented in any Turing complete language. The question is how easy it is.
- danielparks 13y agoI learned Lisp after I learned Javascript, so I had the opposite experience of discovering that a bunch of Lisp-y things worked just as I expected them to. I would never claim that Javascript is scheme (and it doesn’t sound like that’s what you’re claiming), but the things I love about Javscript are also things I love about scheme. Is it the homoiconic-ness of the s-expressions you like? Personally, I'd love to see continuations in Javascript, despite the potential for horrible abuse. Deeply nested callbacks are a pain in the ass. Of course, promises are a pretty decent solution.