9 ms·
JavaScript Isn't Scheme
- deleted 13y ago[deleted]
- skyhvr 13y agoBeautiful.
- jliechti1 13y agoPart 1 of Douglas Crockford's On JavaScript gives a really nice history of the many programming languages leading up to JavaScript. Chapter 1: The Early Years: http://www.youtube.com/watch?v=JxAXlJEmNMg http://www.youtube.com/watch?v=JxAXlJEmNMg Chapter 2: And Then There Was JavaScript: http://www.youtube.com/watch?v=RO1Wnu-xKoY http://www.youtube.com/watch?v=RO1Wnu-xKoY
- scrabble 13y agoI was thinking the same thing while reading the article. JS has inherited from both Scheme and Self.
- dschiptsov 13y agoJS might look like Scheme (can't imagine what shall I smoke) only to those, who never managed to learn the later.) But people like to repeat slogans without understanding. This is how everyone is calling Clojure a Lisp, for example, while it is a language of its own, which happen to use parenthesized syntax.) It is not parenthesis that makes a language Lisp. It is not first class functions that makes it Scheme.) Lisp/Scheme is a set of conventions/features, and when some are broken and other are missing that means it is something else.
- TeMPOraL 13y ago> This is how everyone is calling Clojure a Lisp, for example, while it is a language of its own, which happen to use parenthesized syntax. Well, the official website doesn't help much by itself calling Clojure a (dialect of) Lisp. http://clojure.org/ http://clojure.org/ The only other time I heard someone saying "Clojure is not Lisp" it wasn't in order to say something nice about the former.
- hkolek 13y agoI agree, but I'm wondering what you think is missing or broken in Clojure to prevent it from being a Lisp? Sure, it sits on top of the Java type system and one major thing I can think of that is lacking is the condition system (although, isn't this a only Common Lisp thing?). I don't think it has to be Lisp all the way down to be a Lisp dialect, if that's what you're getting at.
- anonymoushn 13y agoEvery other Lisp happens to have TCO, so if you try to port other Lisp programs to Clojure you generally get stack overflows.
- hkolek 13y agoBut afaik TCO is only a requirement for Scheme implementations, not for e.g. Common Lisp (i.e. you don't need to implement TCO to satisfy the Common Lisp standard). I don't see how the lack of TCO prevents it from being a valid Lisp dialect.
- cgag 13y agoDo you need to implement the common lisp standard to be "a lisp"? What is a lisp?
- hkolek 13y agoExactly my point. I was just using CL as example because I think it would be hard to argue that it is not a Lisp yet the standard doesn't guarantee TCO. > What is a lisp? It's a very good question. I think PG sums it up quite nicely in "Revenge of the Nerds" [1]. Although, now that I'm thinking about it, I'm not quite sure there's any point in classifying something as a Lisp or not... [1] http://www.paulgraham.com/icad.html http://www.paulgraham.com/icad.html
- gsg 13y agoEmacs lisp doesn't guarantee TCO (and in practice does not perform it at all), and yet few people claim that it is not a dialect of lisp.
- ddellacosta 13y agoAt the risk of feeding a troll, a bit of reading comprehension and critical thinking 101: regardless of whether or not you personally consider Clojure to be a Lisp, this is outside the discussion of the article. The home page for Clojure explicitly states "Clojure is a dialect of Lisp." This is in contrast to JavaScript, whose creators never claimed it was Scheme or even a dialect, although the author of the article suggests it was influenced Scheme. In addition, he has perceived that lately, many people claim JavaScript is Scheme, and he rejects that claim. Disputing the validity of Clojure as a Lisp is orthogonal to the subject of the article.
- bwy 13y agoThis is absolutely insane. I don't even know how it got to the point that an article was necessary to explain this.
- pjmlp 13y agoI started coding in a Timex 2068, back in 1986, I keep getting surprised with one needs to explain nowadays to youth generations, given the amount of available information about computing in general.
- deleted 13y ago[deleted]
- danielparks 13y agoI asked on the author’s site as well, but I don’t understand the argument that JavaScript doesn’t have lexical scoping. http://c2.com/cgi/wiki?LexicalScoping http://c2.com/cgi/wiki?LexicalScoping
- cobbal 13y agoIt probably refers to the fact that variables by default are global. If you prefix them with var they're function scoped, but there's no way to make them local to the curly braces of an "if" statement. In scheme, lexical scoping is easily accomplished through the let form, and it's pretty hard to make a variable global by mistake. So yes it does have lexical scoping in the sense that function arguments are lexically scoped, but that's the only scoping environment, and you can't hide that fact behind macros like you could in scheme if it was needed.
- hayksaakian 13y agoDid you notice that "let" is coming in through ecmascript? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- deleted 13y ago[deleted]
- mistercow 13y ago>If you prefix them with var they're function scoped, but there's no way to make them local to the curly braces of an "if" statement. There is; it's just ugly. You just have to use an immediate function as the body of the if statement.
- djKianoosh 13y agoin the words of will smith in men in black, "please keep that kinda shi* to yourself"
- 13y ago
- jrochkind1 13y agoIt's true because it's funny.
- kragen 13y agoOn one hand, it's true that Scheme has a lot of things JS doesn't, and vice versa; and the feel of the languages is very different. On the other hand, it's completely clueless to claim JS doesn't have lexical scoping. Only someone who didn't understand what the alternatives to lexical scoping were could claim that.
- mistercow 13y agoIn particular I was bothered by the author's separation of scoping and closures. For example, if you look at what Objective-C has in terms of closures, and what JS has, then you're practically looking at completely different animals. But if you just say "closures ✓", "perfect lexical scoping ✗", you completely miss that point.
- zeckalpha 13y agoTake a look at the author's toy language for the rationale for the separation: http://magpie-lang.org/ http://magpie-lang.org/
- gsg 13y agoQuite the contrary. Javascript has a strange, ugly hybrid of lexical and function scope that is not that of Scheme, which I suspect that Bob understands very well given his interest in languages (and that he works on a language that compiles to JS). This is not lexical scoping: function example(k) { function ugly() {return i}; for (var i = 0; i < k; i++) {} return ugly; } example(4)() // => 4
- danielparks 13y agoWhat is it that you don’t like about this. Is it that the var is hoisted? http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html http://www.adequatelygood.com/JavaScript-Scoping-and-Hoistin... Hoisting generally seems ugly to me. Edit: I think there is some confusion here about scoping. One axis is dynamic versus lexical scoping (are there other options?). Another axis is function, block, global, etc. scope. They seem orthogonal to me.
- Homunculiheaded 13y agoI 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 ago
- bhashkarsharma 13y agoVery well and funnily written, among other things. Thoroughly enjoyed :)
- hobs 13y agoCouldnt agree more, the writing style of the author is amazing(especially considering the topic). The use of humor to make what could be a dry subject pretty damn good is a rare talent.
- munificent 13y agoThank you! I try very hard to make it worth the reader's time to read it. Humor and interesting phrasing is a big part of that.
- hobs 13y agoI am glad you saw that, me and a coworker were discussing how you should keep on blogging, good work!
- fsck--off 13y ago> Scheme is even more Lisp than Lisp That's not true. In fact, there are some prominent people in the Lisp community who do not think that Scheme is a Lisp. See this thread from 2002 on comp.lang.lisp (especially Pitman and Naggum's comments) for more. If you are too young to have posted on C.L.L when Usenet was still popular, and want to see what a full fledged flame war looks like, look at the end of the thread. Some people who posted there (including the OP) are on HN. https://groups.google.com/forum/#!topic/comp.lang.lisp/Bj8Hx6mZEYI[1-25-false] https://groups.google.com/forum/#!topic/comp.lang.lisp/Bj8Hx...
- markus2012 13y agoHoly smoke... I started posting on Usenet ~1989. I've seen a number of flame fests that I considered epic but this moved the bar exponentially.
- saurabh 13y agoAnd he started it with this. I hesitate to ask this question because I really don't want to start a flame war.
- untothebreach 13y agoI got to the end of the page and thought, "Well that wasn't so bad..." -- then I saw that I was at the end of page 1...of 22. Epic.
- 6cxs2hd6 13y agoCivil wars over distinctions without a difference are the ugliest kind.
- kragen 13y agoThere are people — like Pitman and Naggum — who argue for defining "Lisp" to mean "Common Lisp" for political rather than technical reasons, essentially because they want to stop the evolution of Lisp. (Those who haven't read the thread might think I'm exaggerating.) Fortunately, they are relatively irrelevant today, and Lisps like Clojure, Hy, and Racket are carrying on the further development of Lisp.
- DanWaterworth 13y agoHaskell doesn't have first-class continuations, it has syntactic sugar that allows you to write continuation passing code in a direct style.
- EzGraphs 13y agoThe main reason the comparison between JavaScript and Scheme is helpful is that it breaks the connection between JavaScript and Java. The first thing many Java programmers do when trying to write JavaScript is to try to create a class hierarchy (rather than using prototypical inheritance) using idioms from Java. Although possible, it ends up awkward and confusing in most cases. Understanding that functions are first-class and seeing functional idioms fall out from there is a big paradigm shift for Java devs. Obviously JavaScript isn't Scheme using the author's "top 10 defining characteristics of Scheme." Crockford's analysis is on track - and John Resig and Bear Bibeault highlight the same idea by introducing functions are really fundamental to the languages more than objects (in "Secrets of a JavaScript Ninja"). The language's history does imply the comparison as well. Eich's original mandate was to "write Scheme for the browser" but he was later directed to give his language a C-like syntax and to ride on the coat-tails of the hype surrounding Java. "JavaScript isn't Scheme" might not be accurate for folks schooled in the finer points of Scheme. It is very useful to those who cut their teeth learning Java.
- dmpk2k 13y agoWe might just as well claim that Javascript is Perl then. Javascript has a lot more in common with Perl than it does Scheme; those things that both Javascript and Scheme have in common are also common in many other languages. Anyone trying to draw parallels between Javascript and Scheme isn't crossing some pedantic line, they're off in crazyland. Or, more likely, they don't understand both languages as well as they're implying.
- munificent 13y agoit breaks the connection between JavaScript and Java. This is a good point. The defining characteristic of Scheme in the minds of many is really just closures. Almost every modern language except Java has those, so "Scheme" has inadvertently turned into a weird shorthand for "inverse of Java". I think that's too blunt of an instrument to help you reason about any of the languages in question, but I do appreciate encouraging people to think functionally.
- mnemonicsloth 13y agoGoogle "brendan eich javascript scheme". Result #1 is from Brendan Eich's website: I was recruited to Netscape with the promise of “doing Scheme” in the browser... I’m happy that I chose Scheme-ish first-class functions and Self-ish (albeit singular) prototypes as the main ingredients. https://brendaneich.com/2008/04/popularity/ https://brendaneich.com/2008/04/popularity/ So "JS=Scheme" is not very crazy. Maybe it oversimplifies. But it's not baseless. And it's short.
- etler 13y agoThis article is based on the assertion that there are people that think Javascript is Scheme with an ugly makeover. But do those people exist? Most people who make the comparison aren't saying they they're equal to each other, but that they share similarities. Maybe some people hear that out of context and take it too far, but I don't think they're the majority. I think the thing that makes the comparison is more the first class functions than the closures. The closures assist the first class functions, but the functions are the star. Not a whole lot of non functional programming languages support first class functions with the simplicity and completeness of javascript. http://en.wikipedia.org/wiki/First_class_function#Language_support http://en.wikipedia.org/wiki/First_class_function#Language_s... In javascript, passing functions as parameters is a day to day thing, and that style of being able to pass around different functions as building blocks is what gets it compared to functional languages. Sure, that's not the only thing that functional languages have going for them, but it's the most important thing, and what they're even named after.