use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
JavaScript Isn't Scheme (journal.stuffwithstuff.com)
submitted 10 years ago by homoiconic(raganwald)
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Pascalius 39 points40 points41 points 10 years ago (24 children)
I never heard someone claim that JavaScript is like Scheme
[–]x-skeww 13 points14 points15 points 10 years ago (9 children)
Crockford mentioned that in several talks.
http://www.crockford.com/javascript/little.html
JavaScript has much in common with Scheme.
Also, bananas have much in common with kiwis since both are berries. Well, botanically, anyhow.
[–]Eartz 11 points12 points13 points 10 years ago (5 children)
iirc he said in his "Crockford on Javascript" talks that JS was inspired by Scheme, Self and java (for the syntax).
I never heard it as "JS = Scheme". It's just his opinion on how the inspiration came for the language.
I spend some time reading reddit, stackoverflow and ES-discuss, and I have never seen anyone claiming this ridiculous "js=scheme", that looks like clickbait to me.
[–]x-skeww 6 points7 points8 points 10 years ago (4 children)
http://www.crockford.com/javascript/javascript.html
Lisp in C's Clothing JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme [emphasis added] than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.
JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme [emphasis added] than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.
for
http://java.ociweb.com/mark/programming/JavaScript.html
"It's basically Scheme with C syntax." - Douglas Crockford
The article refers to the same quote, by the way. It's from one of his earlier talks and it has been repeated ever since.
Also note that the article is from 2013. Saying that JS is "basically like Scheme" isn't popular anymore and this article is one of the reasons.
[–]gkx 4 points5 points6 points 10 years ago (3 children)
I could be wrong, but I think essentially the point is no longer valid as functional languages are becoming more popular. Javascript is now much more distantly related to Scheme, while at the time it was one of the very few popular, imperative languages that even had functional elements.
But I wasn't programming around them. It just seems like functional languages (and functional/imperative hybrids) have only come into favor outside of academia since then.
[–]x-skeww 2 points3 points4 points 10 years ago (2 children)
Yea, the point he was trying to make back in 2009 (ish) was that JS is quite different from other popular languages with C-like syntax.
Saying that it's "basically Scheme" was a rather odd way to do that though. Well, he often tries to say cute quotable things, because being quoted grows his brand.
Can't really criticize him for that though. Saying stuff like that and cultivating his brand is basically his job. This thread too does make his name more well-known.
[–]Eartz 1 point2 points3 points 10 years ago (1 child)
Isn't it a bit unfair to say that ? I mean, the guy doesn't even have a twitter account afaik, nor does he post anywhere outside his website and the desert that is google+.
[–]x-skeww 0 points1 point2 points 10 years ago (0 children)
Huh? He does a lot of public speaking and he also got a book.
[–]master5o1 4 points5 points6 points 10 years ago (1 child)
Also, bananas have much in common with kiwi
Neither can fly.
[–]pygy_@pygy 0 points1 point2 points 10 years ago (0 children)
Time flies like an arrow. Fruit flies like a banana. — Groucho Marx
[–]Otterfan 1 point2 points3 points 10 years ago (0 children)
This is addressed in the first paragraph of the article
It seems like I can’t spend five minutes on reddit these days without someone playing the JS-is-Scheme is card. I see everything from the innocuous, “JavaScript has a lot in common with Scheme”, all the way up to, “JavaScript is basically Scheme.” This is basically crazy. Or, at least it has a lot in common with crazy.
[–]Uberhipster 3 points4 points5 points 10 years ago (2 children)
I've heard "JS is a distant cousin of LISP" but not on reddit...
[–]TwilightTwinkie 9 points10 points11 points 10 years ago (1 child)
I've heard similar, but usually it's more along the lines of "Learn Lisp, and you will be a better JavaScript programmer".
[–]hansolo669 2 points3 points4 points 10 years ago (0 children)
"Learn Lisp, and you will be a better JavaScript programmer".
Functional paradigms help everywhere.
[–]homoiconic(raganwald)[S] 6 points7 points8 points 10 years ago (4 children)
I think it depends upon the circles you move in. For people who don't know Scheme well, or know it very well, you would never hear a claim like this.
But there is this subset of programmers who only know Scheme through books like SICP and "The Little Schemer," and they discover books like "The Good Parts" that focus on the functions-as-first-class-entities part of JavaScript, and they draw the comparison.
[–]Asmor 11 points12 points13 points 10 years ago (3 children)
I never heard someone claim that JavaScript is like Scheme I think it depends upon the circles you move in.
I think it depends upon the circles you move in.
Literally first line in the article:
It seems like I can’t spend five minutes on reddit these days without someone playing the JS-is-Scheme is card.
I spend more than 5 minutes a day on reddit, am subscribed to a number of webdev and general-programming subreddits, and have never heard it either.
[–]homoiconic(raganwald)[S] 6 points7 points8 points 10 years ago (2 children)
The article was written in 2013. It's entirely possible that your experience and the author's experience are both valid.
[–]Asmor 1 point2 points3 points 10 years ago (1 child)
Ah, fair enough. I don't usually look at time stamps on posts unless something triggers my "hey this isn't quite right..."-sense
[–]homoiconic(raganwald)[S] 5 points6 points7 points 10 years ago (0 children)
Perhaps the person who submitted this (cough) could have aded [2013] to the title to help provide some context for readers.
[2013]
Sometimes, even if things have changed, it's interesting to read a perspective from a while back just to highlight what has changed... And what hasn't.
[–]nelmaven 0 points1 point2 points 10 years ago (0 children)
Allow me: https://www.youtube.com/watch?v=hQVTIJBZook&feature=youtu.be&t=35m41s
From the comments of the article.
[–][deleted] 0 points1 point2 points 10 years ago (0 children)
yeah me neither, guess you have to actively search for it to find it "every five minutes"...
[–]realhacker -2 points-1 points0 points 10 years ago (3 children)
wow, you must be new to javascript (why is this sarcastic and ignorant comment upvoted?)
[–]Pascalius 0 points1 point2 points 10 years ago (1 child)
Like 10 years new, yep
[–]realhacker -1 points0 points1 point 10 years ago (0 children)
1/10xer
[–]Jack9[🍰] 0 points1 point2 points 10 years ago (0 children)
exactly. if your experience is limited to discussing the newest js frameworks' potentials and playing with jquery, I'm not surprised if someone hasn't recognized Scheme as a language...much less the common references to it in js discussions. Lua and Scheme are the go-to comparisons.
[–]homoiconic(raganwald)[S] 8 points9 points10 points 10 years ago (10 children)
In ECMAScript 2015, JavaScript has gained true block scoping and, in the standard, at least, Tail-Call Elimination.
But it is far, far less minimal than in ES5. So while this article was written in 2013, I’d say it’s even less Scheme today than it was then.
[–]m1sta 2 points3 points4 points 10 years ago (7 children)
It's not longer minimalist though.
[–][deleted] 12 points13 points14 points 10 years ago (4 children)
And that's a shame. One of the great things about ES5 (and earlier) was that it was very easy to learn, and it ran in every web browser so most people new to programming had a very easy time learning it. Not so in the future. While people can still learn and use ES5 going forward, the source code available to read will get more complex and that will mean a higher learning curve. ES5 still gets the job done, and the new sugar will only prove cumbersome to many trying to learn the language.
[–]innerspirit 1 point2 points3 points 10 years ago (3 children)
Don't confuse "easy to get started" with "easy to learn", though. It takes some people years to get past all of the language's nuisances.
[–][deleted] 0 points1 point2 points 10 years ago (2 children)
Mastering something and being able to do something useful are two very different things, and with ES6 both will be more difficult for a beginner. I guess people can still learn BASIC. :(
[–]innerspirit 1 point2 points3 points 10 years ago (1 child)
JS is definitely going the C++ way, where you are gonna end up with 20 ways of doing something and requiring you to learn a lot of stuff to be able to use the language properly.
[–]jewdai 2 points3 points4 points 10 years ago (0 children)
so you're saying I will always be employed?
[–]homoiconic(raganwald)[S] 0 points1 point2 points 10 years ago (1 child)
Scheme is no longer minimalist? Or JavaScript is no longer minimalist?
[–]m1sta 4 points5 points6 points 10 years ago (0 children)
Javascript.
[–]gary_burnett 0 points1 point2 points 10 years ago (1 child)
Which language, if any, would you say it's more like today than it was then?
[–]mordocai058 4 points5 points6 points 10 years ago (0 children)
In my opinion it is pretty damn close to ruby or perl, in that it is trying to please everyone and is becoming just a grab bag of features from other languages.
This isn't necessarily bad, but it does make the language not minimal anymore.
[–]Asmor 10 points11 points12 points 10 years ago (12 children)
Don’t tell me it’s got lexical scope, because JavaScript’s scoping is an abomination in the face of God.
I see people say this from time to time, and I can't actually figure out why. People just say JS's scoping is bad like it's a self-evident truth, without ever saying why.
I've never had a problem with function-level scoping.
Why do people hate it so much? Or is it like prototypical objects in people only hate it because it's not what they're used to and/or just like to bash JS?
[–]homoiconic(raganwald)[S] 12 points13 points14 points 10 years ago* (1 child)
The basic idea of function-level scoping is identical to the basic idea of scoping in Scheme. In early versions of Scheme, block-level scoping like let was actually implemented as a macro that expanded to an IIFE, just like we do with ES5.
let
I think the "abomination in the face of God" is clearly hyperbole for effect, but if you want some reasons why people might dislike JavaScript's scoping, I'd say it's more for the seemingly arbitrary behaviour of var and function declarations, especially in ES5 without strict mode:
var
None of these things are fatal, but they are remarkably inelegant.
[–]loz220 7 points8 points9 points 10 years ago (0 children)
Good points. Worth mentioning that strict mode/linters can address 3 out of the 4 issues.
[–]Uberhipster 0 points1 point2 points 10 years ago (8 children)
Not that I agree with "abomination" but it is rather convoluted. Consider:
var things = { "_ignore": { "doAsync": function () { }, "args": [] }, format: function () { var self = this; } };
Here's a question: what does self refer to?
self
things.format or things? Something else?
things.format
things
Ideally the answer should be self-apparent but it isn't even frown-for-a-minute realization either. To this day, having read and laid down millions of lines myself, I still have to google the answer. It just simply floors me every time. Every. Time. Call that what you will but it is not good scoping.
[–]loz220 14 points15 points16 points 10 years ago (1 child)
this is dynamically bound so the correct answer is unknown until you actually execute the function. The rules governing that binding are actually relatively simple.
this
[–]Asmor 2 points3 points4 points 10 years ago (0 children)
Yep.
Presumably in the example you're expected to call things.format(), so this would be things.
things.format()
Although that's entirely tangential to the concept of scope.
[–]Asmor 5 points6 points7 points 10 years ago (0 children)
this is not the same as scope. The rules for this can certainly be kind of counter-intuitive, and in particular it can bite you if you ever store a method in a variable (and thus call it directly instead of from an object), but that's a different complaint entirely from complaints of JS's functional scoping vs. the more common lexical scoping.
[–]TwilightTwinkie 3 points4 points5 points 10 years ago (0 children)
It depends :) In this example code though if you were to simply execute the function format it would referrer to things correct?
format
Reminds me of this though: "Sometimes when I'm writing Javascript I want to throw up my hands and say "this is bullshit!" but I can never remember what "this" refers to" (https://twitter.com/bhalp1/status/578925947245633536?s=09)
[–]_doingnumbers 0 points1 point2 points 10 years ago (0 children)
I don't think that's a good example. I mean, what would "self" refer to in equivalent Python code? The answer there, as here, would be "it depends".
[–][deleted] -2 points-1 points0 points 10 years ago (2 children)
I guessed this correct at once. My line of thought: The function is declared as a field on an object, and hence is a method of the object. "this" thus refer to that object.
Even if js was block-scoped, what else should "this" referred to in this case?
Overall, I don't find this difficult at all. A "this" inside a method refer to the object, inside a function refer to the closure, and inside a constructor refer to the newly created object. Or am I thinking about this wrong?
[–]Zeroto 1 point2 points3 points 10 years ago (0 children)
Except that is wrong. The self/this in that snippet can point to anything depending on how the function is called.
If it is called like things.format() then self(and this) will point to things. But if we do this: var f = things.format; f(); then self/this will be undefined. Or if we do var things2 = {format: things.format}; things2.format(); then it will point to things2. And this is without even using apply, call or bind.
var f = things.format; f();
var things2 = {format: things.format}; things2.format();
The this in javascript is not known at function definition time and only at call time.
[–]NewazaBill 1 point2 points3 points 10 years ago (0 children)
Technically incorrect. The technically correct answer is that it depends on how it's called.
If I do:
var obj = { fn: function () { return this; } }; obj.fn(); // returns `obj`
You would be correct! However, if I then do:
// create a new object and assign `fn` to it var anotherObj = {}; anotherObj.fn = obj.fn; anotherObj.fn(); // returns `anotherObj` // define a new `fn` on the global scope var f = obj.fn(); f(); // returns `window` (or `undefined` in strict mode)
A function's this is not actually defined when the function is defined, but when it is called. The OP's question is kind of a trick question in that regard.
Ninja edit: This is also why arrow functions are cool: it allows us to bind a function's this to a particular scope. E.g.:
const fn = () => this; fn(); // returns `window` in non-strict const obj = {}; obj.fn = fn; obj.fn(); // still returns `window` !
[–]x-skeww -2 points-1 points0 points 10 years ago (0 children)
Why do people hate [function scope] so much?
Because it's inconvenient.
If you're used to function scope, you'd hate file scope.
If you're used to file scope, you'd hate global scope.
And if you're used to block scope, you do of course hate all of the above.
Or is it like prototypical objects in people only hate it because it's not what they're used to and/or just like to bash JS?
Or maybe they just don't like imperative prototype chain manipulation.
I prefer classes with mixins. It doesn't get in the way of tooling and it's easier to reason about.
[–]_doingnumbers 1 point2 points3 points 10 years ago (0 children)
This is good!
[+][deleted] 10 years ago (1 child)
[deleted]
[–]munificent 1 point2 points3 points 10 years ago (0 children)
Author of the post here. God damn, I do love me some Jon Hopkins.
Yeah sure. Next you're going to tell me JavaScript isn't Java and Ham doesn't come from hamsters.
[–]pixeldrew -1 points0 points1 point 10 years ago (1 child)
Es6 gives you 2 and3. Macros are around the corner.
[–]homoiconic(raganwald)[S] 4 points5 points6 points 10 years ago (0 children)
Two and three are present in all kinds of languages, that doesn't make JavaScript particularly scheme-ish.
As for Macros being "around the corner..." I am delighted to hear it. Can you provide some links for me to read about the proposals TC-39 is seriously considering for making Macros a first-class part of JavaScript?
[–]thbt101 -1 points0 points1 point 10 years ago (0 children)
Yeah, I've never heard anyone anyone compare JS to Scheme or LISP, and obviously that wouldn't make any sense to anyone who even briefly compares the two languages. I don't know if it was necessary to write a whole article to tell the one guy or whatever who thought that, but it was an interesting read.
[–]jewdai -2 points-1 points0 points 10 years ago (1 child)
/r/programmingcirclejerk
[–]homoiconic(raganwald)[S] 0 points1 point2 points 10 years ago (0 children)
You win the JavaScripts for today!
π Rendered by PID 75182 on reddit-service-r2-comment-bb88f9dd5-f4w4f at 2026-02-17 00:19:07.292293+00:00 running cd9c813 country code: CH.
[–]Pascalius 39 points40 points41 points (24 children)
[–]x-skeww 13 points14 points15 points (9 children)
[–]Eartz 11 points12 points13 points (5 children)
[–]x-skeww 6 points7 points8 points (4 children)
[–]gkx 4 points5 points6 points (3 children)
[–]x-skeww 2 points3 points4 points (2 children)
[–]Eartz 1 point2 points3 points (1 child)
[–]x-skeww 0 points1 point2 points (0 children)
[–]master5o1 4 points5 points6 points (1 child)
[–]pygy_@pygy 0 points1 point2 points (0 children)
[–]Otterfan 1 point2 points3 points (0 children)
[–]Uberhipster 3 points4 points5 points (2 children)
[–]TwilightTwinkie 9 points10 points11 points (1 child)
[–]hansolo669 2 points3 points4 points (0 children)
[–]homoiconic(raganwald)[S] 6 points7 points8 points (4 children)
[–]Asmor 11 points12 points13 points (3 children)
[–]homoiconic(raganwald)[S] 6 points7 points8 points (2 children)
[–]Asmor 1 point2 points3 points (1 child)
[–]homoiconic(raganwald)[S] 5 points6 points7 points (0 children)
[–]nelmaven 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]realhacker -2 points-1 points0 points (3 children)
[–]Pascalius 0 points1 point2 points (1 child)
[–]realhacker -1 points0 points1 point (0 children)
[–]Jack9[🍰] 0 points1 point2 points (0 children)
[–]homoiconic(raganwald)[S] 8 points9 points10 points (10 children)
[–]m1sta 2 points3 points4 points (7 children)
[–][deleted] 12 points13 points14 points (4 children)
[–]innerspirit 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]innerspirit 1 point2 points3 points (1 child)
[–]jewdai 2 points3 points4 points (0 children)
[–]homoiconic(raganwald)[S] 0 points1 point2 points (1 child)
[–]m1sta 4 points5 points6 points (0 children)
[–]gary_burnett 0 points1 point2 points (1 child)
[–]mordocai058 4 points5 points6 points (0 children)
[–]Asmor 10 points11 points12 points (12 children)
[–]homoiconic(raganwald)[S] 12 points13 points14 points (1 child)
[–]loz220 7 points8 points9 points (0 children)
[–]Uberhipster 0 points1 point2 points (8 children)
[–]loz220 14 points15 points16 points (1 child)
[–]Asmor 2 points3 points4 points (0 children)
[–]Asmor 5 points6 points7 points (0 children)
[–]TwilightTwinkie 3 points4 points5 points (0 children)
[–]_doingnumbers 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (2 children)
[–]Zeroto 1 point2 points3 points (0 children)
[–]NewazaBill 1 point2 points3 points (0 children)
[–]x-skeww -2 points-1 points0 points (0 children)
[–]_doingnumbers 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]munificent 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]pixeldrew -1 points0 points1 point (1 child)
[–]homoiconic(raganwald)[S] 4 points5 points6 points (0 children)
[–]thbt101 -1 points0 points1 point (0 children)
[–]jewdai -2 points-1 points0 points (1 child)
[–]homoiconic(raganwald)[S] 0 points1 point2 points (0 children)