• candyman337@lemmy.world
    link
    fedilink
    arrow-up
    19
    arrow-down
    4
    ·
    edit-2
    1 year ago

    Js is what you make of it. It can be a godawful mess but it also can be really awesome. It’s a really easy language to understand, that is a good thing. But it’s also a double edged sword because that means that novices can write absolute spaghetti code in it. That’s not the fault of the language though.

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

      Being easy to understand is one of the primary goals of any programming languages.

      The problem with Javascript is that it isn’t easy to understand. Javascript is easy to write.

      That’s why it’s easy for novices to pick up and why it ends up being spaghetti code. It’s very unrestrictive and allows writing very poor code that works based on assumptions and breaks when the assumptions aren’t met.

      It made sense at the time because it was just a scripting language for some minor website things, and you didn’t want your site to crash if your script ran into a problem.

      Now it’s being used to write full fledged applications and it’s past design choices are still haunting it.

      • BeigeAgenda@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        Compiled languages at least say “hey don’t do this” and fail or warn you with “this is a bad idea”.

        But hey I still use python, but also pylint to help me avoid mistakes, I just disable the style part for my own sanity.

    • chaorace@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      1 year ago

      Js is what you make of it. It can be a godawful mess but it also can be really awesome.

      Agreed. It wasn’t always a great language, but by some miracle it eventually became pretty alright.

      But it’s also a double edged sword because that means that novices can write absolute spaghetti code in it. That’s not the fault of the language though.

      Disagree. The best languages are those which can be intuitively used without having to learn the pitfalls. Take Rust vs. C++, for example: both languages have pitfalls, but only Rust is intentionally designed to help you steer clear of them. JS is like C++ in this regard – decades of cruft have coalesced into tempting yet painful footguns, much to the chagrin of many a new learner.

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

      Js is what you make of it.

      This is one of the biggest issues with JS.

      Want to stuff your whole program into one file on a single line? Go for it! Want to use 100 JS files in a single directory? You the boss! Want to tinker with the internals of other modules? Ha! What internals?!?

      This is coming from someone that actually likes JS. It’s a very loosey-goosey language and it does next to nothing to prevent bad practices. You’re expected to pick and choose additional libraries to help with quality and organization. Some people choose no framework, some choose relaxed frameworks, or very opinionated ones. And if you want, you can easily mix strategies. I mainly code in Java, much more strict by comparison, and taking this approach would be a good way to ensure nothing works.

      I think the core of JS is good but it needs better official tooling (I still hate NPM) and less of do-what-feels-good approach.

    • Cethin@lemmy.zip
      link
      fedilink
      arrow-up
      5
      arrow-down
      2
      ·
      1 year ago

      Except nit having strict types makes it harder to read, not easier. You have to try to remember what type of data each object contains. Strict typing makes it easier to read. JS is slightly easy to write though, for better or worse, although usually harder to come back to for the same reason mentioned earlier.

    • CanadaPlus@lemmy.sdf.org
      link
      fedilink
      arrow-up
      1
      arrow-down
      5
      ·
      edit-2
      1 year ago

      Big disagree. The point of a language is to express the underlying logic in a human-friendly way.

      Edited to emphasise parsing does not mean understanding.

        • CanadaPlus@lemmy.sdf.org
          link
          fedilink
          arrow-up
          2
          ·
          1 year ago

          You said it can be used and is easy to understand (which I interpreted as parse), that’s subtly different. Awful spaghetti code that works does not show the underlying logic easily to humans, it doesn’t really matter if you can easily understand a line. It is JavaScript’s fault if it lends itself to that unnecessarily.

          I get why people were confused by what I wrote, though. I’ll go back and make an edit. Sorry!