News for hackers. Stuff that matters.
Re:WebAssembly Interface Types: Interoperate with All the Th... by Rusky on Wednesday August 21, 2019 @02:44PM (#20760225)
You keep saying this, but WASM has some very specific technical differences from these previous VMs that make a huge difference.
Re:WebAssembly Interface Types: Interoperate with All the Th... by pjmlp on Wednesday August 21, 2019 @03:47PM (#20760919)
Please, what wonderful feature does WASM have that neither JVM nor CLR are capable of?

Or for that matter, the myriad of bytecode formats devised since UNCOL, like the IBM and UNISYS's language environments on their mainframes.

Re:WebAssembly Interface Types: Interoperate with All the Th... by yellowapple on Wednesday August 21, 2019 @06:29PM (#20762603)
WASM is much smaller and simpler than either. This makes it easier to implement, both within browsers (as evidenced by most mainstream browsers already supporting it natively, and the rest via a polyfill) and beyond (e.g. the myriad of WASM runtimes out there - both interpreted and JIT/AOT compiled - written in all sorts of languages and usable outside a web browser). Same goes for most other bytecode VMs of a similar style/vintage (Dis, Parrot, BEAM, Dalvik, etc.).

Can't speak to mainframe VMs, since I ain't familiar with them. It's reasonable to assume they were proprietary, though (that's how things typically were back in those days), so WASM has a leg up there.

Re:WebAssembly Interface Types: Interoperate with All the Th... by pjmlp on Thursday August 22, 2019 @01:07AM (#20764818)
WASM MVP is smaller and simpler.

The WASM that everyone dreams about will be the same size, if it is supposed to match in features.

Plenty of bytecode formats since have been AOT/JIT since the early 70's.

We wouldn't even be discussing WASM if Mozilla wasn't unwilling to implement PNaCL. Apparently being open source, with initial support for C, C++ and OCaml support wasn't enough.

Re:WebAssembly Interface Types: Interoperate with All the Th... by yellowapple on Thursday August 22, 2019 @02:42PM (#20771148)
> The WASM that everyone dreams about will be the same size, if it is supposed to match in features.

The WASM I dream about (can't speak for anyone else) won't be a whole lot bigger than it is now [0], and I don't think anyone expects it to match the bigger VMs in features (the sheer number of features in the bigger VMs is part of the problem!).

----

[0]: It's already pretty great, IMO, and the additions I'd like to see - namely, support for multiple memories, and the handful of extra instructions necessary to support tail call optimization [0.1] and garbage collection [0.2] - ain't expected to be that huge of an addition in terms of instruction set bloat. I'm hopeful that they won't be especially complex to implement, either.

[0.1]: https://github.com/WebAssembly/tail-call/blob/master/proposa...

[0.2]: https://github.com/WebAssembly/gc/blob/master/proposals/gc/O...

Re:WebAssembly Interface Types: Interoperate with All the Th... by thesuperbigfrog on Wednesday August 21, 2019 @03:38PM (#20760827)
Would you please share the "very specific technical differences"?

As a long-time JVM user, I am curious about WASM and how it compares to the JVM and CLR.

Re:WebAssembly Interface Types: Interoperate with All the Th... by flohofwoe on Wednesday August 21, 2019 @05:06PM (#20761846)
The simple C-style linear memory model is the most important one IMHO, since this preserves the explicit control over the entire memory layout of an application which languages like C, C++ or Rust allow. Optimizations for efficient use of CPU caches carry over into WASM. AFAIK both CLR and JVM use a much higher level model which is built around fine-grained allocations managed by a GC.
Re:WebAssembly Interface Types: Interoperate with All the Th... by pjmlp on Thursday August 22, 2019 @02:39AM (#20765295)
CLR supports C++ since version 1.0.

In fact it had two versions of it, Managed C++ released in version 1.0, replaced by C++/CLI with version 2.0.

JVM has support for C-style linear memory model on its unsafe interfaces (the non-public ones), and is being improved via Graal (which understands LLVM bitcode) and Projects Panama/Valhalla.

Re:WebAssembly Interface Types: Interoperate with All the Th... by flohofwoe on Thursday August 22, 2019 @06:19AM (#20766462)
Ah alright, thanks for the clarification. Pre-WASM emscripten actually shows that it's possible to compile C to any language or virtual machine that has simple linear arrays to use as C's heap, it's just not as efficient.
Re:WebAssembly Interface Types: Interoperate with All the Th... by k__ on Wednesday August 21, 2019 @04:38PM (#20761494)
As far as I know, WASM was thought of as a compilation target for languages like C and Rust, which are quite different from Java and C#.

That alone should make WASM quite different from the JVM, no?

Re:WebAssembly Interface Types: Interoperate with All the Th... by pjmlp on Wednesday August 21, 2019 @04:47PM (#20761625)
https://github.com/oracle/graal

The evolution from MaximeVM, which is now increasingly being integrated into OpenJDK as part of project Metropolis.

As for the CLR, it supports VB.NET, C++ and C# since day one, including a Common Language Specification and Common Type System.

Then alongside its history got COBOL, Eiffel, F#, Ruby, Python, Nermele, Clojure,....

IBM and UNISYS mainframes language environments support a mix of COBOL, C, C++, Fortran, RPG, NEWP, also with a common type system for interoperability.

While UNISYS documents are a bit hard to come by, IBM ones are available as RedBooks.

Re:WebAssembly Interface Types: Interoperate with All the Th... by Rusky on Wednesday August 21, 2019 @05:16PM (#20761927)
Again, you keep bringing these up, by they are not the same thing as WASM.

Graal does not have a standard binary interchange format for compiled C/Rust/etc.-style programs; it requires per-language support for them and works in terms of program source.

The CLR's C++ support is nothing like WebAssembly C++- you either FFI to native code, bypassing the VM, or you compile a limited subset of C++ to unverified bytecode- and the latter doesn't support newer language standards and is being phased out.

WebAssembly solves both of these problems- existing compilers for any unmodified language can target its standard binary interchange format the same way they would target a hardware architecture, and run within its sandbox. WebAssembly doesn't need to add support for them, or know anything about their source form.

Re:WebAssembly Interface Types: Interoperate with All the Th... by pjmlp on Thursday August 22, 2019 @12:59AM (#20764776)
Besides chrisseaton's answer, not only is C++/CLI already compatible with C++17, it will be part of .NET Core Windows variant, because it was yet another reason why we wouldn't migrate away from .NET Framework.

WASM in its current form is still quite limited forcing language runtimes to bring along features that other battlefield proven solutions support out of the box.

Hardly a synonym for unmodified.

Re:WebAssembly Interface Types: Interoperate with All the Th... by Rusky on Thursday August 22, 2019 @01:17PM (#20770322)
C++/CLI is already full of incompatibilities with C++17 (and C++14, and C++11), and there are plans to cut off C++/CLI support with newer standards. Existing support is mostly by accident.

Meanwhile "must distribute a runtime with the app" does not affect the language at all, and indeed applies to these other solutions as well.

Re:WebAssembly Interface Types: Interoperate with All the Th... by chrisseaton on Wednesday August 21, 2019 @05:26PM (#20762006)
> Graal does not have a standard binary interchange format for compiled C/Rust/etc.-style programs

It does - LLVM bitcode.

Re:WebAssembly Interface Types: Interoperate with All the Th... by Rusky on Wednesday August 21, 2019 @05:34PM (#20762084)
LLVM bitcode is far worse than WASM bytecode as a standard binary interchange format. It is intentionally non-portable and unstable by its designers.

Google tried using it for this purpose with PNaCl and it wasn't great. Apple makes it work by strictly controlling the target hardware they use it for, and with massive investment in the toolchain.

Re:WebAssembly Interface Types: Interoperate with All the Th... by repolfx on Thursday August 22, 2019 @05:00AM (#20766041)
That's more a criticism of C rather than LLVM. Bitcode isn't as portable or stable as JVM bytecode because real world C programs use processor specific intrinsics, make assumptions about endianness and word sizes, embed assembly etc etc. LLVM is designed to support all real C programs, which means it can't be entirely portable.

Wasm today is a toy hardly anyone uses. It can't run many real world C programs which means they'll need to be "ported" to the subset of C wasm supports. Well, if you're willing to work with that constraint you can constrain bitcode in the same way.

By the way Graals LLVM support can execute multiple bitcode versions, with seamless and fast language interop, and it virtualises execution so that e.g. a subset of x86 assembly can be cross compiled on the fly to other arch's. It's needed because so much real C doesn't target an abstract machine but real CPUs.

Re:WebAssembly Interface Types: Interoperate with All the Th... by pjmlp on Thursday August 22, 2019 @07:08AM (#20766721)
Actually LLVM Bitcode can be made portable, that is what Apple does in their store apps for watchOS.
Re:WebAssembly Interface Types: Interoperate with All the Th... by chrisseaton on Wednesday August 21, 2019 @05:36PM (#20762098)
I didn't claim it was a good binary format - I just claimed GraalVM supports it, which it does.
Re:WebAssembly Interface Types: Interoperate with All the Th... by afiori on Thursday August 22, 2019 @02:37AM (#20765282)
But it is not an application delivery format which is the whole point here.
Re:WebAssembly Interface Types: Interoperate with All the Th... by chrisseaton on Thursday August 22, 2019 @04:29AM (#20765876)
I ship LLVM to deliver applications just fine.
Re:WebAssembly Interface Types: Interoperate with All the Th... by pjmlp on Thursday August 22, 2019 @02:46AM (#20765316)
Sure it is, that is what watchOS uses.