top | item 11976509

Build Your First Thing with WebAssembly

195 points| NickLarsen | 9 years ago |cultureofdevelopment.com

56 comments

order

tdumitrescu|9 years ago

Nice investigation! A minor point about your description of wasm: "WebAssembly or wasm is a bytecode specification for writing performant, browser agnostic web components." The term "web components" already has a pretty specific meaning referring to the in-progress specs for custom html ui elements and surrounding technologies (see https://developer.mozilla.org/en-US/docs/Web/Web_Components). You probably don't want to overload that term given how close the domains already are.

NickLarsen|9 years ago

That's fair. Originally asm.js was named capsule.js but that was taken and didn't really mean what it was. We could also call it modules but there is another very related spec out there for that as well. What would you call it instead?

dreamsofdragons|9 years ago

It's already a confusing mess, and you aren't getting that genie back in the bottle. "Web Assembly Component" would probably be the best compromise.

vonklaus|9 years ago

I suspect webassembly will fail miserably. If it succeeds anywhere it will be for gaming applications. I could be totally wrong, but most web developers who build applications and sites will not be likely to embrace this given the leverage JS provides and the simplicity of use.

Again, I am not extremely against wasm, but this writeup is pretty well done and my take away was that it was non-trivial to pickup, buggy and has poor documentation. I am curious who web assembly is for and who is really excited about it. Is it gaining traction in gaming, and also what am I missing(serious)?

edit: Can advertisers bypass content blockers by compiling to wasm?

NickLarsen|9 years ago

We (at Stack Overflow) have a new documentation product coming down the pipe with an emphasis on examples and I thought it would be awesome if we could expand our stack snippets feature to languages beyond javascript. A reproducible example right there on the webpage. In researching existing solutions, nothing was satisfying, and then I had the idea to just use asm.js and write an MSIL interpreter. I spoke with some people familiar with asm.js and decided that it wasn't particularly difficult, but it had a ton of limitations from js file sizes to ways to get all of the libraries people ask about uploaded, and of course regular breaking changes in the browser. Wasm seemed like it could help with some of the issues being a formal web specification with representatives from multiple browsers.

Other than that, I can see a lot of uses for it, from small neural nets in the browser to high performance applications like photo editing, and of course gaming. It might not be for all applications, but it certainly has a spot.

aphextron|9 years ago

The idea is that we will be able to write web applications in a sane, proper language like C# or similar, and then compile to Web Assembly. I, for one, embrace this idea whole heartedly.

colordrops|9 years ago

It's not even released yet. Of course it will be buggy and poorly documented.

j1vms|9 years ago

I suspect wasm is a long-term bet on the part of web advocates (including Google and individuals like Eich) to ensure the web remains center stage in the age of mobile native apps that sit on top pretty powerful mobile hardware. As I understand, it's essentially asm.js repackaged in a more formal, standardized manner and has already gained support from all the major browser vendors.

Once integrated properly in desktop and mobile browsers (maybe two years from now), it would probably reduce most of the "useful" performance lead that native apps have over web apps. But, it's still a bet - because of course, no one really knows for sure what things will look like two years from now.

arxpoetica|9 years ago

Speaking as a front-end-heavy developer (but someone who knows quite a lot about the back end too), the ideal of WebAssembly definitely excites, but the bridge to actually engaging with the technology is too cumbersome to actually do anything with it yet.

My take is two-fold. First, the tooling needs to mature. Second, a community of more hard-core developers (i.e., those who work regularly with C, C#, C++, etc.) needs to crop up.

Without those two things, I think you're right, it will never take off. But my bet is that both of those things happen; larger companies will at some point bank on it, and throw a bunch of tooling and development resources at it. Just a guess.

thaumasiotes|9 years ago

> I am curious who web assembly is for and who is really excited about it.

In particular, I'm curious what web assembly is supposed to be offering that Java applets didn't.

Fej|9 years ago

On one hand, I want to bash WebAssembly because it takes away our ability to see what we're running on our own PCs. On the other, it helps us slowly get away from the mess that is modern JavaScript.

vertex-four|9 years ago

With Javascript build tools and minimisers, it's already usually impossible to understand what you're running.

vonklaus|9 years ago

I think "this javascript mess" is largely bourne out of an attempt to mitigate content blocking. asm.js is pretty fast and I am not sure how much improvement wasm will provide, but if given access to more of the low-level environment I am concerned advertisers will implement maliscious code and pop-ups in wasm that is non-trivially blocked.

pducks32|9 years ago

Totally agree. I really think it's important for the community that there be a easy, free, and open way to view the source code (or some readable not obfuscated version) of any site.

wofo|9 years ago

Thanks for the writeup! I had a hard time figuring out how to compile C++ to WebAssembly a couple of weeks ago and finally gave up given the lack of maturity of the implementation. I am sure this will help more people get interested in WebAssembly!

NickLarsen|9 years ago

I had the exact same problem when I first started. Someone once told me "what we can throw away to solve this problem", so I kept removing parts until I got here which I think is currently the easiest way to get started.

_pmf_|9 years ago

Hey, the intermediate language is actually a nice step up from JS.

benkuykendall|9 years ago

Huh, the AST looks pretty human readable. Anyone have tips for writing WebAssembly without using asm.js? Even a pointer to decent documentation would be great.

binji|9 years ago

See my comment above, ultimately you should be able to generate WebAssembly directly from your C compiler (and other languages too). You can write it by hand as well, but that's not the primary goal of the specification.

We should have a text format soon too, which will be nicer than the AST format to read/write by hand.

flamedoge|9 years ago

github.com/WebAssembly/sexpr-wasm-prototype

github.com/WebAssembly/spec

github.com/WebAssembly/design

shurcooL|9 years ago

This is super useful and helpful, thanks for writing it up!

gscott|9 years ago

I have a problem with making designing websites more complicated. This snobbery of finding a new complex way of doing something that should be made easier... not harder.

thomasfoster96|9 years ago

If you understand the problem - that a dynamically typed, interpreted language has performance issues that prevent it being useful in computationally intensive scenarios, but can't be replaced easily - then this solution is actually quite reasonable.

bobajeff|9 years ago

I still see a lot of misunderstanding here about what WebAssembly is. It's not really a "bytecode" like JVM's. The best simplest way to describe it is a virtual ISA for compilers to target.

So the languages that make use of it will be compiled languages like C, C++, Pascal, Fortran etc.