Live data from Hacker News

An Abridged Cartoon Introduction To WebAssembly

smashingmagazine.com

11–20 of 107 posts

Re: An Abridged Cartoon Introduction To WebAssembly

#11
post #3

Since JS is already quite fast nowadays, how much faster will WASM typically be? (Yes, I know, it depends. I'm just looking for a rough estimate.)

The generalish difference between JS and native code languages like C is about 10X. This varies from around 2X to 50X depending highly on what you're doing. WASM should run at native speeds minus some special CPU instructions like vector stuff. So about as fast as highly optimized bytecode languages like Java, maybe 20% slower than optimized C.

And vector stuff (SIMD) is being planned. https://hacks.mozilla.org/2017/02/where-is-webassembly-now-a...

Edit: an even longer list of proposed features. http://webassembly.org/docs/future-features/

Re: An Abridged Cartoon Introduction To WebAssembly

#13
post #3

Since JS is already quite fast nowadays, how much faster will WASM typically be? (Yes, I know, it depends. I'm just looking for a rough estimate.)

As an anecdote: I had been running a Z80 emulator on my website (http://8bitworkshop.com) and I began to notice persistent 30-second delays on Firefox. It was difficult to track down, but I suspected the Z80 interpreter which had a gigantic switch statement. The optimizer must have been choking on it.

After refactoring each opcode handler into separate functions, it now runs with several subsecond delays on startup (as the various code paths are discovered and optimized, I suppose) and with no delays after a minute or so.

WebAssembly won't have this problem (neither does asm.js, but that's a different story...)

Re: An Abridged Cartoon Introduction To WebAssembly

#14
I'm of two minds about WASM.

There's the Alan Kay attitude that we can build entire systems on top of minimal VM's, rather than sacrificing power to bake in more facilities. But even he says that too much time has been wasted by teams reinventing the wheel (or flat tire) who didn't really have the chops to do it.

The other side of that, then, is the great potential for interop that Javascript offers. We now have a worldwide platform with a built-in presentation layer and a highly-optimized interpreter with useful, reflectable data structures out of the box. (edit i.e. it's a viable platform for metaprogramming... the endgame of which is JS-in-JS (see "prepack")).

I would love to see a future in which the browser (and "personal" computer generally) remained a locus of significant computation. In practice, I suspect that highly-intensive tasks (mostly AI stuff) will continue to be done on servers, not because we lack the processing power, but because end users will have signed away the custody of all data worth processing. If that is the case, then WASM's role will be to fill a fairly marginal gap, between what JS can do, and what has to be farmed out anyway.

So ultimately I hope that WASM offers a lifeline to the computing power that individuals still have. But given the state of JS (after huge investments), it feels like starting over again.

Re: An Abridged Cartoon Introduction To WebAssembly

#15
post #9
post #7

Earlier quoted context omitted.

Native

Does that mean Webscale? edit: /s

Webscale? I don't know, and I am really unclear as to why people are already writing about webASM, there is hardly an agreed-upon standard so far. In my professional opinion as a Computational Scientist, I believe a LISP-like graphically-enabled DSL for the Web that worked simply and easily with: Web Forms, Graph Query for endpoints, and had a sensible GUI layering would be perfect for the next 200 years of screen.

I think that the issue comes in when people call it WebASM. ASM had different aims in 1960 than in 2017. In 1960 ASM was about minimizing register overlap and utilizing max CPU efficiency reels. Now, you have no idea what hardware your Web-whatever is going to run on, so how could you possibly optimize for CPU? The only real optimization would be optimizing software-engineer/developer attention+visualization and that would only come with an incredibly elegant breakdown of what screens need for a coder to be happy long into the future.

If there were some easy way for manufacturers to add "component" definitions for hardware devices, perhaps WebASM could become something amazing. However, the name ASM is likely to throw off too many would-be devs. At any rate, it's not meant to be assembly for the web, it's meant to be skeletal scaffolding for your amazing, native apps. Why else even bother.

Re: An Abridged Cartoon Introduction To WebAssembly

#17
post #15
post #9

Earlier quoted context omitted.

Does that mean Webscale? edit: /s

Webscale? I don't know, and I am really unclear as to why people are already writing about webASM, there is hardly an agreed-upon standard so far. In my professional opinion as a Computational Scientist, I believe a LISP-like graphically-enabled DSL for the Web that worked simply and easily with: Web Forms, Graph Query for endpoints, and had a sensible GUI layering would be perfect for the next 200 years of screen. I…

I think you have a different framing of the problem most people excited about WASM have. It is not about talking directly to the hardware, just getting speed gain like you are. So this component idea seems to be coming from out of the blue and indicates to me you haven't paid webassembly much attention until now.

Getting a bytecode that works more like common real machines will be a real performance boon. It doesn't need to match perfectly, it just needs to be similar enough, minimalistic and better than what we have now. The 'simple enough' part makes translation to native machine code easy enough and the minimal makes it easy for standards adoption. As for beating what we have now, you should read the article, because right now its javascript or nothing at all, and anything even vaguely more like a real machine can be optimized better than javascript.

Also, currently Chrome and Firefox support it. Currently Edge and Safari both support it in preview versions of the browsers. I am not sure where you are coming when you say "there is hardly an agreed-upon standard so far" because the four largest browser manufacturers have agreed enough to have 4 different working products or demos. Perhaps you could expand on that to let me know what you or if your information might have been old.

Re: An Abridged Cartoon Introduction To WebAssembly

#18
post #14

I'm of two minds about WASM. There's the Alan Kay attitude that we can build entire systems on top of minimal VM's, rather than sacrificing power to bake in more facilities. But even he says that too much time has been wasted by teams reinventing the wheel (or flat tire) who didn't really have the chops to do it. The other side of that, then, is the great potential for interop that Javascript offers. We now have a wo…

Realistically, as soon as WASM is a good alternative to JS a good part of websites won't use a single line of JS.

Regardless of arguments for and against whether this is a good idea, market pressure to open floodgates to other languages will be far too high to ignore.

My prediction is that WASM will quickly evolve into a new way to containerize applications, very close to a full-fledged VM/OS. The market constantly demands more features and faster execution. The only logical conclusion is that the web browser will become an operating system.

Re: An Abridged Cartoon Introduction To WebAssembly

#19
post #3

Since JS is already quite fast nowadays, how much faster will WASM typically be? (Yes, I know, it depends. I'm just looking for a rough estimate.)

Well, possibly no faster than can currently be achieved by asm.js if the JIT likes you, but I think discussions of raw speed miss the point.

1. Parsing text based JS is much slower than parsing something like WASM.

2. Initialising data required for programs can take significant time in JS as that data is just a program that must be parsed and run.

3. Those first two points, along with better type support should help things get fast quicker, as the parser and JIT have less work to do.

4. In general JS comes with a lot of baggage that it's extremely hard to get rid of at this point, in many ways it's not really a great foundation to build other things on.

Now, WASM seems to provide a pretty good basis for building many things low level things on, but less useful for higher level languages which might want garbage collection or other facilities. I hope we'll end up with a successor or an evolution of it being the primary thing browsers interact with and JS simply being a language supported on it.

Re: An Abridged Cartoon Introduction To WebAssembly

#20
In 20 years of software development and trying different platforms, JavaScript has been the most frustrating and the most rewarding of all of them.

I find a lot of value in using JavaScript as a cross-platform shell. I personally do a lot of work on all of the major operating systems. I primarily (a light primary, like maybe 67%, not 90%) work on Windows, but most of my users are working on macOS. And we're all writing software that eventually has to run on Android. There is almost never a problem I can't solve using a JS project of some kind. That's the rewarding part. I feel like my software goes a lot further on the JS platform than it could have ever gone on any other.

But it's frustratingly slow. A lot of that is the poor quality of a lot of the libraries that are available. I'm not really keen on writing my own HTML templating system, but I'm afraid I might have to just to get the performance targets I want (I static-gen almost everything).

And I often feel like the language is not doing enough to help me. I love writing metaprogrammable systems, but the lack of easily accessible, standardized, advanced type information in JS is a big impediment to that. Sure, I can enumerate all of the methods an object has available to it, but there is no good way to enumerate the parameters those methods take, their return type, or even that they are methods, if I ever happen to get a reference to one of them sans the object from which it came

And yes, I still do object oriented programming. But the functional story in JavaScript is not any better. With map, filter, and reduce being methods on Array, coupled with JS's goofy OO semantics where methods can become detached from their objects if they aren't explicitly bound to them, things become frustratingly verbose to get basic functional patterns to feel good.

So a WASM that let me build better dev tools, in better languages, without losing that cross-platform capability, would be a godsend. Having it run in the browser also is just icing on the cake at this point.

Post reply on HN