Live data from Hacker News

Build Your First Thing with WebAssembly

cultureofdevelopment.com

21–30 of 58 posts

Re: Build Your First Thing with WebAssembly

#21
post #7

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.

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.

Re: Build Your First Thing with WebAssembly

#22

Earlier quoted context omitted.

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?

I believe "module" in classic Javascript already corresponds to a "self-contained" Javascript file.

How about a "Web Assembly Module Object"? I don't know if that is technically correct, but it does let you call them a "WAMO" file.

Re: Build Your First Thing with WebAssembly

#23

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…

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?

OpenDoc used 'part'. IIRC, all parts had a presence in the GUI, though.

This, I think is just a library or archive (in the ar/ranlib sense; https://sourceware.org/binutils/docs/binutils/ar.html#ar) of code that the browser loads over the Internet.

Java hit a jackpot calling such a thing a jar, a word that is both shorthand for "Java archive" and a noun describing a container. That suggests looking at words such as 'bottle', 'box', 'cask', 'pot' (nice word, but its connotations do not make it a winner), 'cup', 'amphora', 'pithos' (not well-known enough, and typically unmovable), 'crate' (taken by rust), or 'vase' but I can't find a nice alternative interpretation as an abbreviation ('Jug' has a 'j' that could mean JavaScript, but I think we would be looking for something with a W for 'web' or I for 'internet') or even something that sounds good ('crate' is growing on me, but already taken by rust. That shows that other terms might grow to become acceptable, too. Maybe 'jug' could be such a word?)

Re: Build Your First Thing with WebAssembly

#24
post #7

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.

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

Re: Build Your First Thing with WebAssembly

#25

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…

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?

It's interesting that the discussion in this thread centers around what to call modules, components, and packaging units. It's like saying that JVM bytecode is a way to author JARs, when it's actually the other way around: JARs are a way to package classes packaging JVM bytecode, which is a compilation target for various languages. WASM is similarly a compilation target for code; whether it's a module of code or a capsule of code or a script tag of code isn't really the point, and "source code" remains an uncountable noun (http://www.edufind.com/english-grammar/countable-and-uncount...). And that it's supposed to be browser-agnostic is cool, but surely the bigger picture is that it's source-language-agnostic.

Re: Build Your First Thing with WebAssembly

#26

Earlier quoted context omitted.

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.

I can respect that. However, my point is, are you a web developer who primarily writes code for the web at your day job. Anecdotally, I haven't seen a lot of overlap between people writing web applications and C# developers. I have seen a lot of C family devs think this is awesome, but have no plans to actually develop directly for the front-end web. edit: the first major demonstration was Unity's angry bots accordin…

I would rather have a permanent top-level tracking banner section built right into my browser as long as I don't have to write JS anymore. It's very high on my priority list.

Re: Build Your First Thing with WebAssembly

#27
post #7

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.

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.

Re: Build Your First Thing with WebAssembly

#28
post #2

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!

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.

Ultimately you should be able to use your C compiler and generate wasm files directly, rather than go through asm.js.

There is an experimental backend of LLVM that you can try, but it will require building LLVM from source currently. Emscripten has an option to do this automatically, I believe.

You can also write the AST format by hand, which IMO is much easier to do than writing asm.js by hand, just more verbose. I wouldn't advise anyone do this, as the format has been changing over time.

Finally, there is work on specifying a true "text format" that is meant to be used with view-source and directly maps to the binary format. You can see some proposals if you look at the pull requests in the design repo. When a proposal is accepted and we implement the tooling, you will be able to generate a binary directly from this format, which will be much nicer.

Re: Build Your First Thing with WebAssembly

#29

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.

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.

Re: Build Your First Thing with WebAssembly

#30

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…

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?

We've been calling them modules, but I'm not certain that's what we'll end up with.

Also, there's a reason the description is a bit fuzzy on the WebAssembly landing page. It's not just a binary format (in fact, we didn't have a binary format for a while after we started). I like to think that it's a specification of execution semantics that can be expressed in many different formats (text, binary, AST, etc.). Not sure that's the easiest way to explain it though.

Post reply on HN