Let’s reinvent java bytecode but… different

  • AggressivelyPassive@feddit.de
    link
    fedilink
    arrow-up
    76
    ·
    9 months ago

    I mean, hardly anyone complaining about Java does so because of JVM bytecode.

    I’m not sure, where the wasm hate is coming from.

    • onlinepersona@programming.devOP
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      25
      ·
      9 months ago

      No hate, just a stupid meme. WASM has the possibility of replacing JS in the browser, however it had to reinvent the JVM 🤷 As long as it gets rid of the JS dominance in browsers, I’m all for it.

      Anti Commercial AI thingy

      CC BY-NC-SA 4.0

      • reflectedodds@lemmy.world
        link
        fedilink
        arrow-up
        10
        ·
        9 months ago

        It probably won’t get rid of js’s dominance, but it’ll give people options. I already see some front end python and rust frameworks thanks to wasm. But for some reason I really don’t like the idea of writing html / css in my rust. But I don’t like the idea of html / css in my rust.

        • onlinepersona@programming.devOP
          link
          fedilink
          English
          arrow-up
          3
          arrow-down
          3
          ·
          9 months ago

          I really don’t like the idea of writing html / css in my rust

          Yeah, I’m not sure if there are very good alternatives to that. Everything I’ve seen tends to go in that direction: markup language + stylesheet language. But HTML and CSS for sure aren’t the best.

          There’s HAML and Pug, which I did enjoy writing much more than HTML.

          Anti Commercial AI thingy

          CC BY-NC-SA 4.0

          • reflectedodds@lemmy.world
            link
            fedilink
            arrow-up
            3
            ·
            9 months ago

            I like flutter’s design where you do your markup and styling as code, and then it gets rendered via opengl. So you get that native performance without having to deal with the whole browser stack.

            I don’t like how almost all software these days is just web apps masquerading as native apps, but they’re just so damn easy to write compared to anything else.

            • onlinepersona@programming.devOP
              link
              fedilink
              English
              arrow-up
              1
              arrow-down
              1
              ·
              9 months ago

              I don’t like how almost all software these days is just web apps masquerading as native apps, but they’re just so damn easy to write compared to anything else.

              Yeah, we definitely need better UI frameworks with a clean and easy approach. So far, I’ve been enjoying Slint, but that’s also because I refuse to touch HTML/CSS/JS.

              Anti Commercial AI thingy

              CC BY-NC-SA 4.0

  • testfactor@lemmy.world
    link
    fedilink
    arrow-up
    81
    arrow-down
    7
    ·
    9 months ago

    Do you really think the reason people hate Java is because it uses an intermediate bytecode? There’s plenty of reasons to hate Java, but that’s not one of them.

    .NET languages use intermediate bytecode and everyone’s fine with it.

    Any complaints about Java being an intermediate language are due to the fact that the JVM is a poorly implemented dumpster fire. It’s had more major vulnerabilities than effing Adobe Flash, and runs like molasses while chewing up more memory than effing Chrome. It’s not what they did, it’s that they did it badly.

    And WASM will absolutely never replace normal JS in the browser. It’s a completely different use case. It’s awesome and has a great niche, but it’s not really intended for normal web page management use cases.

    • masterspace@lemmy.ca
      link
      fedilink
      English
      arrow-up
      9
      ·
      9 months ago

      And WASM will absolutely never replace normal JS in the browser. It’s a completely different use case. It’s awesome and has a great niche, but it’s not really intended for normal web page management use cases.

      While I overall agree that JS / TS isn’t likely to be replaced, Microsoft’s Blazor project is interesting conceptually … Write C# webpages and have it compile down to WASM for more performance than JS could offer.

      • Cratermaker@discuss.tchncs.de
        link
        fedilink
        arrow-up
        5
        ·
        9 months ago

        Interesting, yeah. I inherited a Blazor project though and have nothing positive to say about it really. Some of it is probably implementation, but it’s a shining example of how much better it is to choose the right tool for the job, rather than reinventing the wheel. For a while I was joking about setting the whole project “ablazor” until we finally decided to go back to a React/C# ASP.NET stack. If you’re thinking of using Blazor still, though, I think two fun things to look into are “linting issues with Blazor” and “Blazor slow”. I’ve heard people praise it, but they tend to be those who consider themselves backend devs that occasionally get stuck making frontends.

      • λλλ@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        9 months ago

        What, you can write a website in C# and have It output as a website using wasm? I have never touched wasm. That might be an interesting way to try it though.

        • Heavybell@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          9 months ago

          The problem with blazor as I understand it, is that no, it does not compile your C# into WASM. Instead, it compiles into a standard .net module – with as much excising of unused code as possible – and distributes it with a CLR that is compiled to WASM. So effectively you’re running the .net VM inside the WASM VM. If you do client-side blazor, which is not even MS’s push anymore because they stand to make more money if you write server-side blazor and deploy it to Azure.

          Do look it up yourself tho. I could have a totally wrong understanding. I haven’t looked into it in some time because I’ve not been in a position to start a new frontend project from scratch. I would love to do my frontend stuff in C# though, don’t get me wrong.

    • onlinepersona@programming.devOP
      link
      fedilink
      English
      arrow-up
      6
      arrow-down
      28
      ·
      9 months ago

      Do you really think the reason people hate Java is because it uses an intermediate bytecode? There’s plenty of reasons to hate Java, but that’s not one of them.

      No, I do not. It’s a meme.

      Anti Commercial AI thingy

      CC BY-NC-SA 4.0

      • PoliticalAgitator@lemmy.world
        link
        fedilink
        arrow-up
        9
        arrow-down
        1
        ·
        9 months ago

        Which is functionally identical to the last one you posted. Are you just doing the same joke in every format you can? Fuck the internet sucks now.

  • anton@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    45
    ·
    9 months ago

    The main difference is that WASM is an agnostic bytecode without a gc while the jvm is opinionated in a java way. It has a gc, focus on dynamic dispatch and it has knowledge of concepts like exceptions, classes and visibility.

    All this leaking of abstractions means languages like java and kotlin are well suited, scala has hit problems and c couldn’t be compiled to java bytecode.

  • magic_lobster_party@kbin.run
    link
    fedilink
    arrow-up
    35
    arrow-down
    3
    ·
    9 months ago

    Java is disliked because it’s designed around flawed OOP principles developed in the 80s and 90s. The code easily turn into a mess if you adhere to these principles, because they’re flawed. If you avoid using these principles, you will still get a mess, because that’s not how Java is supposed to be used.

    • hydroptic@sopuli.xyz
      link
      fedilink
      arrow-up
      19
      arrow-down
      3
      ·
      edit-2
      9 months ago

      Java was such a fractal of stupid design choices in its early years, and a lot of it is still there. OOP except when it’s not (int vs Integer, [] arrays but also List et al), no unsigned number types, initially no way to do closures or pass methods around so everything had to be wrapped in super verbose bullshit, initially absolutely dogshit multiparadigm support and very noun-oriented, initally no generics either meaning everything’s an Object, when it did get generics they had to do type erasure for backwards compatibility, etc etc etc

      • magic_lobster_party@kbin.run
        link
        fedilink
        arrow-up
        12
        ·
        9 months ago

        Also: everything is nullable. There are no safety guarantees to ensure you’ve done the necessary null checks. And if you miss your program will crash.

        • hydroptic@sopuli.xyz
          link
          fedilink
          arrow-up
          6
          arrow-down
          1
          ·
          9 months ago

          Oh yeah how did I forget the billion dollar mistake, definitely one of the worst misfeatures of Java

          • magic_lobster_party@kbin.run
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            9 months ago

            I think having null is great in some cases where you need to represent missing value. It’s just that there’s no good way to know for sure if you need to do null checks or not. The only way around it is to do null checks everywhere, which no one wants to do because fuck that. Nowadays there’s Optional which solves some of this, but it was introduced way too late.

            If I were to redesign Java the first thing I would do is to add a nullable keyword or something.

            • hydroptic@sopuli.xyz
              link
              fedilink
              arrow-up
              3
              arrow-down
              1
              ·
              edit-2
              9 months ago

              I think having null is great in some cases where you need to represent missing value.

              Option types or sum types would probably be a much less terrible choice for this, although I guess some sort of nullable keyword counts as a sum type

        • hydroptic@sopuli.xyz
          link
          fedilink
          arrow-up
          3
          arrow-down
          1
          ·
          9 months ago

          Great article, thanks for the link! It makes good points that I hadn’t really considered; I’ve probably just been cranky about it because I’ve preferred heterogenous translations

  • DacoTaco@lemmy.world
    link
    fedilink
    arrow-up
    20
    arrow-down
    2
    ·
    9 months ago

    The problem with java is the language and how it works itself, and not the byte code idea.
    I say that as a few things do that and .net, java and wasm are the first that jump to mind.
    Hell, pure technically any programming language that is not asm does that :')

    My problem is java itself, not its byte code. Wasm as advantage, imo, is that its not stuck to a single language like java is. .net blazor can build to wasm, but you could also use c++ to compile wasm applications :)

    • onlinepersona@programming.devOP
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      22
      ·
      9 months ago

      I’m not sure why the WASM creator(s) didn’t take advantage of the existing java bytecode and JVM instead of reimplementing it. Might’ve sped up its adoption. Doesn’t matter to me though, as long as JS stops being the #1 in web development.

      This meme isn’t to be taken seriously

      Anti Commercial AI thingy

      CC BY-NC-SA 4.0

      • xigoi@lemmy.sdf.org
        link
        fedilink
        arrow-up
        9
        arrow-down
        1
        ·
        9 months ago

        Java bytecode is designed specifically for class-oriented languages like Java and works terribly with anything else.

      • RonSijm@programming.dev
        link
        fedilink
        arrow-up
        9
        arrow-down
        1
        ·
        9 months ago

        Why would they? WASM is Web-Assembly, so Assembly is a lower level language than Java.

        You can use C# WASM through Blazor, and Java WASM though JWebAssembly. WASM as core is supposed to be language agnostic. So If you want a JVM in WASM you can build it on top of it

  • Rikj000@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    20
    arrow-down
    2
    ·
    edit-2
    9 months ago

    WASM = WebAssembly,
    this has nothing to do with Java,
    but with JS (JavaScript).

    JS works with JIT (Just In Time) compilation, meaning every user that requests a web page, will request the JS and your browser will compile that JS on the fly as you request it.

    WASM on the other hand is pre-compiled once, by the developer, when he/she is making the code. So when a user requests a WASM binary, they don’t have to wait for JIT compilation, since it was already pre-compiled by the developer.

    They only have to wait for a tiny piece of JS,
    which is still JIT compiled,
    a tiny piece of JS to load in the WASM binary.

    This saves the user from waiting on JIT compilation and thus speeds up requesting web pages.

    WASM also increases security,
    since binaries are harder to reverse engineer then plain text JS.

    Due to those reasons,
    I believe WASM will be the future for Web development.

    No clue why people are hating on WASM,
    but I guess they just don’t grasp all of the above yet.

    • Sekoia@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      12
      ·
      9 months ago

      Having read a significant portion of the base WASM spec, it’s really quite a beautiful format. It’s well designed, clear, and very agnostic.

      I particularly like how sectioned it is, which allows different functions to be preloaded/parsed/whatever independently.

      It’s not perfect by any means; I personally find it has too many instructions, and the block-based control flow is… strange. But it fills a great niche as a standard low-level isolated programming layer.

    • madkarlsson@beehaw.org
      link
      fedilink
      arrow-up
      2
      ·
      9 months ago

      WASM is great and as it becomes more accessible it will likely take over more and more

      OPs meme is just a sign of someone not understanding the softer parts around development. The meme also seems to forget that we tried java in the browser for two decades and it was just… Horrible from all perspectives, in all layers

    • lil@lemy.lol
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      9 months ago

      I want webpages to be open source, not compiled. That’s why I dislike WASM

      • Rikj000@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        6
        ·
        9 months ago

        WASM projects can be open source,
        just like Android apps can be.

        However in both instances the compiled versions of it are not easily readable.

        Also you can validate binaries against a shasum to ensure no tampering has happened with them.

    • onlinepersona@programming.devOP
      link
      fedilink
      arrow-up
      4
      arrow-down
      22
      ·
      9 months ago

      Wasm code (binary code, i.e. bytecode) is intended to be run on a portable virtual stack machine (VM)

      WASM wikipedia

      Java bytecode is the instruction set of the Java virtual machine (JVM), crucial for executing programs written in the Java language and other JVM-compatible languages

      java bytecode

      Need I say more?

      • dohpaz42@lemmy.world
        link
        fedilink
        English
        arrow-up
        10
        arrow-down
        1
        ·
        9 months ago

        Please do say more because I don’t think the argument you’re trying to make is coming across clearly. Obviously your intelligence is at a level far higher than us low-iq plebs, and we need your brilliant mastery of these topics to be poetically spelled out for us. For we are not worthy otherwise.

          • dohpaz42@lemmy.world
            link
            fedilink
            English
            arrow-up
            12
            arrow-down
            1
            ·
            9 months ago

            In all seriousness, everything. You post two out-of-context quotes from two different websites, but put no actual effort into tying them together and explaining your position on either side, and expect us to read your mind and agree with you. It’s a bad faith comment that exudes arrogance.

    • XTL@sopuli.xyz
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      9 months ago

      No, Java was always a creeping horror. The VM is one of its less bad features.

      Yes it has been steadily getting worse, though.

      • marcos@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        9 months ago

        less bad

        Hum, no. The idea of a fast intermediate representation that is still high-level enough to allow for runtime optimizations and portability is GREAT. It’s not “less bad”.

        But, of course, everything else destroys the language. A language agnostic WASM is taking that one really great part, and dropping everything else.

      • taanegl@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        9 months ago

        Sun Microsystems was once the great hope of the computing world, and technically the JVM was first to normalise the use of VM’s, albeit from a containerised perspective. It was Docker before docker, in some sense.

        This coupled with Solaris and the SPARC systems that were Java-native (whatever that means) enabled this type of containerisation from a hardware level, which again: was a huge thing.

        But, Sun turned for the worse once the JVM hit browsers and server stacks. That’s when their SaaS model was envisioned, that was the precursor to the acquisition by Oracle.

        So it started nicely, but hit the enshitification velocity somewhere in the early 2000s.

  • pftbest@sh.itjust.works
    link
    fedilink
    arrow-up
    6
    arrow-down
    4
    ·
    9 months ago

    You can’t compile C to java bytecode, they are fundamentally incompatible. But you can compile C to wasm, which is what you want for a good universal bytecode. Java is shit.

      • pftbest@sh.itjust.works
        link
        fedilink
        arrow-up
        10
        arrow-down
        3
        ·
        9 months ago

        Have you seen what it outputs? The same way we can compile C to brainfuck, it doesn’t mean it’s good or is useful.

        • onlinepersona@programming.devOP
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          13
          ·
          9 months ago
          • “compiling C to java bytecode isn’t possible”
          • *link to project that does exactly that*
          • “it’s not good or useful”
          • *WASM exists*
          • “that’s useful”

          … OK

          Anti Commercial AI thingy

          CC BY-NC-SA 4.0

          • pftbest@sh.itjust.works
            link
            fedilink
            arrow-up
            3
            arrow-down
            1
            ·
            9 months ago

            I can’t quite understand what is your point? Are you arguing that both JVM and WASM are bad? With this I agree, they both have terrible performance and in an ideal world we wouldn’t use any of them.

            Are you arguing that JVM bytecode is better than WASM? That’s objectively not true. One example is a function pointer in C. To compile it to JVM bytecode you would need to convert it to the virtual call using some very roundabout way. But in WASM you have native support for function pointers, which gives much better flexibility when compiling other languages.

            • onlinepersona@programming.devOP
              link
              fedilink
              English
              arrow-up
              2
              arrow-down
              10
              ·
              9 months ago

              There is no point. It’s a stupid meme, not to be taken seriously in a “programmerhumor” community. It’s about as serious as demanding the Biden be the arbiter of good and bad programming languages, or saying JS should be used to punish convicts.

              Look at the other people saying stuff like “JAVA: Just Another Virtual Assembler” or something. They aren’t taking it seriously.

              Anti Commercial AI thingy

              CC BY-NC-SA 4.0