Live data from Hacker News

Compiling to WebAssembly: It’s Happening

hacks.mozilla.org

21–30 of 225 posts

Re: Compiling to WebAssembly: It’s Happening

#21
post #18

Earlier quoted context omitted.

Yes, that's correct.

What about opengl and hardware inputs for instance? What kind of standard libraries will be available ?

WebAssembly will (with a few small exceptions) use existing web APIs.

Re: Compiling to WebAssembly: It’s Happening

#23
post #6

Earlier quoted context omitted.

The important use case is to allow people to write web applications with their language of choice, instead of horrible javascript. And get near full performance.

I think this is important. Probably because I have the "worse is better" article from 1991 open in another tab, and if you s/Lisp/Javascript/g then many of the criticisms ring true. Some of what made Unix, Windows, and Mac OS healthy environments for development was the fact that all developers were equally well off, you didn't have to pay a tax for writing something in a language other than Lisp. You could keep your…

Hmm? You paid a huge tax in desktop development for writing in a language other than the one the OS was written in. All of the platform documentation & examples were in its "native" language. You usually had to marshall data structures yourself to fit the data formats of the native language. You had to write shims (oftentimes in assembly!) that would bridge the calling conventions of your preferred language to those that the frameworks were written in.

There's a reason that C became the dominant language during the 80s and early 90s: it's because Win32, UNIX, and MacOS >=7 were all written in it. That's a large part of what Worse is Better was about. Richard Gabriel founded a company to write software for Lisp Machines, pivoted it to run Lisp on commodity hardware, found that all of his customers would rather just write in C, pivoted it again to do a C++ dev environment, and eventually went out of business.

The renaissance for other languages was really during the web era, when everything just spit out HTML and it didn't matter what the server was written in. Once customers started demanding rich interactivity on the client, there was a strong incentive to write everything in Javascript, and then a strong incentive to write the servers in Javascript too, and then a strong incentive to use Javascript for other things like native apps and IoT devices too.

Re: Compiling to WebAssembly: It’s Happening

#24
post #22

Does code written in WebAssembly have access to the DOM somehow? How will that work?

In the current proposal there is no way for WebAssembly to directly access the DOM (or any other "Web API" objects).

Basically you will need to drop back down into javascript and handle that there (basically how asm.js does it now).

But there is a proposal to eventually integrate direct DOM access into Web Assembly, but that's for after they get it up and running.

Re: Compiling to WebAssembly: It’s Happening

#26
post #15

WebAssembly lets people write in C++, Ruby, Python, etc and for that code to work in the browser like Javascript does at the moment. Am I correct?

Yes, but it is a very limited subset of the whole "web ecosystem".

In its first version, it will not be able to access any/most web APIs directly (so you won't be writing a web app in 100% C++ any time soon).

The goal is to allow "Computationally intensive" bits of code to be compiled, while leaving JS to act as the glue for it all.

Re: Compiling to WebAssembly: It’s Happening

#27
So does it just do what NaCL was already doing, or at least is the objective the same?

I'm more worried about more specific things like hardware access (GPU, mouse inputs, networking, windowing)

It seems wasm runs at native speeds and take full advantage of optimization, but can it really be a solution fits all? There must be some things wasm can't do. And so far, since JS did almost everything, I don't see the point of wasm if it can't do what other language can.

Re: Compiling to WebAssembly: It’s Happening

#29
post #15

WebAssembly lets people write in C++, Ruby, Python, etc and for that code to work in the browser like Javascript does at the moment. Am I correct?

Mostly. The initial target is C++ and similar languages, and it will not have DOM access, but using suitable libraries (libc, SDL, etc., for example emscripten's) you can write a normal C++ program and have it run in the browser.

You can also run Ruby and Python in the browser by just compiling their C or C++ VMs. But that won't still work "like JavaScript" - their objects won't be native VM objects in the browser, it won't use the browser's GC, they won't be observable in the browser's debugger, etc.

So far all of that was already possible, and done, with asm.js.

In the future, it is a goal to work to do GC object integration, so that something like Ruby or Python could actually compile down to something with native VM objects, and that would also allow calling DOM APIs directly. (This will likely still require a compiled VM, though.)

Re: Compiling to WebAssembly: It’s Happening

#30
post #27

So does it just do what NaCL was already doing, or at least is the objective the same? I'm more worried about more specific things like hardware access (GPU, mouse inputs, networking, windowing) It seems wasm runs at native speeds and take full advantage of optimization, but can it really be a solution fits all? There must be some things wasm can't do. And so far, since JS did almost everything, I don't see the point…

The main difference is that NaCl used a plugin API (PPAPI). WebAssembly, like asm.js, can access JavaScript, and so it has indirect access to DOM APIs, with no new powers over the existing web.

The main point of wasm, from my perspective, is startup speed. wasm will allow much smaller downloads of large codebases, and much faster parsing (due to the binary format). For small programs this might not matter, but for big ones, it's a huge deal.

Post reply on HN