Hacker News new | past | comments | ask | show | jobs | submit login
WebAssembly First Public Working Drafts (w3.org)
112 points by EddieRingle on Feb 15, 2018 | hide | past | favorite | 64 comments



Had a quick look through, looks interesting. Some thoughts

* Only 32-bit address space (although they do say "Future version of WebAssembly might provide memory instructions with 64 bit address ranges")

* Webassembly is pretty low level. Just 4 basic types (integers, floats). No C-style structures even. This is lower level than e.g. LLVM IR, and lower level than the Java VM.

* No garbage collection support.

I hope Webassembly can be used from not just Javascript, but something like C++, directly.


There are already quite a few of ongoing projects for compiler backends targeting WebAssembly.

https://github.com/appcypher/awesome-wasm-langs/blob/master/...

As for lacking a GC in its present version, the runtime can always bring one along, just like in most CPUs.


I would say that 32bit are more than enough for most web applications. I struggle to recall any web application that would require more than 4GB of RAM to run.


Slack?


Desktop applications are increasingly moving to the web. Regardless of whether you think this is a good thing, the standard has to take that into account.


I doubt that every single desktop application will move into the web for a good long while, long enough to have a smooth transition from 32bit to 64bit if necessary, though I doubt applications that need more will use WASM.


> I doubt that every single desktop application will move into the web for a good long while

Oh sure, personally I hope it'll never quite happen. But It'll get there and a standard needs to be forward-facing.


so once all desktop is in the browser, can we then make the browser the sole interface, and all in one stroke have desktop apps again? Ouroboros eh?


WebAssembly apps don't have to be hosted on the web, or run in a browser. They will, almost exclusively, because the "browser as OS" model is what modern web developers have fixated on, because of javascript. But, there's no reason users couldn't install and run WASM natively as well.


You can compile rust to it.


The asp.net team is already hard at work on the Blazor project a web UI framework using C#/Razor and HTML. https://github.com/aspnet/Blazor


What do you mean hard at work? Do you know if there are any MSFT employees that work on it full-time? Have you seen it on an official roadmap maybe?

I'd like to know because a real committment could signal a huge shift, although personally I'd rather use flux+react but written in c#.


A strongly typed VueJS powered by C# instead of JS/TS would be my dream SPA development environment. Hopefully this might feel similar.


It uses JavaScript for DOM?


No. I'm imagining it doesn't even have a traditional DOM. It's using it's own custom rolled framework and web assembly which makes the browser like a blank canvas. Super cool.


I really love the idea of WebAssembly but am super intimidated by it. Being a junior frontend dev it seems like a really powerful piece of tech that could go in a million directions in the future.

My big hangup is understanding a low level use case for it. I've console.logged in wasm but only knowing javascript I don't know where to go from here. Is the idea that you can utilize packages in any language then rebuild it in js?


If you are a junior frontend developer, WASM probably just doesn't mean much to you, and probably won't. You'll use it, wrapped by a JavaScript facade, to do some performance-sensitive stuff. (Some folks are rubbing their hands together about the possibility of using the DOM in another language and not writing JavaScript; this will eventually happen, but I strongly doubt mainstream frontend development will go that way in the reasonably near future.

I don't really see why you should be intimidated by it any more than a Java programmer who sees JNI barf once in a while should be intimidated by C. If you're that interested, all you really have to do is learn a normal, natively-compiled language. Which would be wise anyway--nobody serious about the field should only know one language, JavaScript or not. Then you can learn how to compile down to WASM (it's rarely difficult) and just go from there.


It's intimidating because the tooling is very immature. Compiler and debugger support is not at the level of Java or C.


> Compiler and debugger support is not at the level of Java or C.

WASM is more of a compiler target, not a language at the level of C or Java: its something you'd compile to from C.


That doesn't forbid WASM to have a nice graphical debugger, like most CPUs have.


WASM can already be debugged with the browser-integrated debuggers, source maps can map back to the original files.


> Some folks are rubbing their hands together about the possibility of using the DOM in another language and not writing JavaScript; this will eventually happen

Sadly WASM doesn't help here at all due to lack of way to interact with the GC. Not only lack of finalisers but that having two GCs doesn't work. I learnt this 2 times over the hard way.

For something today, look to fengari: https://fengari.io/ . It implements a VM in javascript, reusing the javascript garbage collector, which means that you get seamless DOM interaction.


GC interaction is not needed for DOM stuff. That was originally the case, but the "host bindings" proposal lets it shed that dependency. I pasted a link downthread.


In time. Model the WASM code as a WebWorker, use the DOM like you would in React. A semantic level shadow DOM in WASM is lightweight.

WASM is a beautiful baby universe, hatched from a messy past.


Yeah, I've been working on python and java for sometime but it still boils down to js thinking for me.

Thanks for explanation though, I'm not intimidated of it taking my job as much as I am the wide scope of the thing. Seems massive!


I dunno. It's no more massive than most other computing environments. JavaScript is an aberration in the way it's structured. This is certainly a matter of perspective; I tend to think that starting with a restrictive environment like JavaScript (and don't get me wrong, I like JavaScript and write a decent bit of it every day) makes the cage look like the world. Pedagogically speaking, I worry about JavaScript being somewhat damaging...but, whatever.

Anyway, WASM is just trying to remove the restrictions on a strict environment (that's why it's called Web Assembly, yeah?). The example that floated to mind--you've been writing Java? This[1] is written in Clojure, but there's no reason you can't get this wacky in Java. (Not that you should.)

[1] - https://aphyr.com/posts/341-hexing-the-technical-interview


From my understanding one use case is Transpiling into Web Assembly. The tooling isn't there yet, but you can hopefully use it instead of JavaScript and get some type safety and performance.

Sure you can use a language like TypeScript or one of the others that will transpile down to JavaScript giving you type safety, but you won't have the performance of web assembly. Although, I've yet to see what you'll need that performance for. A few of my co-workers are excited about it, but I've been pressing them, we don't need that level of performance on the SPA type stuff we write.

I think having web assembly will give you new avenues and use cases people haven't fully considered yet.


It's actually compiling to wasm..no more transpilling


Sorry, I wasn't clear. So instead of writing WebAssembly, you can write another language such as C# that will get compiled into wasm.


With enough luck and given time you will be able to skip JS at all! If the community will find the life force after wasting many years on SPA, then we might even see some HTML—near-free canvas/WebGL GUIs!


I am not a fan of this. Browsers by now have awesome text layout and rendering support, highlighting, screen reading, zooming. Individual images can be seen/copied/saved, user scripts and styles and browser plugins can access the loaded html content, and so on.

All this will have to be redone in canvas for no good reason and I doubt it will be nearly as good as what browsers can do already, and we will lose a lot of openness and interop.



Microsoft is already doing it with .NET, others as well.

Expect the revenge of browser plugins.


no way a .net plugin become mainstream, thankfully we left behind java-like-plugins.


Sorry to disappoint you, but everyone is on the WebAssembly race, all plugins will be back, like it or not.

https://github.com/appcypher/awesome-wasm-langs

https://github.com/mbasso/awesome-wasm

As for Microsoft, they just announced the Blazor project.

https://blogs.msdn.microsoft.com/webdev/2018/02/06/blazor-ex...

Thank browser developers for opening the pandora box.


While I agree that we may be able to rid ourselves of JS, why would we want to rid ourselves of HTML? It's become an excellent language for describing a UI.


> My big hangup is understanding a low level use case for it.

Two real world use cases for WebAssembly are image decoding and audio decoding.

WebP image decoding: https://webmproject.github.io/libwebp-demo/webp_wasm/index.h...

Opus audio decoding: https://www.scirra.com/blog/211/opus-audio-in-construct-3


Emulating entire computers: http://blog.archive.org/2018/02/13/emulation-in-the-browser-... This is powerful because it makes the emulator itself platform-independent. Any wasm-capable browser can now emulate a ton of other platforms.


Alternatively you could compile proprietary desktop applications to webasm and use nodejs as a standalone VM.


I hadn't thought about using it for decoding images, clever! I'd been dreaming of translating my favorite python package over to the web to use without having to spin up django, but from what I'm hearing that isn't really the purpose.


We're not quite ready yet, but later in the year, you should check out Rust and wasm. We explicitly are interested in catering to the "am super intimidated by it" case. Right now, it all works, but is not super nice to use; it's under really heavy development though!


Perspective is a good example: https://github.com/jpmorganchase/perspective

Move heavy number crunching into WASM.


I hope this is the future of the web.

If the DOM gets accessible from wasm, we'll finally be able to avoid using javascript entirely.

It's crazy how much time and effort are necessary to finally be able to make a piece of software work on any computer, without having to make different high level graphical API work together.

The cherry on top would be to have both the dom AND websockets.


Well, if it will support the DOM I believe it will support any web API(i.e. including websockets)


The DOM is accessible from WASM, Javascript functions can be imported and called just like regular functions.

In fact, that's also currently the only way to access other APIs like WebGL from WASM.


Is anyone else afraid that this will enable a "Tower of Babel" effect where the coming sheer profusion of languages will fragment web programming into dozens of competing, mutually-incomprehensible linguistic camps.

Javascript sucks, but at least it's the web's lingua franca.


>Is anyone else afraid that this will enable a "Tower of Babel" effect where the coming sheer profusion of languages will fragment web programming into dozens of competing, mutually-incomprehensible linguistic camps.

That's already happening - web development seems to assume that compiling to javascript from any one of a legion of languages should be standard practice.


So you still need JS to load/compile wasm or do anything useful(i.e DOM)...what a disappointment!


The alternative is that it's a bloated piece of tech that ends up the way of Flash/Applets.


I believe flash and java applets were something else than WASM.


Right, they were their own separate VMs, with a lot of duplicated functionality. WASM is just a way to get native, non memory managed languages executing efficiently in a JavaScript environment.


I.e. disabled and eventually removed? I could live with that.


Now that makes me wonder what the point of WASM is because we could have always transpiled code to JS


Transpilation to JS always sucks. JS was not designed as a compiler target. The point of WASM is exactly that: Compile any language on the web without getting into the JS limitation.


Performance. WebAssembly has no JIT stage, it gets AOT compiled straight to machine code. Plus, it gives (or will give) much lower-level access to features like threads and memory allocation.


Thanks to Spectre I don't think we'll be seeing threads anytime soon. Well, not threads with shared memory anyway which removes a lot of the point of them. Same reason JavaScript just lost SharedArrayBuffer, too easy to make a high precision timer out of it.


> Plus, it gives (or will give) much lower-level access to features like threads and memory allocation.

There's no reason JavaScript couldn't just have those features. It already has some amount of memory allocation control via ArrayBuffer & DataView.


You're describing asm.js which had significant issues as a compilation target. The generated javascript code was massive and it took several seconds just to parse it.


Related is a mozilla post on streaming wasm for big performance gains: https://hacks.mozilla.org/2018/01/making-webassembly-even-fa...


asm.js never added threads, which is a far bigger performance issue than fine-grained manual memory allocation is.


Right now, some of the biggest users are applications where JavaScript's garbage collection pauses are show-stoppers, like games and audio recording software.


Is that just the current state of affairs, or will it always be like that?


Just for now, it seems. It's tied together with the GC support: https://github.com/WebAssembly/design/issues/1079. I wouldn't expect it anytime soon though.


It is not tied together with GC support; that used to be the case, but https://github.com/WebAssembly/host-bindings/ is the way forward.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: