Giles Bowkett: Don’t Use JavaScript, Use a Language
- December 30th, 2011
- Posted in Coding
- By AMB
- Write comment
Giles Bowkett is one of the few people who routinely writes essays that strike me as obviously wrong right up until I agree with them completely. Which is a fancy way of saying that he usually knows his shit and he’s always pretty persuasive. At least when it comes to tech anyway. (I disagree with most of his non-tech writing, but I suspect that’s due to us having different axioms.)
At any rate, the most recent essay to give me that sense was his recent post defending the proposition that “JavaScript is not a Language”. Go and read it, and consider it the next time JavaScript permits, forces, or cajoles you into some ridiculous hack or frustrates you with its ridiculously vague and squishy syntax.
If he’s reading, I’m interested what Smurf of Azure Abstraction has to say as a JavaScript hacker par excellence.
At any rate, I think Giles’ piece is substantially true and an interesting view of the problem. I think it helps to contextualize all the redefinition and pointless syntactical recursion I’ve had to put up with from JavaScript over the years. I can’t say whether or not CoffeeScript is better (not used it myself) but if it is, as Giles would have it, an actual language, then I can’t help but think it must be an improvement.

He’s using a pretty wonky implied definition of “language”: a programming interface that falls at a particular level of abstraction. This would of course define C (without cstdlib) as not a language, since you have to write everything for yourself. I’m not willing to accept that definition.
His argument for modularity almost makes sense, except that CoffeeScript, his proposed alternative, is compiled into JavaScript. This means that his classical object oriented system is now… nothing more than sugar. Yet he still complains about libraries that add modules to JavaScript, such as require.js. I would argue that there is little difference between the two approaches.
Frankly, I don’t see what this essay adds to the discussion. His title is overreaching to the point of absurdity. His examples are poor — the Rails example is only tangentially related. It comes down to “I don’t like JavaScript because it doesn’t provide features XYZ at the language level.” While this is a perfectly reasonable statement, it’s not the one he said he was making.
Hey Chris, thanks for your comment. I suspected you’d disagree and was confident that you would do so interestingly, and I’m happy to be right on both points.
I think that his argument rests mainly on what people would consider “language-level features”. Things like inheritance mechanisms, typing, etc. JavaScript has essentially none of them. And yes, CoffeeScript compiles to JavaScript, but the point, I think, comes back to the old saw that “code is primarily for people to read an only secondarily for people to execute”. That CoffeeScript renders to JavaScript before execution isn’t that much of a knock against Bowkett’s argument.
I think your C comparison can actually be useful here. While it provides some of the linguistic scaffolding of modern languages, there’s a reason why C++ has become the standard. Both languages compile down similarly, but C++ is substantively better from a programmer perspective exactly because it’s got more language-level features.
I will concede your point that Bowkett’s assertion about JavaScript not being a language is mostly rhetoric. It is, after all, trivially true that it is a Turing complete language same as any other. But it is so abstract and, for the lack of a better term, squishy, that a more featureful, rigorous language (like CoffeeScript) is needed.
If compiling to JavaScript makes CoffeeScript’s OO “only sugar,” does that mean C is only sugar on top of Assembly?
Even C has a single way to require files.
It’d be nice if CoffeeScript could solve the require problem, but it can’t really; the best it could provide would be a toupee. The Node community is doing a pretty good job of making CommonJS a convention, which is close enough, but it doesn’t change the fact that it’s a ridiculous problem to have, and it’s likely to be a good long while before cleanly structured modular requires are a commonplace thing on every web page everywhere — assuming that ever happens at all.
I don’t deny my argument had some serious technical flaws, but overall, I think it comes closer to nailing the problem than anything else I’ve seen in the conversation thus far.
Aaron, thx re the “obviously wrong until I agree completely” thing. I like that, it might even work as a slogan. ;-)
Giles –
Thanks for reading and commenting. I think your post hits at the heart of my issues with JavaScript, which is that it’s so poorly defined that it can be redefined on the fly and it often forces you to do so to get work done.
Solving my coding problems is hard enough without having to solve my language at the same time.
I mean, seriously, any language that requires pages of exegesis on the differences between undefined and null needs some work in my book. http://stackoverflow.com/questions/801032/null-object-in-javascript
I think we’re pretty much in agreement on most of the points you make. My main problem with his argument is that *we* have to make it for him, since he does such a poor job himself.
Only one of his paragraphs is about what JavaScript lacks: a language-level import statement. The rest of his post is about Lisp, except for one random paragraph about why Rails doesn’t have a to-do list generator.
If we were to talk instead about how JavaScript could be improved, this conversation would be very different. I think a ground-level rewrite would be really interesting (though not particularly practical).
It reads like a dashed-off post, to be sure. But I think his point is valid. JavaScript’s so nebulous that to do any serious work you end up creating your own defacto domain-specific language out of it.
As for a ground-level rewrite, I’m curious to hear what you (as the best JavaScript hacker I know) think should be fixed in a new ECMAScript-implementing language. Any particular thoughts?