[Opinion] Why is JavaScript so unpopular?

View original thread
Henrique Barcelos's photo

I think the main issue is that people don't know JavaScript very well.

JavaScript itself is sort of a Frankenstein. Non-technical people tend to think it is somewhat similar to Java, which couldn't be further from the truth. What Brendan Eich wanted to do back in the time while he was designing the the first version of JS was something like Scheme in the browser. He was "forced" by non-tech stakeholders at Netscape to make it look and feel like Java, because of its popularity back in the day.

So JavaScript has an identity problem. While at the surface it resembles Java, on the one hand because of the name and the other because some constructing blocks and its syntax, it is very (very!) different from it.

For starters, JavaScript is not a traditional OOP language. Despite the last years effort of making it more familiar to OOP developers with the introduction of keywords like class and all that comes with it, under the hood it is still 100% prototype chaining. And that's what almost everyone that writes JavaScript doesn't understand. I've been JavaScript'ing for about 10 years now and I can count in my hands the number of people I've crossed paths with which truly understood the nature of JavaScript prototype model.

I believe the recent wave of Functional JavaScript probably made Brendan Eich happy, because it is much closer to what he envisioned there than the persisting OOP-dominant view we had so far. While not a full-fledged functional programming like Haskell, OCaml, F# and others, FP just seems way more natural to JavaScript constructs than OOP. In fact, most of the clumsy stuff in JS is related to how it treats objects. It took me years to understand this properly and if I'm not paying attention, I can do something wrong with it even nowadays.

Another reason why I love JS (well, most of the time at least) and probably why many people hate it is the degree of freedom it offers. I think the only other language I know that won't get in your way even if you are doing stupid things is PHP. JavaScript lets you free to do whatever you want, but freedom always come with responsibility. It can be burdening having to think about every detail on how to architecture your app, what should be the folder structure, which framework to use. People tend to suffer from analysis paralysis. I myself suffered from this. But then I learnt to embrace this freedom. Every time I start a new project, I get to experiment new patterns, new structures, take some concept borrowed from a language I'm just learning. Sometimes very good things are born from that. Sometimes I fail spectacularly. And that's ok!

People who tell that JS doesn't scale probably forgot to tell that to Paypal, Netflix and many other big companies out there. Here ns Brazil there is big bank whose API layer is (or was about 3 years ago) entirely written in Node.js. Even Microsoft has embraced it.

"Oh, but without type safety, if you change X in Y place, you can break something somewhere in Z". Sure. This also happen in more strict languages, you just discover that earlier. Usually this is a symptom of a much deeper problem: you are not setting the boundaries correctly in your application. There is too much coupling. And if you really really need that compiler telling you you are a moron, that's what TypeScript is for. And guess what, TypeScript is just JavaScript with some sugar on top of it. The programming model is still the same, the constructs are mostly the same, the syntax is very similar as well.

In the end, it all comes around to that old saying:

There are only 2 types of programming languages: the ones people complain about and the ones nobody uses.

Jacob Bogers's photo

Well, JS is extremely popular (>80% coders use JS) because it makes a dev fungible, I think this "negging" is more counterculture thing, JS is very established so its "cool/hipster/rebellious" to kick against establishment.