Why JavaScript Deserves More Love Than Hate
For a long time, JavaScript has been derided as not being a ‘proper’ programming language. It’s been classed as weird for its unstructured nature and often causes frustrations to those coming into it from other languages.
Despite this, JavaScript managed to move up from being just a scripting language that anyone can pick up to running and ruling over the web and its associated devices. Major companies like Netflix and Paypal live on JavaScript for their front and back ends.
Intermediary translation frameworks exist to transform your JavaScript code into a different language like Java and C++ — meaning that JavaScript itself must have at least the same abilities and capabilities to achieve the things it needs to achieve as these languages.
So why the hate? Why is it that ‘traditionally trained’ developers sometimes look at JavaScript with a sneer of derision?
Let’s Begin at the Beginning
JavaScript never had any intentions of being as big as it currently is. When Brendan Eich created the first version of JavaScript, it was done in 10 days.
Originally, he wanted it to resemble Scheme — a multi-paradigm programming language that many developers today have never even heard of, let alone encounter under normal circumstances in the wild.
JavaScript only looks a bit like Java because Netscape — the original commissioners of JavaScript — wanted to be part of the cool kids club and encourage people to take it up because it looks familiar.
However, the underlying ideas behind JavaScript still retain its Scheme origins and intentions. The paradigms that govern Scheme (and its associated sibling, Lisp) continue to live on in JavaScript like a hidden memorial for the grandfatherly language that’s twice the age of Java.
Apart from looking like Java, that’s approximately where the similarities end for JavaScript.
As a result of this false advertising, traditionally trained developers often encounter bouts of frustrations because they’re applying what they know against something that looks similar but isn’t producing the result they’re expecting.
The Good Part of JavaScript
Being multi-paradigm has its perks — mostly in the language’s ability to adapt to its requirements and not the other way around.
‘Traditional’ languages like Java and C++ have clear structural and syntactical requirements that need to be fulfilled for the program to compile.
JavaScript, in contrast, doesn’t care and will continue to run in the browser unless there’s been a major blip. For some, this is seen as the recipe of potential disasters through junk code bad patterns and hack jobs — but these things can also be found in traditional languages when the developer behind the code doesn’t know what they’re doing.
It doesn’t matter how robust a language is, an unskilled developer still has the same potential to create disasters, regardless of which language they’re coding in. It’s just often made worst when they work in a space away from their domain of ‘expertise’.
The multi-paradigm nature of JavaScript also means that patterns can be adapted for its requirements and implemented for best results. You’re not bound to a singular inheritance pattern. With JavaScript, you have a choice of pseudoclassical, prototypal, and differential, and even functional inheritance.
The Annoying Part of JavaScript
Strongly typed values is not something that is a ‘thing’ in JavaScript. You can just throw whatever value into the box and hope that it won’t break the application later down the line.
This is probably the thing that gets a lot of developers transitioning into JavaScript annoyed. Everything is either a var
or let
. However, this isn’t as big an annoyance as everyone seems to be making out since the advent of TypeScript.
The annoying parts of JavaScript are probably more to do with the unexpected strange parts like double-precision floating points, coercion (where variables are not typed but values are), callback hell for those still getting their heads around promises and async, and almost everything being a global variable because you can’t declare them private or public (fixed through TypeScript).
For some, JavaScript is like that project you were told to make ‘as flexible as possible’, only to find that it’s so flexible to the point that it looks like a spaghetti gloop. Some people prefer structure and clarity over creative flexibility — and I don’t blame them.
It’s All About Mindset and How Much You Know
As developers, we tend to be biased towards what we know best. Resistance to a different way of thinking is natural and part of the learning process, especially when we become entrenched in code patterns we know work.
But while some patterns may work well for a certain language, it is not always universal or the syntax is structured so differently that you can’t quite ascribe the same ways of thinking to achieve the same results.
While a lot of what you already know in programming is transferrable to JavaScript, there is also a lot that isn’t. The beauty of JavaScript is that it can be picked up by anyone — making it also its biggest weakness.
No one has to sit through hours of computer science classes just to get a working program or wade through several days worth of tutorials, content, books, and reference manuals just to get the basic concepts.
JavaScript is probably the only language where you can copy and paste code from Stack Overflow and, 90% of the time, it’ll work the first time around — regardless of environment, set up, and dependencies. It’s that kind of language.
That’s why it’s also important to take the time and learn it properly — from the ground up without any side distractions like libraries and frameworks, which often come with their own requirements.
Everyone talks about learning Angular, React, and Vue, but never really about Vanilla JavaScript.
Final Words
The level of hate that JavaScript gets varies. It also depends on how entrenched the developer is in their native language.
Yes, JavaScript is weird — but so is Java, C++, Swift, Python, and every language that’s currently out there, depending on the perspective that you’re looking at it from.
To truly value the power and potential of JavaScript, you need to cut through your personal preferences, biases, judgments, and preconceptions about the language based on what you’ve heard about it.
Only then can you truly begin to approach your code with an open mind and not get stuck in a self-perpetuating feedback loop. This is because, as humans, we tend to choose only what we want to see rather than reality.
To be an effective and efficient developer, you need to learn how to move beyond this. Senior developers have this skill mastered.
Perks, quirks, and everything else in between, I conclude that JavaScript isn’t as bad as some developers make it out to be.