DEV Community

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

 
fjones profile image
FJones

And yet, none of the examples you list are ones I find particularly compelling. Yes, JavaScript is easy-to-use - as easy as most any scripting language. It certainly isn't hard-to-get-wrong, though.

node.js is exactly one of those environments JS wasn't designed for. It has, in many ways, combined the worst parts of Python, Java, and PHP into one, with few noticable upsides. Talk about misusing a language.
Async/await is a construct that embraces easy-to-get-wrong if anything - conventional Promises were actually better than this.
BigInt in a language where everything is a low-precision float is another matter of working around language design. Yes, almost every language faces this, but JavaScript's solution isn't unique either - much as it isn't for streams and generators.
And ES6 is indeed the point about a language evolving over 20 years: Most of ES6 is syntactical shorthands for existing functionality. JavaScript has advanced, yes, but so have other web languages. PHP 8 is still struggling from old flaws, but it, too, is a huge change from 20 years ago. Does that make PHP a good language now? Many of the flaws in language design are still there.

Mind you, I wasn't trying to hate on JS all that much. It's a flawed language like many others. I'm trying to see anything it excels at in productive use, used as an example of JS being good. Every language has its use - what is JavaScript's? Versatility, perhaps. But is that due to the language or due to the ubiquity stemming from its use in Netscape? I would argue the latter, and I would argue that a jack-of-all-trades language just opens itself up to even more misuse.
Cryptography in JS is something I'll freely admit to continue hating on, though - and that's even ignoring the constant security flaws in that ecosystem of modules.

Where Perl and PHP are the duct tape of the web, JS is the splint. It's useful, but it isn't good.

Thread Thread
 
190245 profile image
Dave

Seriously now... can you please come to work with us?

Why don't others in the industry understand? Appropriate tool for the job, that's all that matters.

Have some love, you deserve it!

Thread Thread
 
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?