DEV Community

Discussion on: I'm Javascript. And I'm done taking your shit.

 
jpantunes profile image
JP Antunes • Edited

JS wasn't made for node, it was the other way around and I think that's obvious to anyone who can look at two release dates and tell which one came first. If you want to argue whether nodejs is a good platform for backend development I'm happy to engage in that discussion separately, but we'd need to talk about architecture(s) too because that's what influences my choice in tools and I suspect it's the same with you and most experienced professionals.

ES6 introduced more than just shortcuts, although those are very welcomed (imho) because I like terse code. Async/Await for example is definitely a bit more than syntactic sugar, it's a new language construct that allows devs to reason about their async code as if it was sync. Promises are great too and constructs such as Promise.all and Promise.race are really great. BigInt is a new primitive and it's not stored as a floating point (double-precision, 64 bit number) but as an object. From memory, numbers work the same way in JS, Python and Elixir, and probably every other language that implements IEEE 754.

You do touch on a pain point of the JS ecosystem, which is the reliance on modules to do very basic stuff. I don't blame the language itself as much as a combination of other factors, ie, most devs start coding in JS, therefore most code you'd see is from people with limited experience, therefore most bad code you'll see will be JS. Likewise, if most cars in Bavaria are BMWs, and there are only a few Lotus around, it's normal to see more wrecked BMWs than Lotuses, but that doesn't make it a worse car.

Now the question remains, how exactly is JS not a good language when its practical, expressive and feature rich and runs almost everywhere?

Thread Thread
 
fjones profile image
FJones

I won't rehash the arguments about the specific features (mostly because, as I said, I wasn't meaning to hate on JS too much and I'm not objecting to the features, but their uniqueness as a stand-out for particular use cases), so I'll just touch on the closing:

Practicality of JavaScript is betrayed by its legacy flaws in language design. If I'm not mistaken, the OP actually references quite a few of those. Heck, many of the points from "PHP Is A Fractal Of Bad Design" have their JS equivalent, and so the conclusion holds true as well: If I'm spending more effort on remembering the quirks, am I really using a good language?

JS is also hardly any more expressive or feature-rich than other languages. Arguably, the standard library is less feature-rich than that of most other languages, and with most of the syntax borrowed from existing languages (and shorthands becoming increasingly less verbose), that, too, betrays the strengths of JS.

That it runs everywhere is kind of my main point: Why does it run everywhere? And are those the right places for it to run? Is there any use case where it is a stand-out first choice as a language? Notably a use case where you have a choice. With language supersets like TypeScript steadily supplanting it, it isn't even the stand-out choice for web frontends anymore - and when it is used by itself, rarely without additional syntactic sugar like JSX. I can't name a use case where I'm given multiple options and would choose JS from them - even though the underlying paradigms of a prototype-based functional language should lend themselves well to that. Each use case JS is reasonably decent at has either no alternatives, or better ones. Better tools for the same job.

Thread Thread
 
jpantunes profile image
JP Antunes

JS is 25 years old iirc, it has plenty of history but why would anyone worry about the quirks instead of trying to learn it as a new language (post ES6)? Mind you that Typescript does not replace JS, it just helps some developers write type safe (at design time...) code, but it's still plain JS at runtime.

On another note, take a moment to read this sentence as if someone else wrote it: "Why does it run everywhere?.... Each use case JS is reasonably decent at has either no alternatives, or better ones. Better tools for the same job." To me this is an example of "old man yells at cloud", or are you going to argue that Netflix handling 15% of all web traffic with Node.js is a bad decision?