News for hackers. Stuff that matters.
Re:Why WebAssembly Is Faster Than Asm.js by gcr on Wednesday March 15, 2017 @10:19PM (#13881856)
Why aren't we standardizing on something like Java bytecode or LLVM IR or CLR?

What problems with those existing technologies could wasm solve better?

Re:Why WebAssembly Is Faster Than Asm.js by iainmerrick on Wednesday March 15, 2017 @10:36PM (#13881952)
Java and the CLR are pretty similar (legal issues aside). Both are great, but neither is ideal as a general-purpose VM for arbitrary programming languages. Neither is a good target for C and C++. (The CLR has "managed C++" but I don't think that's widely used.)

What is WebAssembly going to be used for that isn't already handled well by Javascript? High-end video games is an important example. Those are almost exclusively written in C++. Lots of indie games are written in C# using Unity, but the Unity runtime library itself is C++.

So why not LLVM? The LLVM isn't actually well-defined, stable, or even platform-independent. That hasn't stopped both Google and Apple trying to use it for this kind of thing (PNaCl and Bitcode respectively). PNaCl failed to catch on, Bitcode is helped by the fact that Apple has complete control over their own platform.

Edit to add: from a game developer's point of view, a good question is why we need both this and the new "SPIR-V" thing in Vulkan...!

Re:Why WebAssembly Is Faster Than Asm.js by Nelkins on Thursday March 16, 2017 @08:09AM (#13884329)
I thought the exact purpose of the CLR was to be a general-purpose VM for arbitrary programming languages. I mean, it's even in the name: Common Language Runtime.

Also, there's this passage from the CLR docs (a.k.a. Book of the Runtime) that explicitly states its multi-language intentions[1].

[1] https://github.com/dotnet/coreclr/blob/master/Documentation/...

Re:Why WebAssembly Is Faster Than Asm.js by iainmerrick on Thursday March 16, 2017 @11:05AM (#13885566)
Huh, the meaning of the name hadn't even occurred to me! I guess I just think of it as the Common Microsoft Language Runtime. :)

It seems like alternate languages on the CLR have never really caught on, even though in principle it's more flexible than the JVM. The only ones you hear much about are C# and F#. Compare to the JVM where you have Java, Scala, Clojure, Kotlin.

And neither the CLR nor JVM seems to have caught on for low-level, performance-critical code (game engines, scientific programming, deep learning). I guess people feel the garbage collection and bounds checking add too much overhead.

So the new fashionable approach seems to be portable machine code, very close to the way real hardware behaves. If you want bounds checking and garbage collection, do it yourself.

Re:Why WebAssembly Is Faster Than Asm.js by WorldMaker on Friday March 17, 2017 @02:34PM (#13896637)
I've seen the CLR used in low-level, performance-critical code. Performant game engines in XNA were better than a lot of critics gave them credit for. (Schizoid, a game nearly no one purchased, for one immediate example of a very performant game built in the CLR that didn't get enough credit.) The failures in XNA were more market segmentation failures (XBLIG versus XBLA, alone; though Schizoid and a few others passed through into XBLA) than engineering. With the UWP the market segmentation failures are disappearing, which is good for sales, but also means that successes in the CLR are less visible too: at a glance you can't tell if a UWP app is a CLR app or not. (Plus, .NET Native further blurs the lines.)

In a different domain from games, there were some very interesting apps I've seen that were very low-level, performance-critical written for the IoT before IoT was a term space in the old Micro-CLR.

I still of the opinion that a lot of the reason people don't use CLR/JVM and other runtimes more for low-level/performance-critical code has a lot less to do with "overhead" of garbage collection/bounds checking (whether it is as bad as critics often perceive it to be is another debate), and as much to do with stubbornness and job protection ("Of course my C and Assembly skills are still needed, because the CLR will never compete with my hand unrolled loops that are nearly impossible to debug and segfault the machine sometimes, which you should pay me to fix.").

Re:Why WebAssembly Is Faster Than Asm.js by iainmerrick on Friday March 17, 2017 @10:52PM (#13899635)
I think a big part of the problem with .NET is just that it's a big confusing mess of confusingly-named components.

MS managed to take their own excellent technology and turn it into a legacy nightmare. Am I targeting C#, the CLR, the CLI, or making a PCL, or what? Which PCL profile(s)? It's way worse than Java in that respect and Java's already pretty bad (not that anyone uses J2ME much any more).

Re:Why WebAssembly Is Faster Than Asm.js by WorldMaker on Monday March 20, 2017 @11:28AM (#13914969)
Your comment doesn't seem particularly on topic, but a lot of the confusion you speak of seems to be your own. C# is a language, the CLR is the standard for a runtime (and typically the name of the classic .NET desktop runtime if not otherwise specified), CLI are command line interfaces, PCLs are now extinct and going the way of the dodo (replaced by the much more useful .NET Standards, of which .NET Standard 2.0 is probably the only one most people care about right now). Yes, there are plenty of acronyms to keep up with, but I'm not sure I would agree that .NET is any worse than Java (or really any other multi-language, multi-platform stack that has to support both the future and a good collection of backwards compatibility).
Re:Why WebAssembly Is Faster Than Asm.js by cm2187 on Thursday March 16, 2017 @12:16AM (#13882436)
But I presume that webassembly will allow a program to ship with its own managed environment. So you can have a .net program running within a CLR within webassembly.

The return of Silverlight! (which I welcome by the way)

Re:Why WebAssembly Is Faster Than Asm.js by muizelaar on Wednesday March 15, 2017 @10:35PM (#13881945)
Java bytecode and CLR are not great targets for compiling C++ to and implementing performant VMs for them is much more difficult than a WASM JIT.

The WASM FAQ has an entry about LLVM IR: https://github.com/WebAssembly/design/blob/master/FAQ.md#why...

Re:Why WebAssembly Is Faster Than Asm.js by throwawaysbdi on Thursday March 16, 2017 @01:02AM (#13882659)
Upvoted for having actual information
Re:Why WebAssembly Is Faster Than Asm.js by JoshTriplett on Wednesday March 15, 2017 @10:33PM (#13881933)
Java bytecode doesn't make a good compilation target for compiled languages; wasm specifically aims to provide a good target for such languages. LLVM IR by itself doesn't provide appropriate sandboxing for the web; wasm has security and sandboxing as a fundamental part of its design. The CLR shares many of the same problems Java has, and would also fail to provide a vendor-neutral, unencumbered solution.
Re:Why WebAssembly Is Faster Than Asm.js by darpa_escapee on Wednesday March 15, 2017 @10:22PM (#13881870)
My friend, where have you been for the last 5 years?

Web developers have been reinventing the wheel every 3-6 months and calling it innovation.

Re:Why WebAssembly Is Faster Than Asm.js by Rusky on Wednesday March 15, 2017 @10:58PM (#13882096)
A fair criticism of a lot of web tech, but not of WebAssembly, which is doing many things JVM/CLR/Flash/etc. never did.
Re:Why WebAssembly Is Faster Than Asm.js by throwawaysbdi on Thursday March 16, 2017 @12:43AM (#13882565)
And what are those exactly? JVM and CLR bytecode is totally platform agnostic and both support many languages without trouble.

Apparently they aren't cool anymore so we need to spend another few thousand man years building another system in their image

Re:Why WebAssembly Is Faster Than Asm.js by rubber_duck on Thursday March 16, 2017 @05:40AM (#13883705)
You seriously don't see the difference between WASM and CLR/JVM ? JVM/CLR are high level and need to know about things like types/object model - this lets them do GC more efficiently and fancy stuff like reflection, etc. at

WASM is assembly level just sandboxed and portable - direct memory access and basic instructions - it doesn't even have GC right now.

They are only superficially similar.

Re:Why WebAssembly Is Faster Than Asm.js by gcr on Wednesday March 22, 2017 @07:20PM (#13936001)
So here's a thought: how is this different from PNaCL and friends?
Re:Why WebAssembly Is Faster Than Asm.js by rubber_duck on Saturday March 25, 2017 @09:26AM (#13955499)
Conceptually not very different, practically PNaCL has a problem of being an ad-hoc standard based on LLVM - WASM fixes that.
Re:Why WebAssembly Is Faster Than Asm.js by dragonwriter on Wednesday March 22, 2017 @07:34PM (#13936099)
PNaCl, IIRC, doesn't expose web APIs, but requires message-passing to and from associated JS for that.
Re:Why WebAssembly Is Faster Than Asm.js by dragonwriter on Wednesday March 22, 2017 @07:30PM (#13936063)
> And what are those exactly?

Providing a lower-level platform; directly exposing open web APIs. The first may not seem like an advantage, but it means more flexibility in the higher level systems (including runtimes like JVM or CLR, if you wanted to) that can be usefully run on top of it.

Re:Why WebAssembly Is Faster Than Asm.js by Rusky on Thursday March 16, 2017 @12:48AM (#13882595)
But they don't support the primary reason for asm.js and thus wasm- C and C++.

They also, as you note in another comment, do not have the appropriate security model for web apps.

Re:Why WebAssembly Is Faster Than Asm.js by pjmlp on Thursday March 16, 2017 @05:30AM (#13883663)
I guess you never did any .NET development.

.NET 1.x introduced Managed C++.

.NET 2.0 replaced Managed C++ with C++/CLI due to feedback from C++ devs, regarding keywords and how GC types were declared. C++/CLI was submitted to ANSI C++ as standard proposal.

UWP introduced C++/CX, although it does compile to native code and interoperates with .NET Native instead.

Or Flash for that matter, which had a C++ compiler called FlasCC.

Re:Why WebAssembly Is Faster Than Asm.js by Rusky on Thursday March 16, 2017 @10:39AM (#13885353)
I am well aware of managed C++ and C++/CLI. They are not the same language as native C++, in the sense that matters for WebAssembly's target audience.

C++/CX is closer, but a) also still not the same language and b) doesn't run on the CLR, so isn't an argument for replacing wasm with IL.

Re:Why WebAssembly Is Faster Than Asm.js by wruza on Wednesday March 15, 2017 @11:13PM (#13882167)
5 years? All years, actually.
Re:Why WebAssembly Is Faster Than Asm.js by pizza on Wednesday March 15, 2017 @11:05PM (#13882132)
smaller ideas faster, zestierly
Re:Why WebAssembly Is Faster Than Asm.js by username223 on Wednesday March 15, 2017 @11:15PM (#13882183)
Amazingly, "zestier.ly" has not yet been registered.
Re:Why WebAssembly Is Faster Than Asm.js by scrame on Thursday March 16, 2017 @12:24AM (#13882480)
oooh, it's like agile, but lightweight.
Re:Why WebAssembly Is Faster Than Asm.js by throwawaysbdi on Thursday March 16, 2017 @12:50AM (#13882608)
"micro" if you will
Re:Why WebAssembly Is Faster Than Asm.js by paulddraper on Wednesday March 15, 2017 @11:24PM (#13882229)
Seems like a waste of time.

Maybe if we had a JS framework for reinventing the wheel...

Re:Why WebAssembly Is Faster Than Asm.js by Retra on Wednesday March 15, 2017 @11:38PM (#13882288)
You mean Wheel.js? It's crap. RollCircle is 1000x better, and it's got a flexable plugin layer that works with Angular, Ember, or Asm.js.
Re:Why WebAssembly Is Faster Than Asm.js by ethbro on Thursday March 16, 2017 @12:04AM (#13882401)
RollCircle is too complicated. I already learned Wheel.js two years ago, and don't want to relearn the wheel.
Re:Why WebAssembly Is Faster Than Asm.js by throwawaysbdi on Thursday March 16, 2017 @12:49AM (#13882600)
I prefer ReWheel. It's like RollCircle but they've reduced everything to a single wheel so it's easier to reason about. Some people still think you shouldn't have a single global wheel but it's definitely where things are headed.

Anyways you should take a look, it's a lot easier to pick up than RollCircle and nobody really uses Wheel.js anymore

Re:Why WebAssembly Is Faster Than Asm.js by jnordwick on Thursday March 16, 2017 @01:09AM (#13882693)
Modern developers want more variety. I've been working on something new:

npm elipse.js

It's based on circle, but I'm still working out some issues.

Re:Why WebAssembly Is Faster Than Asm.js by throwawaysbdi on Thursday March 16, 2017 @01:17AM (#13882723)
I tried to install but I'm getting an error message: "undefined" is "undefined" on line 27361 in elipse.min.js . I'll send you the stacktrace because it's bigger than the message limit here. I see that you're transpiling typescript into ES2015 then down to ES5 in Babel, cool. Could I get a source map for the original file?
Re:Why WebAssembly Is Faster Than Asm.js by paulddraper on Wednesday March 15, 2017 @10:26PM (#13881898)
We already did Java bytecode, though it wasn't good enough to get standardized.
Re:Why WebAssembly Is Faster Than Asm.js by Touche on Wednesday March 15, 2017 @10:34PM (#13881941)
Llvm ir isn't cross platform, for starters.