Slashdot Mirror


How Converting A C++ Game to JavaScript Gave Us WebAssembly (ieee.org)

Slashdot reader Beeftopia shares "a detailed history of WebAssembly...from one of the developers." IEEE Spectrum reports that "Like a lot of stories about tech innovation, this one started with video games." [Mozilla's Alon Zakai] wanted to take a game he had helped write in C++ and convert it to JavaScript code that would run well on the Web. This was in 2010, and back then, converting C++ to JavaScript was unthinkable... so he started working to adapt an open-source tool that could translate C++ code into JavaScript automatically. He called his project Emscripten... we were able to formalize the permitted JavaScript patterns, to make the contract between Emscripten and the browser completely clear. We named the resulting subset of JavaScript asm.js... I would optimize the JavaScript engine in Firefox to run the resulting code even faster...

This brings us to the present... Emscripten can take code written in C++ and convert it directly into WebAssembly. And there will be ways in time to run other languages as well, including Rust, Lua, Python, Java, and C#. With WebAssembly, multimillion-line code bases can now load in a few seconds and then run at 80 percent of the speed of native programs. And both load time and execution speed are expected to improve as the browser engines that run the code are made better.

They'd started with a C++ game because "If we could make games run well on the Web, other computationally intensive applications would soon follow."

The article -- by Mozilla software engineer Luke Wagner -- remembers that the name Emscripten was a "a mash-up of 'script' from JavaScript and 'embiggen' from the TV show The Simpsons."

2 of 139 comments (clear)

  1. Re:Sounds like a dumb ass by Anonymous Coward · · Score: 2, Interesting

    This "dumb ass" basically did what Google's NaCl engineers couldn't do, and helped find an agreeable migration path for web browsers to alter their existing VMs to support other languages. Thanks to him, contrarian fogeys may finally be able to shut the fuck up about JS in a few years. And I consider that a MAJOR win for everyone's sanity.

  2. Re:Sounds like a dumb ass by Anonymous Coward · · Score: 4, Interesting

    Wow, modern /.ers really like to dump on people doing fun projects, never mind completely missing the point of the article. Did you even read TFS before making up your knee-jerk response?