• Feathercrown@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    3 months ago

    I won’t argue that the web is complicated, but a lot of that complexity comes from the necessity of supporting so many different environments that you can’t control.

    I’d also like to ask when the last time you used JS was-- we use one UI framework (Angular) but no lodash, jquery, etc. to provide library functionality. Everything’s just built into JS now.

    • Mia@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      edit-2
      3 months ago

      I can understand accounting for different environments. That’s unfortunately unavoidable. But I found web framework developers in particular have a weird tendency of piling up ungodly amounts of abstractions just for the sake of it.

      It’s kind of a cultural problem in modern software development in general imo. It’s not limited to web dev by any means, but it’s particularly bad there because JS lends itself to it quite well.

    • Mia@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      3 months ago

      I had to go back to working with React just recently. I’m technically using TS, but the standard library is the same anyways. It hardly has everything imo.
      It does have what it needs to interface with the browser, and quite a few -sometimes poorly thought out- facilities, but not much more.

      Don’t get me wrong, for a web scripting language it’s plenty, but if one wants to use JS for stuff that isn’t just putting a simple page on a screen, that’s not enough.

      Maybe you mean Node instead of JS?

        • Mia@lemmy.blahaj.zone
          link
          fedilink
          arrow-up
          2
          arrow-down
          3
          ·
          3 months ago

          Anything that isn’t plain web browser stuff.

          You can’t write files without Node specific APIs.
          You can’t even do proper bitwise operations because everything’s a float.
          Binary serialization is a pain and proper deserialization in general is not enforced, even in TypeScript, because types are an illusion.
          Up until recently there were no synchronization primitives, though now the idea of having them in JS seems terrifying.
          There are no other data structures than arrays and maps, which are often not enough.

          It’s just not a language I’d use for anything more than… well… Scripting. But even though other, better solutions exist for cross platform development, people insist on using JS, so here we are.

          • Feathercrown@lemmy.world
            link
            fedilink
            English
            arrow-up
            8
            arrow-down
            1
            ·
            3 months ago

            You can’t write files without Node specific APIs.

            You seem to be confused about what JS is. It’s a high-level interpreted language. It’s not C. Of course it can’t open files. Can you imagine if any webpage could open files on your PC? This is like asking why Rust doesn’t have a certain Blender shader node or Scratch block. The language fundamentally doesn’t include those concepts directly. As an interpreted language, of course JS is going to access OS APIs through its host program. If the concern is that the APIs aren’t standardized-- well, yeah, that’s true. Although the basic stuff (file I/O) is included in runtimes directly.

            You can’t even do proper bitwise operations because everything’s a float.

            Is there something I’m missing here? Why would you expect to be able to do bitwise operations on floats and get a sensible value? And if you want to do integer bitwise operations… you still can? Just use integer values and the bitwise operators? If you’re complaining that you can’t be sure if a number is an integer, that’s 1. a separate issue, bitwise operations still work fine, and 2. easily solved.

            Binary serialization is a pain and proper deserialization in general is not enforced, even in TypeScript, because types are an illusion.

            Have you looked at the bit arrays JS has now?

            Up until recently there were no synchronization primitives, though now the idea of having them in JS seems terrifying.

            Do you require multithreading for a language to be considered “good enough”? Why complain now that JS does have these abilities?

            There are no other data structures than arrays and maps, which are often not enough.

            This is patently false. JS has sets, maps (actual ones, not objects like you were referring to), etc. We’re soon getting records and tuples. If you want to build a linked list in JS, you do it the exact same way as you would in any other language. Not that it would be very useful.

            • Mia@lemmy.blahaj.zone
              link
              fedilink
              arrow-up
              2
              arrow-down
              1
              ·
              edit-2
              3 months ago

              Is there something I’m missing here? Why would you expect to be able to do bitwise operations on floats and get a sensible value? And if you want to do integer bitwise operations… you still can? Just use integer values and the bitwise operators?

              No that’s my point. You can’t, because there’s no such thing as an integer value. It’s all floats, always. They get casted to integers, the binary operation is done, then they get converted back to floats. That’s a lossy process, so some binary operations with certain values are simply not possible and you get weird results. The max width of an integer you can store is 53 bits, the maximum addressable width is 32 bits for binary operations. That’s wonky.

              This is patently false. JS has sets, maps, etc…

              Ah yes I forgot sets. But I don’t think there’s anything else? Last time I checked there were no binary trees, no proper (ring buffer) queues, no ordered sets, but I may be wrong on that. It’s not enough imo for a proper standard library.

              For everything else:

              My point is that JS is an okay scripting language for the web. As I said, for that it’s perfectly fine, though the frameworks are often lacking imo. But there is this tendency to use it to create backends, desktop applications and tooling. That’s where the language falls apart, because it’s not made for that. It needs to be more robust, well defined and fully featured to be used in those contexts, both in terms of JS itself, and its standard library. Same with TS.

              You seem to be confused about what JS is. It’s a high-level interpreted language. It’s not C.

              I know and that’s the point. It’s underspecified for things outside the web, so it’s terrible for those use-cases. You can make it work for Node, but not for Bun or any other runtime. And even then, the experience is acceptable at best.

              I personally would never use it for such use-cases, but people keep touting it and TS as these amazing general purpose languages you can do anything in. You can, but you really shouldn’t.

              • Feathercrown@lemmy.world
                link
                fedilink
                English
                arrow-up
                4
                ·
                3 months ago

                You can’t, because there’s no such thing as an integer value. It’s all floats, always.

                But you can. Any number that precisely represents a 32-bit integer can be used with binary operations as if it was one, and there will be no loss of information or unexpected results. Is it weird that JS has no integer type, or that its max safe integer representation caps out at 2^53? Yes, but that’s not the complaint you made. Binary operations work literally perfectly as expected for any inputs that have the appropriate type. Actual float values are truncated, which fits the language design.

                Ah yes I forgot sets. But I don’t think there’s anything else? Last time I checked there were no binary trees, no proper queues, no ordered sets, but I may be wrong on that. It’s not enough imo for a proper standard library.

                I’m sure you’re aware of push, pop, shift, and unshift, which together can make a FIFO or FILO structure, or a more complicated one, from an array. If you’re using TS you could create a semantic type that only allows a subset of these operations. I will concede that we have no tree type, although I’m not sure if that’s standard in other languages? I haven’t needed to use one myself.

                Anyways, I won’t fight you on JS being overused. I will say that it’s flexible enough that it can be used in any way, even if it’s not the greatest idea. Something like embedded programming or safety-related things shouldn’t use JS. And as you keep mentioning, it wasn’t made for low-level stuff, although it can do it. I don’t think that’s a requirement for a stdlib though.