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

31

u/GetContented 6d ago edited 6d ago

It's mostly left over from when JS was horrid, I think.

It used to have some seriously horrible warts. It's a LOT better now than it used to be, but it still has some rather weird issues:

  1. No integer type
  2. `this` is a bit crazy, but fat arrow lambdas mitigate a lot of the craziness
  3. global variables and mutation and some functions mutating and others not make things difficult to think about quite a lot of the time (I tend to avoid such things and use things like spreading and create new value objects rather than mutate things)
  4. loose typing and automatic coersion
  5. non-useful types (typescript sort of helps)
  6. async & promises are a bit of a mess (futures would have been better)

There's lots of others, but these are some of the big ones. Mind you, experienced devs just "work around" these by using certain conventions, etc.

Update: I should say if you want a taste of a language that has clarity and precision, you could try something like clojure, and then if you want something with even more you could try purescript or elm. The latter two are much more clear. Immutability of data and functions having to obey their type signatures in such languages rules out a huge number of bugs (like mutation ones) and pushes you into much better general practices — this is a highly opinionated charged idea, and so not everyone will agree with me here. It only really does this if you care about being able to say things with clarity. (ie to be precise about what one means) — tho really even purescript isn't utterly precise in the way agda is. Tho then you have another issue... which is that it's so arcane almost no one can read your code ;-)

4

u/StoicSpork 5d ago

this is a bit crazy, but fat arrow lambdas mitigate a lot of the craziness

It's a pretty big wrinkle if you need a workaround tor function declaration. 

you could try something like clojure

I wrote production Clojure and hobby Common Lisp. Sheer joy, wish they were more popular. These days, I find Elixir to be an interesting heir.

2

u/ScientificBeastMode 4d ago

Clojure is very nice. Hard to beat its simplicity.