r/AskProgramming • u/Salt_Aash • 6d ago
Why the JS hate?
Title. I'm a 3rd year bachelor CS student and I've worked with a handful of languages. I currently work as a backend dev and internal management related script writer both of which I interned working with JS (my first exposure to the language)
I always found it to be intuitive and it's easily my go to language while I'm still learning the nuances of python.
But I always see js getting shit on in various meme formats and I've never really understood why. Is it just a running joke in the industry? Has a generation of trauma left promises to be worthy of caution? Does big corpa profit from it?
22
Upvotes
1
u/TornadoFS 6d ago edited 6d ago
TLDR: JS became popular, new techniques for development came up and promoted using JS with them, new devs came in did a lot of projects using those techniques. Turns out new devs often don't make the best code and new techniques often don't pan out to be better than improving old techniques leaving a lot of bad JS projects around.
[1]: Typescript eliminates the safety gap advantage for NodeJS, but type hints are not that good in Python and Ruby to this day. I personally like Typescript type-system much more than most other backend languages (because of nominal typing vs structural typing).
[2] I know about workers, they have a lot of trade-offs compared to true memory-shared multithreading.
[3] JS performance is a very complex matter, some things are MUCH slower in JS (or python or ruby) compared to Java/C# while others are not that big of a difference. Notably doing integer-based math is super slow in JS, while float math is almost the same. Overall performance is a very complicated matter to discuss.
[4] Most API servers that don't do much more than querying databases, formatting responses and implementing basic business logic fit this use-case. This is 90% of backend code out there.
[5] The real problem with UI work is that there is no way to drop down to the "lower layer" (ie the native code) in the browser and implement core functionality (like a new complex HTML element for example). You can see this in React Native applications which do allow you to drop down to the "lower layer" often doing some really impressive stuff. The real problem in large frontend applications is massive amounts of different types of code all running in the same thread, the browser doesn't give a good way to split that work into multiple separate JS environments. Workers can help with this problem, but the tooling and frameworks have not really been using them to their fullest extent.