No offence

  • dontblink@feddit.it
    link
    fedilink
    arrow-up
    40
    ·
    1 year ago

    May i ask why everyone hates JavaScript so much? It’s not ironic it’s a real question, i can’t really get it, is it just because it doesn’t have types? Or there’s more?

    • oktupol@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      55
      ·
      1 year ago

      I believe the amount of hate and mockery Javascript receives is heavily skewed, simply because almost every programmer who is active today has at least some experience with the language, and with more users there are also more people capable of complaining about it.

      I work with languages that are much worse than Javascript, yet they don’t receive nearly as much hate because hardly anyone uses them.

      One that comes into my mind is ABAP:

          • twei@feddit.de
            link
            fedilink
            English
            arrow-up
            7
            ·
            1 year ago

            As you may know SAP is a German company and the name originally was an acronym for SanduhrAnzeigeProgramm, which translates to “hourglass displaying program” - a nod to when busy software would change the mouse cursor into an hour glass - since it was initially conceived as a hardware stress test software - expanding to employee stress tests was just the logical next step.

            Things got weird when scammers found a new hustle charging hundreds of dollars per hour pretending it was an ERP solution or similarly outrageous ideas that non-technical people in all kinds of business fell for.

            (copied from reddit before it gets deleted)

      • Zucca@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        4
        ·
        1 year ago

        Oh boy…

        Imo, both methods should set the same value for x. That’s madness. 🤪 Just look at awk for example. There’s a dedicated substr() and it doesn’t care about spaces. But then awk is quite loose in everything… and niche… But I love it.

    • fiah@discuss.tchncs.de
      link
      fedilink
      arrow-up
      22
      arrow-down
      2
      ·
      1 year ago

      it has a lot of cruft and gotchas and lacks a good standard library (which is why npm is a thing). That means there’s a lot of bad javascript code out there and a lot of people who have had bad experiences with it. But, if you take care to not shoot yourself with the included footguns and you know your way around npm, it’s a perfectly fine language for its purposes in front- and backend development IMO

    • Iteria@sh.itjust.works
      link
      fedilink
      arrow-up
      21
      arrow-down
      1
      ·
      1 year ago

      Because it’s inescapable. Web development is by far the most common type of programming work and even if you’re a backend developer you tend to have to touch javascript at some point, so everyone knows the pain of javascript’s foot guns and javascript has a lot.

      The fact that it’s mandatory to do your work invokes bitterness in people. For backend, you can kind of switch around until you find a language you like. For frontend, it’s javascript or nothing at all.

      Javascript as a language is very out of sync with other commonly used languages. Its footguns are very easy to run into. As a result you have a lot of rituals around just not shooting yourself in the foot. The rituals, libraries, and frameworks around avoiding Javascript’s foot guns have been very shifting and changing. Of course, because the javascript ecosystem changes far faster than other languages, there are a lot of rakes for developers to step on to add to the naturally existing foot guns.

      Javascript as a language probably shouldn’t be the sole language of the internet for a variety of reasons. It’s a very hateable language because of how easy it is for newbies to make new terrible code and how common it is. Until something like WASM takes off, the downpour of hate for javascript will continue.

      • masterspace@lemmy.ca
        link
        fedilink
        arrow-up
        5
        arrow-down
        2
        ·
        edit-2
        1 year ago

        Javascript as a language is very out of sync with other commonly used languages.

        How so? Moving back and forth between Typescript and C# / Java is pretty natural imho, as long as you understand the compiled vs interpreted differences.

      • RagingNerdoholic@lemmy.ca
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        1 year ago

        In my experience (Javascript and PHP, which both have plenty of footguns), these pitfalls can be avoided by using good practices.

        Just because they are dynamically typed doesn’t mean you have to use dynamic typing. Don’t type switch your variables.

        Just because you don’t have to use brackets in a certain scenario doesn’t mean you can’t. Use them as needed for clarity.

        That kind of thing.

    • masterspace@lemmy.ca
      link
      fedilink
      arrow-up
      20
      arrow-down
      2
      ·
      edit-2
      1 year ago

      It’s wild that Python is getting a shoutout over javascript despite being an even bigger loosely typed mess.

      I think it’s partially because Python has a reputation as being a serious language for serious people because it’s popular amongst data scientists and academics, whereas Javascript is still seen as being popular amongst script kiddies and people building crappy websites for $100 / pop.

      That being said, most of the time i hear javascript jokes at work they’re pretty tongue in cheek /ironic / the dev isn’t really hating on it. I have heard a dev or two make those javascript jokes with a more serious critical tone, and everyone tends to ignore them and not engage because they’re pretty clearly just haters who have a general tendency to dislike popular things.

      • Faresh@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        1 year ago

        If by «loosely typed» you mean weakly typed, then that’s not true. Python is a dynamically and strongly typed language. Attempting to do an operation with incompatible types will result in a TypeError.

        >>> "3" + 9
        Traceback (most recent call last):
          File "", line 1, in 
        TypeError: can only concatenate str (not "int") to str
        

        You may be thinking of the following, but this only works because the __mul__ and __add__ methods of these objects have been written to accept the other types.

        >>> "A" * 4 + "H"
        'AAAAH'
        
        • masterspace@lemmy.ca
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          I meant that you do not declare types and a variable’s type can change at any time.

          Regardless of semantics, it results in code that is not scannable.

          • Faresh@lemmy.ml
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 year ago

            But it is in no way worse than javascript in that regard, though?

            I don’t think static typing in Python is really so essential. I see it above all as a scripting language, so its applications don’t benefit as much from static typing as other languages do.

            Maybe a better hypothetical python would have used some kind of type inference system, like in haskell, which allows for static typing while still allowing to write code unencumbered from types and stuff, but I really think, for Python’s target domain, its type system is actually adequate or good. Maybe its documentation could benefit from type hints, though.

            • masterspace@lemmy.ca
              link
              fedilink
              English
              arrow-up
              2
              ·
              1 year ago

              But it is in no way worse than javascript in that regard, though?

              No, but OPs original post was implying that it was better than JavaScript, when in my mind they’re pretty similar in that regard, with the major exception that there is no python equivalent of Typescript which is rapidly passing JavaScript in professional settings.

              I don’t think static typing in Python is really so essential. I see it above all as a scripting language, so its applications don’t benefit as much from static typing as other languages do.

              For a scripting language it’s fine, but problems arise when you start building giant applications with it (which does happen).

      • AGuyNamedMay@programming.dev
        link
        fedilink
        arrow-up
        0
        arrow-down
        6
        ·
        1 year ago
        1. What lol, python has type hints (ie gradual typing)
        2. Python is absolutly not popular at all in academics lol, most over there use haskell/ocaml/c
    • SolarMech@slrpnk.net
      link
      fedilink
      arrow-up
      14
      ·
      1 year ago

      It has a rocky start, and a lot of cruft from that era sticked around.

      There are also a lot of horrible legacy projects from the pre-ES5 era which are a pain to work with. Often older projects were coded either before people knew how to do javascript right, or before the devs who wrote it knew how to write javascript right.

    • ursakhiin@beehaw.org
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      I’m a backend engineer. My biggest issue with JavaScript is environments that use it in the backend.

      JavaScript is designed to run in a way that continue to try to do things even when it’s running in to errors. But it does that because I’m a front end that’s what you want. In the front end, working but ugly is better than not working at all. In the backend that can be catastrophic, though.

    • pazukaza@lemmy.ml
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      1 year ago

      My problem with it is that it gives people too much freedom. They can write the code in very, VERY ugly ways… And they do. It’s a language that let’s you write a mess pretty easily.

      That’s really my only complaint. The ugliness happens mainly in:

      • callback hell. For some reason some people still do callback hell in 2023.

      • functions as objects. This is pretty neat actually, one of the best things in Javascript, but some people just abuse the hell out of it.

    • monk@lemmy.unboiled.info
      link
      fedilink
      arrow-up
      7
      arrow-down
      15
      ·
      1 year ago

      Let me suggest a simple exercise for you.

      1. Print “Hello world!” to stdout in Javascript.
      2. Show me the standard that guarantees that everything you’ve used exists and works as intended.

      I’ll wait.

      • masterspace@lemmy.ca
        link
        fedilink
        arrow-up
        9
        arrow-down
        1
        ·
        1 year ago

        Show me the standard that guarantees that everything you’ve used exists and works as intended. I’ll wait.

        I think you fail to understand the very basics of web development if you’re operating on the assumption that everything you need is always reachable.

        • monk@lemmy.unboiled.info
          link
          fedilink
          arrow-up
          3
          arrow-down
          3
          ·
          1 year ago

          I think you’re misunderstanding what “everything” means (it was “everything needed for a hello world”) and trying to divert the discussion to whatever Web has devolved into, which is an abomination that’s definitely unsuited for learning the ropes of software development.

      • Feathercrown@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        In the browser you cannot access stdout, but you can use console.log to write to the dev console which is basically the same thing.

        In Node, you can use process.stdout.

        Both are available from the top-level globalThis objects that are part of each platform’s respective default library.

        • monk@lemmy.unboiled.info
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          And in GJS? All other runtimes?

          In, say, C, such basic stuff is right there, in the standard.

          Javascript isn’t even standardized, some ECMAScript is, so I don’t even know what we’re talking about.

          • Feathercrown@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            All ECMAScript is standardized because that refers to the standard.

            I think you’re discounting the different environments that JS runs in. Something like C runs in a much more uniform environment (the OS) while JS must be able to run in different runtimes. It’s like how windows has APIs that C can access, but obviously you can’t access them when running C from other OSes (forgive me if that’s inaccurate, I don’t use C often).