12
Lensflare
326d

I want to explain to people like ostream (aka aviophille) why JS is a crap language. Because they apparently don't know (lol).

First I want to say that JS is fine for small things like gluing some parts togeter. Like, you know, the exact thing it was intended for when it was invented: scripting.

So why is it bad as a programming language for whole apps or projects?

No type checks (dynamic typing). This is typical for scripting languages and not neccesarily bad for such a language but it's certainly bad for a programming language.

"truthy" everything. It's bad for readability and it's dangerous because you can accidentaly make unwanted behavior.

The existence of == and ===. The rule for many real life JS projects is to always use === to be more safe.
In general: The correct thing should be the default thing. JS violates that.

Automatic semicolon insertion can cause funny surprises.
If semicolons aren't truly optional, then they should not be allowed to be omitted.

No enums. Do I need to say more?

No generics (of course, lol).

Fucked up implicit type conversions that violate the principle of least surprise (you know those from all the memes).

No integer data types (only floating point). BigInt obviously doesn't count.

No value types and no real concept for immutability. "Const" doesn't count because it only makes the reference immutale (see lack of value types). "Freeze" doesn't count since it's a runtime enforcement and therefore pretty useless.

No algebraic types. That one can be forgiven though, because it's only common in the most modern languages.

The need for null AND undefined.

No concept of non-nullability (values that can not be null).

JS embraces the "fail silently" approach, which means that many bugs remain unnoticed and will be a PITA to find and debug.

Some of the problems can and have been adressed with TypeScript, but most of them are unfixable because it would break backward compatibility.
So JS is truly rotten at the core and can not be fixed in principle.

That doesn't mean that I also hate JS devs. I pity your poor souls for having to deal with this abomination of a language.

It's likely that I fogot to mention many other problems with JS, so feel free to extend the list in the comments :)

Marry Christmas!

Comments
  • 2
    @aviophille 🐒
  • 1
    This is somewhat of a response to ostream’s comment in another rant:

    "(…) Unless your whole point, like the other retard, being that JS is shit, without the slightest beginning of an argument (…)"
  • 12
    🍿 🍿 🍿 🍿
  • 0
    I still like it.
  • 6
    tbf. i like the idea of Null and undefined.

    Especially in the context of backend.

    Null and undefined helps make a distinction between a value remaining the same as before vs explicitly setting it to null
  • 1
    @iceb this is simply abuse of the language. And people not caring about that shit is part of the problem ^^
  • 1
    You could fix all of that, and JS will be still be a dumpster fire of a programming language.
  • 1
    @aviophille can invalidate your argument. Even skilled devs (who work in a node environment) run into the mentioned problems atleast once in a while.

    I know, because i break their software constantly. It's literally my job.
  • 1
    @SidTheITGuy if you fix all of them, it might actually improve in reputation. But i doubt it's gonna happen ever because "backwards compatibility"

    What web dev really needs, is either a new language for developing large scale projects, or opening up more to the large ecosystem of developing software as in almost every other area in software dev.
  • 1
    @superdupernova unfortunately not..
  • 2
    @superdupernova

    Typescript transpiles to JS.

    It is a superset of JS. Thus it inherited a large portion of the mentioned problems.

    @iceb

    The only reason for undefined is that JS allows by design undefined variables.

    Which is one of the worst design decisions a language can make.

    There is literally nothing good in allowing undefined behaviour by trying to make it "semi defined" (aka setting it to undefined).

    Ask the C / C++ / ... guys.
  • 3
    It’s a pretty good list. I don’t have much to add to it. JavaScript is a decent language but it has the faults that lots of other languages do, and they aren’t in the language as mistakes but rather intentional design to make it easier to use.

    If you’re trying to take JavaScript seriously, you’re gonna have a hard time. But if you’re aware of its quirks and the fact that it was designed for a developer with less brain power than you, it does the job pretty well and I still quite like it. Python does bug me a bit though, such an ugly piece of shit with no real identity besides being the “spaces are syntax” one.
  • 5
    Maybe javascript is crap language but no other language offers you ability to modify infinite numbers of UI elements and become developer just by opening developer tools on any website on this planet.

    The accessibility of javascript kills every other language and at the same time provides a very large doors to the developer world.

    So given that I'd say javascript is great language for beginners who want to try if they like software development.

    I can say we owe javascript that we have so many developers on this planet, so many technologies and that software development is taking over the world. We owe this to javascript because people want to leave crap language and do something more.
  • 0
    The problem is the people who made it back end language and use it for something else other than front end scripting language.

    As long as you stick to using it to make XHTML and fetch request, and manipulate DOM with getElementById(), it's a pretty fine language. Null/undefined/generic/int/etc doesn't matter since I only use it to update InnerText and InnerHTML.
  • 0
    I’m commenting on this now so I can form a proper counter argument for when I’m not drunk and sleep deprived
  • 0
    what frontend languages do *you* use?
  • 1
    @sleepyObjobjobj Swift for iOS and Kotlin for Android.
  • 0
    Even though I really hate the JS everywhere syndrome, almost all of your arguments are about the dynamic type system. Listing the effects of a dynamic system one by one doesn't make it a separate argument.
    And your argument why that is so bad is just because.
    You obviously don't know how to work with a dynamic typed language. It's like complaining about floating point precision mistakes. Plenty of memes, every language is affected by it.

    The in browser behaviour is the only real point you have IMO. In browser it's nice that it tries to correct html, js and don't fail loud. Outside it, it's horrible.
  • 0
    @hjk101 I have only one point about the dynamic type system. It’s the first one.
    What are the other ones in your opinion?

    My argument why it’s bad? I already said that for scripts it is ok. For a programming language the reason why it’s bad is pretty obvious: You don’t get all the benefits of compile time type checks. If you don’t see it as a downside, then you probably don’t have any experience with real programming languages.

    I know that floating point weirdness is present in any language and I’m experienced enough to not include it as a weakness of JS.
  • 1
    @hjk101 imho your argument is kinda bogus.

    Its not "just" dynamic typing.

    Dynamic typing is just one very large general topic.

    @Lensflare went then into the details of which specific aspects of dynamic typing / the type system are bad.

    I guess that is what most people fail to comprehend: details matter.

    JS is the kind of "sloppy work" of a handyman who should have known better.

    A lot of these details could have been resolved - either before the first final spec or in one of the very late ECMA script steps.

    So its not "just" the dynamic typing system.

    Its a lot of smaller and larger details that should have been fixed - but despite better knowledge (or at least despite better knowledge being available at that point of time) they just omitted it.

    ECMAScript is now in its 14th revision.

    A lot of these details could have been fixed.

    But they do not bother.

    Its kinda like a craftsmen tiling your room with the right tiles, but rotating them, chipping them up and when you ask him when the fuck they will fix this bloody mess they look at you and ask you whats wrong...

    Well. That is wrong. The ignorance.
  • 0
    @Lensflare
    The '===' when you want them to also be the same type is a dynamic type thing. Same as the truthy/falsy and generics. Generics are there to make things for agnostic, pretty silly with for a dynamic language that has everything generic by default...

    In my mind you just disqualified yourself with the "real programming language statement". That's just stupid elitism and insulting to people that do real programming with languages that you don't approve of.
    And don't worry about insulting me. I usually have worked professionally with about 7 more real (and perhaps in your mind imaginary) programming languages than my peers.
    My primary language is Go and I dabble in electronics with C/C++ and assembly for fun.
  • 0
    @hjk101 with generics, I kinda agree, it’s a consequence of dynamic typing.

    === has nothing to do with it.

    Truthy/falsey has also nothing to do with dynamic typing. See C/C++: It has a lot of this stuff but it has static typing.

    I don’t insult anyone. JS has been developed in a few days with not much thought put into it and is now abused for programming. The design decisions made back then are still present in today’s JS and will always be the major part of JS to keep it backward compatible. It IS in fact not a real programming language. People using it as one doesn’t change this fact.
    And if people get insulted by that, it’s not on me.
  • 1
    @Lensflare you’re wrong in saying it’s not a programming language. If you get insulted by that, it’s not on me.
  • 0
    @black-kite Why should I get insulted by a wrong claim? 🤔
  • 0
    @Lensflare

    By the way... Python added a sort of generic typing.

    https://mypy.readthedocs.io/en/...
  • 2
    @black-kite this. I also find it insulting to all the people that worked on the language for years to say it's done in a few days. Like what they have done has no meaning at all. IMO great improvements were made with additions of async, arrow functions and type hinting. Every older language has to deal with legacy, browser support is still lagging behind in adoption of ECMAscript standards.

    I still hate the overuse of the language and it's the least favourite of my toolkit. But I can respect the work that has gone in it and what people are doing with it.

    This is of course a ranting platform and fair game to complain about things. Likewise I feel the need to defend older languages (that are actively developed) because they get a lot of hate, most of it unjustified IMO because they have legacy they need to support. The brilliant engineers that work on the languages get so much insults it's insane.

    @IntrusionCM Yep that is one of the static type improvements they made in python.
  • 1
    @hjk101 static type *hints*.

    Python has dynamic typing like JS.
  • 0
    @IntrusionCM yes I know it's static type support in a dynamic typed language. The way to do that is with type *hints*. Where hints are a bit misleading because they are compiler/interpreter enforced, as in won't run on violation of the *hint*.
  • 2
    @hjk101 not true either.

    The Python runtime does not enforce type hints at all.

    Thats what static type checkers like MyPy do.
  • 0
    @IntrusionCM sorry didn't know that was the case with python. It is with PHP and assumed the same with python as I couldn't find anything on it that quickly.
    Thanks!
  • 1
    @hjk101 no problem.

    Sounded probably more rude than it was meant to be :)

    Yeah, PHP has the strict_types setting that must be set, then compiler will check.

    Python went after the version 3 fiasco another way - add what is missing, allow others to experiment with it via extension system / FFI / what not.

    MyPy / Pylint / Flake / Black... Or Rust based Python extensions like Polar.

    Imho Python does show that dynamic typing doesn't have to be bad and giving people the necessary tools to experiment and extend the language to their liking, a lot of good can happen.

    E.g. the type hints were first an additional library and are now part of the core language.

    A language can evolve. Even without breaking everything. It just requires careful design.

    Python 3 was in my opinion what one could call a necessary evil. But - just to stay on the rant discussion - the ECMA Script versions *did* break backwards compatibility.

    Currently having a flu so some chaos in my brain...

    Reason I mentioned the Generics in Python is because Generics and dynamically typed doesn't have to be a contradiction.
  • 0
  • 1
    @Lensflare you’ve done a good job exposing the flaws of JS and I fully understand and agree with your point of view. I myself use TS and wouldn’t want to work on a JS project again as I have in the past.

    Nevertheless the truth is that JS is a scripting language that has evolved into a programming language. It’s just a fact, whether you like it or not.

    Also, as @vane said, it’s a language that has helped programming become more accessible to many people, including myself.
    It’s a language I’m moving away from now as I seek more robustness in the tools and languages that I use.
  • 0
    @aviophille ah, thanks!
Add Comment