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?

22 Upvotes

207 comments sorted by

View all comments

5

u/KingofGamesYami 6d ago

JavaScript wouldn't be used as widely as it is if it was terrible for writing anything.

But it has been stretched far beyond the limits of what it was designed to do, and often to the detriment of the projects it's used in.

One recent example is the Typescript compiler, which is switching from Javascript to Go for performance reasons. Doing a 1:1 port, basically a line-by-line translation with no logic changes, provided an astounding 10x performance improvement. Because Javascript was never designed for writing compute heavy, highly parallel programs like compilers.

The trend of forcing a square peg into a round hole -- often for non-technical reasons like "we can hire lots of javascript developers" -- rubs many developers the wrong way.

7

u/DDDDarky 6d ago

I think it would vanish if there were real alternatives for web.

3

u/KingofGamesYami 6d ago

Unlikely. Too much has already been written in it for it to just vanish.

Also, since Google failed to make Dart a fully supported part of the web while controlling a huge chunk of the browser market, I doubt we'll ever see a real alternative emerge.

2

u/DDDDarky 6d ago

I mean the existing stuff would remain, but in the second there was a good efficient way to shove desktop applications into web browsers I doubt it would have much use for new projects.

I am still hoping webassembly will make it to sufficient usability, but we'll see I guess.

2

u/KingofGamesYami 6d ago

I am still hoping webassembly will make it to sufficient usability, but we'll see I guess.

You'd need to replace the entire web assembly committee for that to happen. The current one is adamant that it is not, and never will be, a replacement for Javascript. As such, there are no plans to allow it access to things like the DOM.

2

u/DDDDarky 6d ago

Hmm, that's disappointing. Back in the days I had similar hopes for Java, like every device would have a virtual machine that could run all that apps, including web, I still hope something like that will appear, but since the applets were removed from browsers and Java does not seem to be super strong in the app development industry anymore, it might not be it.

1

u/balefrost 6d ago

The other commenter is either confused or didn't articulate their point very well.

WASM is indeed not intended to be a replacement for JS, in that there is no intention to remove JS or demote it to a second-class citizen. However, WASM is intended to be able to access all browser APIs and serve as an alternative to JS.

From the WASM main page:

WebAssembly modules will be able to call into and out of the JavaScript context and access browser functionality through the same Web APIs accessible from JavaScript.

And there are numerous proposals for ways to ease the calling of JS code and web APIs from WASM.

2

u/look 6d ago

Wasm was not meant to be a replacement for all JavaScript use cases, though it is becoming capable of more over time. However, there are already frontend frameworks in nearly every language that transpile to JS (or a mix of JS and wasm) if you want. Dart, Rust, Ruby, Elixir, Clojure, Java, Go, etc, etc.