Live data from Hacker News

Compiling to WebAssembly: It’s Happening

hacks.mozilla.org

31–40 of 225 posts

Re: Compiling to WebAssembly: It’s Happening

#31
In the recent press tour about Swift, Apple seems to be really gung-ho about people using Swift everywhere.

Since Swift is built on LLVM and there's direct LLVM support for WebAssembly, I wonder if Apple will get behind WebAssembly so they can get Swift in the browser.

Re: Compiling to WebAssembly: It’s Happening

#32
post #3

Web assembly always makes me a little sad. It feels like we are going back to flash only it won't be bad this time, I promise, no really. I always feel like the most obvious use for it is to start writing truly hateful and abusive code. I'm sure this is because I'm getting old.

>I'm sure this is because I'm getting old.

"this" being you making wildly inaccurate statements and burying your head in the sand?

Re: Compiling to WebAssembly: It’s Happening

#33

Earlier quoted context omitted.

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…

Yes, you paid a tax. But my argument here is that the tax for writing in different languages on Win32, Unix, and Mac OS was far cheaper than the tax for writing in other languages on a Lisp machine. This is because translating low-level code to high-level code is not as straightforward as the reverse operation. For example, if I compile C to JavaScript, how do I even think about writing a function like memcpy()? You end up with a monster like asm.js where interacting with the DOM is a chore.

Yes, the web brought a renaissance in different languages. But we already had a bunch of different languages lying around when the web became important. We were already using different languages to write desktop software. I didn't even learn C until the late 1990s, but I was happily writing software before then.

WebAssembly is going to make languages other than JavaScript palatable in the browser, and I can only see that as a good thing.

Re: Compiling to WebAssembly: It’s Happening

#34
This seems like the modern trend, and I like it. I'm going to compare this to the recent developments with OpenGL and Vulkan. With OpenGL, you ship textual source code for your shaders written in GLSL, and you have to hope that the compiler on your client's machine does the right thing! With Vulkan and SPIR-V, the compiler is taken out of the equation, and you can use whatever language you want to write shaders, validate them ahead of time, and ship the validated binary blobs to the client. Incidentally, I'm looking forward to WebGL 2. I really miss being able to use texture arrays, integers, and instancing.

Re: Compiling to WebAssembly: It’s Happening

#35

Is there (or are there any plans to add) a WebAssembly -> asm.js compiler, so that I can write some code by hand in WebAssembly and still get it to run fast in old browsers? Or are there features of WebAssembly that would be impossible to add in asm.js? The reason I ask is that asm.js is really painful and cumbersome to write by hand and wasm seems substantially nicer, but I only have small bits of numerical hot loop…

I agree asm.js isn't fun to write by hand, but wasm is also primarily a compiler target. You might not necessarily find it easier to write (its text format isn't defined or even sketched out yet, so it's impossible to guess).

If you just want to compile a few small functions with hot loops, it might be easiest to write them in C, and use a new option in emscripten that makes it easy to get just the output from those functions (no libc, no runtime support, etc.), see

https://gist.github.com/kripken/910bfe8524bdaeb7df9a

and

https://gist.github.com/wycats/4845049dcf0f6571387a

Re: Compiling to WebAssembly: It’s Happening

#36
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.

If they wanted to do it right, then an HTTP requests itself should serve a compiled HTML binary based on an AST. The binary version of HTML.

Re: Compiling to WebAssembly: It’s Happening

#37
I suspect too many web applications are going use WebAssembly to obscure their code and the way they work, thus making it impossible to learn by studying their code. As someone who learned programming mostly by looking at other people's code, I'm afraid the web will change in a way that would make it a lot harder to do so.

Re: Compiling to WebAssembly: It’s Happening

#38
post #37

I suspect too many web applications are going use WebAssembly to obscure their code and the way they work, thus making it impossible to learn by studying their code. As someone who learned programming mostly by looking at other people's code, I'm afraid the web will change in a way that would make it a lot harder to do so.

Do you really read other people's minified/obfuscated js?

Re: Compiling to WebAssembly: It’s Happening

#39
post #35

Is there (or are there any plans to add) a WebAssembly -> asm.js compiler, so that I can write some code by hand in WebAssembly and still get it to run fast in old browsers? Or are there features of WebAssembly that would be impossible to add in asm.js? The reason I ask is that asm.js is really painful and cumbersome to write by hand and wasm seems substantially nicer, but I only have small bits of numerical hot loop…

I agree asm.js isn't fun to write by hand, but wasm is also primarily a compiler target. You might not necessarily find it easier to write (its text format isn't defined or even sketched out yet, so it's impossible to guess). If you just want to compile a few small functions with hot loops, it might be easiest to write them in C, and use a new option in emscripten that makes it easy to get just the output from those…

Both of the proposed syntaxes I’ve seen for wasm text format (an s-expression syntax and a C-like syntax) seem pretty nice. The sexp format in particular seems like it would be a great target for simple bits of purpose-specific code generation (for code that doesn’t need a “compiler” per se).

Re: Compiling to WebAssembly: It’s Happening

#40

Earlier quoted context omitted.

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.

If they wanted to do it right, then an HTTP requests itself should serve a compiled HTML binary based on an AST. The binary version of HTML.

[deleted]
Post reply on HN