by crimsonalucard · 8y ago · 0 comments
I like Javascript. I hate DOM manipulations in the browser, and browser based differences, but Node on the backend is generally a pleasure to work with, and far, -far- better than most of the languages and ecosystems I've had to deal with. I prefer Erlang (well, and Elixir) for larger projects with complex concurrency/distribution/fault tolerance requirements.
Yes, Javascript was always hated. It certainly has some WTF elements to it that deserve some hatred. But for a straightforward, easy to learn, get things done language that doesn't lead to a lot of bloat, doesn't force you to be concerned with things you shouldn't have to be concerned with, etc, it's actually pretty solid, and I suspect a lot of the hatred has to do with the argh of the browser, in which no language will help you.
The DOM isn't a language issue, it's an API issue. That issue has gotten much better in recent times, but jQuery became popular because those API issues were so big. Today, you look at caniuse and see that almost every new feature is not implemented or partially implemented by at least one browser.
That's bad when talking about something like the File API, but that used to be the case for DOM primitive operations. Instead of one browser, every browser implemented almost every feature in an incompatible way. For example sizzle (the selector that's the foundation of jQuery) came into existence because there wasn't a unified way to do something as simple as selecting a node from the DOM.
Things like querySelectorAll have made life easier for most of us, but the DOM is still a maze of barely compatible implementations. I don't dislike it to the degree I used to, but I still don't like it.
What exactly is so difficult about DOM manipulation? I honestly don't get why people see it as a problem that warrants zillion badly written frameworks, while other critical language issues are pretty much ignored.
Everything in the DOM is basically a global variable, and any part of the app might manipulate any part of the DOM.
Example: Someone wrote CSS that is coupled to a child element (which seemed the clearest way to write it at the time) and someone else comes along to edit the content of the HTML which adds a layer and now your logic is broken even if the CSS still looks right. The frameworks make it easier to avoid that kind of fragile coupling / enforce a consistent way to manage the interaction of JS, CSS, and HTML.
All that said, web applications really are an entirely different beast than websites, even if they exist on a spectrum.
But none of that is an issue on the backend, where there's no DOM considerations. No HTML or CSS either. Just Javascript. And there it's straightforward, succinct, and usually easily understood (usual caveat of bad developers, but compare average Node codebases with average Java codebases).
The problem with javascript isn't that it's a terrible language per se - it's perfectly adequate for its actual, intended use case (lightweight scripting and DOM access.) The problem is that "flawed language designed in 3 days" is now being used everywhere, and that its ecosystem is a trainwreck of unnecessary complexity tied to a badly designed package manager linked to a proprietary backend.
Now, all of you, get off my lawn!