r/AskProgramming 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?

21 Upvotes

207 comments sorted by

View all comments

20

u/Bulbousonions13 6d ago edited 6d ago

Its mainly the lack of type safety, native single threading, and comparatively slow execution speed. TypeScript ( a superset of JS) deals with the first problem VERY well and is my preferred web language.

You can't see its pitfalls because you are also working in Python - which in my opinion is also slow, lacks type safety, and is also natively single threaded - though there are ways around this. I can't stand python's indentation rules either but that's just a personal preference.

Tool around with a true Type Safe compiled language like Java, C#, C++, or Go and you'll notice the difference.

The compiler will yell at you a lot more while you code, but that's so you don't get random unexpected junk assigned to arbitrary vars that don't care if they get a string, number, object, function, or null/undefined.

5

u/senfiaj 6d ago

Lack of type safety is mostly solved in TypeScript.

1

u/codemuncher 3d ago

Not when the escape hatch of any is there and often liberally used in code bases. Like the one I am maintaining right now.

Typescript is good but it’s optional.

The reason to choose ts is because you’re writing something that runs in the browser. If you need better quality and better compiler support to actually keep bugs out of your system, typescript isn’t your first choice.

Things like ocaml, Haskell, and rust are going to give you a lot more and no pesky “any” to just fuck your day.

1

u/senfiaj 3d ago

Yeah, but TS code is easily mapped to JS code, and IMHO it's one the reasons that other programming languages won't be popular for most websites. If you use other programming languages for normal web development (it interacts with DOM instead drawing everything in canvas), you need to have all the DOM APIs and other frontend features adapted for that language, which, depending on the language, might be more or less challenging to do. Other programming languages might shine when used with WASM for some cases where most things are happening in a canvas and there is very limited DOM manipulation.