All Major Browsers Now Support WebAssembly

Discussion in '[H]ard|OCP Front Page News' started by Megalith, Nov 14, 2017.

  1. Megalith

    Megalith 24-bit/48kHz Staff Member

    Messages:
    11,092
    Joined:
    Aug 20, 2006
    Following the adoption by Safari and Edge, all major browsers now support WebAssembly, which delivers JavaScript code compiled as highly-optimized bytecode. Bytecode, being many times smaller than the code from which it's been compiled, can be used to save bandwidth on mobile devices and help improve page loading times for modern websites and web apps.

    Even from the day of the announcement, WebAssembly was insanely popular with the online gaming industry who could create more advanced gaming engines, similar to the ones used for desktop-based games. All these positive features and potential gains were why Mozilla engineers called the feature a "game changer for the web," and why work on WebAssembly went much smoother and faster than many could have predicted.
     
  2. jeremyshaw

    jeremyshaw [H]ardForum Junkie

    Messages:
    12,030
    Joined:
    Aug 26, 2009
    Better web mining clients is what I see.
     
  3. cyberguyz

    cyberguyz Limp Gawd

    Messages:
    143
    Joined:
    Aug 28, 2014
    Been a few years since I was working with this but here goes:

    in normal operation javascript is sent as source code to the browser which then has to compile, then interpret the resulting Java bytecode using the platform's runtime. What webassembly does is send down precompiled java object code. The fact that the browser does not have to call java to compile the javascript code is what saves time and bandwidth. I have run into situations where java bytecode from one version of java is not compatible across java versions (i.e. some java 1.6 byte code is not compatible with Java 1.7 without special jvm execution options).

    When sending source javascript to the browser this version incompatibility is not a problem because the client compiles it. However I am not sure how WebAssembly gets around this possible versioning issue. Perhaps WebAssembly has its own jvm runtime?
     
  4. Youn

    Youn [H]ardness Supreme

    Messages:
    4,731
    Joined:
    Jan 22, 2007
    Where are you reading that Java/JVM is involved at all?
     
  5. cyclone3d

    cyclone3d [H]ardForum Junkie

    Messages:
    11,802
    Joined:
    Aug 16, 2004
    Java /= javascript

    Completely different things.
     
  6. cyberguyz

    cyberguyz Limp Gawd

    Messages:
    143
    Joined:
    Aug 28, 2014
    Sorry. Brainfart. I did say it has been a few years...
    Anyhow there are similarities between both languages - each has to be compiled to bytecode. Before webassembly it is done by the client. After webassembly it is precompiled. both have to be executed by an interpreter (vm). Disregard my ruminations on versioning since it has nothing to do with the way ecma versions are handled.

    Though completely different languages, Javascript takes its internal syntax from Java (inside the script tags).
     
  7. frag.machine

    frag.machine n00bie

    Messages:
    55
    Joined:
    Jan 5, 2011
    Sorry, no. The only connection between Java and JavaScript is the name due a marketing brainfart from Netscape. They were made by different companies at different moments for different reasons.
     
    naib, Ordeith and almalino like this.
  8. velusip

    velusip Gawd

    Messages:
    1,002
    Joined:
    Jan 24, 2005
    Just to clear up some confusion: Javascript is one implementation of ECMAScript. Javascript is usually rapidly (JIT) compiled into bytecode, which runs on a Virtual machine (VM) with optimized access to native instructions on your local architecture. (Coincidentally, lots of languages operate on this same sort of principal, unfortunately one of them is named very similarly: Java.)

    I'll explain what WebAssembly is:

    * It is a bytecode language (called WASM). Yes, another one. As the news article states, now all the major browsers have agreed on the instruction set to include in their own VM. Some sort of ECMAScript implementation bytecode is now extended with WASM bytecode.
    * Each browser has an interface to access the compiled WASM bytecode and memory via exports.
    * WASM bytecode can be translated and represented in an intermediary language called WAST. It's just a more readable version of the bytecode.
    * The WASM compiler which generates bytecode blobs currently supports C/C++ and Rust as an input language, and additional translators are developed independently and are independent of the browser software.

    So, you can now write some javascript, provide it with your website, browser JIT compiles to VM bytecode, and runs.

    OR, you can now write some C, compile it to WASM bytecode, provide it with your website (along with some controlling javascript, which is JIT compiled to VM bytecode), and runs.
     
    cyberguyz and GoldenTiger like this.
  9. velusip

    velusip Gawd

    Messages:
    1,002
    Joined:
    Jan 24, 2005
    Oh, and the compiler and VM can't really handle much outside of the most basic forms of programming (basic logic, branches, io). There's a list of what's being worked on here: http://webassembly.org/docs/future-features/
     
    GoldenTiger likes this.
  10. cjcox

    cjcox Limp Gawd

    Messages:
    475
    Joined:
    Jun 7, 2004
    Now web pages can consume more of your memory in less time and be stealthier as well.... FTW!
     
  11. serious

    serious Limp Gawd

    Messages:
    212
    Joined:
    Sep 24, 2012
    Tried the tank demo and OoM .... hardware acceleration was the problem ...
     
  12. dgz

    dgz 2[H]4U

    Messages:
    3,971
    Joined:
    Feb 15, 2010
    The performance gains should be huge. Security is about to get black hard, though. This is the true Flash successor hehe
     
    Flapjack, cyberguyz and Youn like this.
  13. Flapjack

    Flapjack 2[H]4U

    Messages:
    3,111
    Joined:
    Apr 29, 2000
    I was thinking the exact same thing. As a security professional, it's hard not to see vulnerabilities as the result of new technology. :(
     
  14. dgz

    dgz 2[H]4U

    Messages:
    3,971
    Joined:
    Feb 15, 2010
    We web devs are going to need you more than ever. Securing systems is hard and we suck at it