The Case Against JavaScript
The Case Against JavaScript
It’s not a language with warts; it’s a minefield
https://medium.com/javascript-non-grata/the-case-against-javascript-75854c07bfba
Once in a while, I come across an article so beautiful in its elegance, and so persuasive in its delivery, that I am compelled to give it great tribute. The JavaScript Minefield is such a masterpiece.
My personal experience with this language has been less than edifying. It’s an awful, horrible, detestable language. I’ve been told by Douglas Crockford that there are “good parts” to the language; if you use a carefully chosen subset of JavaScript, you can write wonderful software. That may be, but the suggestion goes counter to every intuitive sense that I’ve acquired over 30 years in the IT industry.
I have used many languages in my career. I’ve used FORTRAN, Modcomp assembler, Tandem TAL, C, C++, C#, Smalltalk, Objective-C, Java, Python, and Go. NONE of these languages advocate avoiding certain parts of the language. What the hell kind of language is it that needs this kind of cautionary?! I’ll tell you: an extremely poorly designed one. A pathological one.
I have NEVER used a language that fails silently for syntactical reasons. Jesus Christ, how can this be???
How can this be?
(Yes, I know, it’s the browser’s fault; it’s an implementation issue. But given that JavaScript is the language of the web, you have to conflate the language with its implementation. There has to be a proper way to handle errors in the browser. Silent failure is not an option.)
Look, I know there is no such thing as a perfect programming language. Every language has its “warts.” But JavaScript is problematic on an epic scale.
Watch Where You Step
As Jeff Walker says, if you’re going to enter a minefield, you need one of two things: 1) a safe path through the minefield; 2) a detailed map of all the mine locations.
Douglas Crockford’s book, JavaScript: The Good Parts, provides such a safe path. However, it is all too easy to accidentally stray off the path. And sometimes, you have to step off the path.
Crockford’s book, as well as others, offer a map of the mines. This is problematic, too. Having to use a map while you’re programming is a major P.I.T.A. To paraphrase Crockford: “Programming is difficult business. It should never be undertaken using an inferior tool that imposes a heavy burden.” The added cognitive load of keeping the JavaScript minefield map in your head makes your job that much harder. Why should you take it upon yourself?
Why?
Linting is the best bad option of all the bad options
Tools such as JSHint and JSLint go some way to mitigate the awfulness of JavaScript. But it is not a complete solution and it suffers from some major drawbacks, the most egregious of which is this:
You have to drop out of your browser workflow to manually run the linters.
Sorry, I cannot abide by this. Linting should be directly integrated into the workflow. It should not take away the convenience of coding/testing in your browser and IDE. (Disclosure: I write applications using Go, Python, and JavaScript from within an IDE.)
And even if you could solve this problem, linting has genuine limitations. It won’t protect you 100 per cent. (Read Walker’s article.)
Recommendations
Don’t use JavaScript. Or at least use it as sparingly as possible. That’s what I do. I use jQuery to spiff up my web applications; I expect that will be my only exposure to JavaScript.
Use a tool that sits atop the minefield. Something like Dart or Go compiling into JavaScript is a possibility. There aren’t any good options at the moment, though (Dart is probably a dead-end) [1]. So I shall have to be patient and wait…
Until I do find the answer, I shall avoid JavaScript like Ebola. When I use jQuery, I shall don my hazmat suit and get the hell out as soon as I’m done.
Alternatives
Actually, there is a good option: it’s called Amber. https://medium.com/@richardeng/a-gentle-introduction-to-amber-8c532631e9ab
What’s wrong with loving JavaScript? I never understood why I can’t use it for everything.
quora.com Richard Kenneth Eng’s answer to What’s wrong with loving JavaScript? I never understood why I can’t use it for everything.
The simple reason is that JavaScript is one of the worst designed programming languages in the history of programming languages (putting aside joke languages like Brainfuck). For starters, it doesn’t even have an integer data type! What other language doesn’t have integers?
JavaScript doesn’t have normal arrays as most programmers understand them. JavaScript is one of the only few languages in existence that have weak typing (not to be confused with dynamic typing), which results in many crazy-ass coercions. JavaScript is the only language I know of that can actually fail silently at runtime due to syntactical errors!
And I’ve just barely scratched the surface. The fact that a book like Douglas Crockford’s “JavaScript: The Good Parts” is even necessary tells you all you need to know. The fact that a linter is practically mandatory for using JavaScript safely speaks volumes.
You can’t even use JavaScript to prepare a beginner for the IT profession because nearly ALL other major languages are class-based OOP languages…Java, PHP, Python, C#, C++, Ruby, Objective-C, Perl, Scala, Swift. JavaScript is heavily based on object prototypes, a dubious feature shared by only one other language of any significance: Lua.
So JavaScript will teach you a whole lot of bad habits that are not transferrable to the rest of the IT industry.
You have to understand that the ONLY reason JavaScript dominates in web development is because web devs have no choice. JavaScript is the ONLY language available in the web browser. If web devs had a choice, they sure as hell wouldn’t choose a moronic language like JavaScript!
Here’s the truth: the web development community has effectively been held hostage by JavaScript. Only the Stockholm syndrome convinces everybody that it’s a good language. What this community seriously needs is a “deprogrammer.”
Sure, JavaScript has a presence in several other domains, but in mobile, Java and Objective-C/Swift rule. In desktop, Java, C++, and others are popular. In games, it’s pretty much all down to C# and C++. In cloud computing, it’s Java. In numerical computing, it’s Java, Python, and C++. In data science, it’s R and Python. In finance, it’s C++ and Python. In robotics and the Internet of Things, Java, Python, C, and others are extremely popular. And so on.
Outside of web development, JavaScript has traction server-side, but Node has rather limited applicability. For high performance, high availability server applications, there are many superior alternatives such as Java, Scala, Clojure, Go, Erlang, etc.
Despite what others may tell you, JavaScript is not the universal programming language. To do well in the IT industry, you need to be polyglot. So broaden your scope with Java and Python, at the very least, and give serious consideration to picking up Go, C#, and one of the FP languages (such as Haskell, Clojure, Erlang).