An unofficial, read-only Hacker News reader.

2035 came early (opens external site)

1037 points by setheron 4 days ago | fzakaria.com | 382 comments on HN

View full thread · View on Hacker News

Comment thread (7)

  1. I agree. But I am disappointed that none of the initiatives to put another language in the browser came to fruition (except WASM). Something like Ruby would have been nice.
    Replies (2)
    1. Not even WASM, because the tooling still sucks, and if you need a GC, JavaScript is still better than dealing with WASM GC, a MVP that only suits languages with the same GC semantics as JavaScript.
    2. I think WASM managed to fall between two stools - it couldn't decide whether it wanted to be a high performance runtime analogous to NaCL that allowed you to run code at native speeds, or a generic bytecode language that other languages can target (analogous to Java or .NET bytecode), while having the same access as JS.

      It mananged neither - the runtime is both slower to load, run and is significantly more complex than NaCL ever was, while suffering from lots of limitations, meanwhile WASM code exists separated from the JS runtime. It's high level features like garbage collection, aren't really usable by language runtimes.

      Imo the best thing would be, if you could compile Ruby to a generic bytecode, which has extended features to support dynamic objects. .NET kinda managed this back then, and there were things like IronRuby, which supported a decent subset of real Ruby code, but wasn't really popular afair.

      Replies (2)
      1. > the runtime is both slower to load, run and is significantly more complex than NaCL ever was, while suffering from lots of limitations, meanwhile WASM code exists separated from the JS runtime. It's high level features like garbage collection, aren't really usable by language runtimes.

        Basically everything in this sentence is false. Wasm runtimes are simpler than NaCl, which required an entire LLVM. They start faster, with lazy compilation, interpreters, parallel concurrent compilation, and dynamic tier up. It has fewer limitations than NaCl--it supports SIMD, can access all JS and browser APIs, and didn't require rearchitecting the browser. It's not separated from the JS runtime--all the browser engines use the same compilation, GC, and runtime infrastructure. The high-level features like GC that you mention not being usable from language runtimes are being used by Scala, Kotlin, and OCaml, with more coming.

        I shipped the first versions of Wasm in Chrome, and it's true startup wasn't great. Initially, we compiled all Wasm with the top tier before starting. V8 doesn't do that anymore, nor do any other runtimes. Startup is better, topline performance is better, and integration with JS is better.

        And did I mention that Wasm also runs in lots of other places?

        Replies (1)
        1. > can access all JS and browser APIs

          That's highly misleading.

          The crippling problem with WASM is that all data must be serialized prior to calling a JS library. You can't just call the API directly. It causes massive overhead and performance problems, making a data-intense "pure" WASM application very slow.

          Edit: The problem is very evident if you need to graph 1000s of points. Calling fetch (js-space API) has to translate data to something your WASM language can handle, then after parsing it in WASM there's overhead either for serializing the data into something the JS graphing library can handle, or overhead for passing raw HTML through js-space.

          Replies (1)
          1. It's true that there are plenty of APIs that require JS objects, but for anything that takes an ArrayBuffer, you can get export a Wasm memory that has a .buffer property and then slice it however you like; no copying and no serialization.
      2. I agree: I'm shipping a product built in WASM, and the performance issues and lack of direct browser API access are real limiting factors. Even I wonder if transpiling to JavaScript would be better overall than WASM.