News for hackers. Stuff that matters.
Re:Universal Binaries Using WASM by hypfer on Tuesday February 26, 2019 @04:51AM (#19253106)
Its literally Java all over again.

Don't. Just. Don't.

Re:Universal Binaries Using WASM by lazyjones on Tuesday February 26, 2019 @06:33AM (#19253474)
Or p-code. This is my knee-jerk reaction too, can't wait till someone implements a portable browser in wasm like it's 1997. If someone actually builds a working and useful portable OS and UI layer around wasm, I might stop joking about it.
Re:Universal Binaries Using WASM by CyberDildonics on Tuesday February 26, 2019 @02:52PM (#19257734)
Most people don't have a p-code or java interpreter on their computer already, but 80% can already use webasm.

https://caniuse.com/#feat=wasm

Re:Universal Binaries Using WASM by rkangel on Tuesday February 26, 2019 @06:54AM (#19253545)
Why not? A single cross-platform compilation target seems like a great idea.

Java got caught up with some proprietary stuff thanks to Oracle, but there's a useful goal there. In the same way that the web is a useful target for cross-platform UI applications.

Re:Universal Binaries Using WASM by pjmlp on Tuesday February 26, 2019 @07:20AM (#19253663)
As if under Sun it was all flowers and such.
Re:Universal Binaries Using WASM by Hywan on Tuesday February 26, 2019 @09:55AM (#19254723)
Re:Universal Binaries Using WASM by hypfer on Tuesday February 26, 2019 @10:39AM (#19255126)
So he's basically stating that Wasm is better at doing what Java/Shockwave/Flash did. Thats most likely correct but also beside the point. The concept of "That one Layer which enables Cross-Platform applications" is just something which has failed, does fail and will fail in the future. Idc if its better at being Java since its still trying to be java.
Re:Universal Binaries Using WASM by steveklabnik on Tuesday February 26, 2019 @10:53AM (#19255257)
I’m saying that’s the case in the browser, but I’m also a big believer in wasm outside of the browser too.
Re:Universal Binaries Using WASM by guiriduro on Tuesday February 26, 2019 @05:12AM (#19253184)
The JVM, the .Net CLR: mature, stable, secure - why do we need another alpha-level VM thing that was devised to make Javascript faster that can awkwardly run slow(er than native) bytecode? How is that progress?
Re:Universal Binaries Using WASM by johncolanduoni on Tuesday February 26, 2019 @06:12AM (#19253396)
Because it’s not “devised to make JavaScript faster”. WASM is first and foremost designed as a compilation target for languages that work with a simple linear memory and don’t use a garbage collector, like C/C++/Rust (extensions to interact directly with the JavaScript GC are in progress, but quite a ways off). The progress it enables is the ability to run performance sensitive code written in these languages in a software-sandboxed environment at anywhere near native speed, as opposed to multiple times slower.

Also neither the JVM nor the CLR even seriously attempt to offer the security when executing untrusted code that WASM does. WASM has been deployed for over a year in all the major browsers, making vulnerabilities in its implementations very valuable. Yet we haven’t seen some huge explosion of CVEs due to its addition, unlike the early history of the JVM and CLR’s attempts to implement robust software sandboxes (before they both threw up their hands and stopped trying to market their sandboxing features as suitable for running untrusted code).

Re:Universal Binaries Using WASM by lazyjones on Tuesday February 26, 2019 @06:39AM (#19253490)
> unlike the early history of the JVM and CLR’s attempts to implement robust software sandboxes (before they both threw up their hands and stopped trying to market their sandboxing features as suitable for running untrusted code).

Is this a fair comparison? JVM and CLR allow general purpose programming and syscalls across several platforms. What can you do with WASM today? Only whatever is allowed by browsers.

Re:Universal Binaries Using WASM by krapp on Tuesday February 26, 2019 @06:48AM (#19253512)
WASM was designed with the intent that it run in the web as well as natively[0].

It just happens that the technology is still in its infancy and, because initial support was deployed in browsers, the web is currently the primary focus of developer interest.

And, unfortunately (to me) the most likely means of "native" deployment for WASM applications is going to be in Electron, but that's due to a limitation of the initiative of developer culture, not WASM itself.

[0]https://webassembly.org/docs/non-web/

Re:Universal Binaries Using WASM by lazyjones on Tuesday February 26, 2019 @06:51AM (#19253527)
IOW, JVM/CLR wanted primarily to support locally run, trusted application code and gave up on browser sandboxing. WASM is primarily run on browsers and hasn't attempted yet to support full applications. Apples vs. oranges.
Re:Universal Binaries Using WASM by krapp on Tuesday February 26, 2019 @07:14AM (#19253629)
I don't think it's apples and oranges, I think it's approaching the same destination from different starting points.
Re:Universal Binaries Using WASM by johncolanduoni on Tuesday February 26, 2019 @09:46PM (#19260435)
I wasn’t claiming that they don’t have distinct feature sets; WASM for example can’t currently do any kind of shared memory concurrency, let alone provide a GC with shared memory concurrency. The claim that it’s just a recapitulation of the JVM however is equally innacurate. Nobody would seriously consider running multiple mutually-untrusted JVM programs in the same process, but WASM is offered in that manner in every major browser.

That said, nothing stops a WASM embedder from offering system calls, and you can already use whatever system resources you want via Node as easily as you can use the DOM in a browser.

Re:Universal Binaries Using WASM by FridgeSeal on Tuesday February 26, 2019 @06:55AM (#19253551)
Because it’s not another shitty language runtime like JVM or CLR, it’s a machine-code level target.

You can take your Java/Rust/.Net/Haskell/etc/etc apps and compile them down to WASM, much like you would if you were using LLVM to compile down to assembly.

Re:Universal Binaries Using WASM by pjmlp on Tuesday February 26, 2019 @07:20AM (#19253658)
I bet the existing AOT compilers for Java and .NET are able to produce much better optimized code than any available WASM implementations.
Re:Universal Binaries Using WASM by FridgeSeal on Tuesday February 26, 2019 @07:53AM (#19253827)
And LLVM can do better than those in turn, would I prefer if we were using LLVM as the underlying target for machine code? Hell yeah I would, but we’re not quite there yet, and if it’s a toss up between the JS powered 3MB+ websites and endless shitty electron apps or WASM, I’m going to elect for WASM.

At least with WASM if it takes off, it can at least path the way for a more better and more appropriate (LLVM, AoT CLR, etc) universal machine code later down the line. That’ll never happen if we’re chained to JS though.

Re:Universal Binaries Using WASM by pjmlp on Tuesday February 26, 2019 @08:33AM (#19254124)
I rather have the AOT compile times from Java and CLR based toolchains.

As for LLVM as the underlying target for machine code, it is already a thing, nothing new here.

https://www.imsystech.com/high-level-languages/

https://www.infoq.com/articles/ios-9-bitcode

Re:Universal Binaries Using WASM by jashmatthews on Tuesday February 26, 2019 @09:49AM (#19254678)
LLVM _is_ the backend for Mono. It's easier for LLVM to produce better code if it doesn't have to go via a register based bytecode VM like WebAssembly. Was discussed here not so long ago: http://troubles.md/posts/wasm-is-not-a-stack-machine/
Re:Universal Binaries Using WASM by Volt on Tuesday February 26, 2019 @02:15PM (#19257393)
>and if it’s a toss up between the JS powered 3MB+ websites and endless shitty electron apps or WASM, I’m going to elect for WASM.

I don't know why you think the situation would improve with WASM.

Re:Universal Binaries Using WASM by int_19h on Tuesday February 26, 2019 @07:15PM (#19259723)
It's literally not. You can't compile C into efficient JVM bytecode, but you can with WASM.
Re:Universal Binaries Using WASM by pjmlp on Wednesday February 27, 2019 @02:10PM (#19266002)
Graal project has other point of view.

https://github.com/oracle/graal/tree/master/sulong

Re:Universal Binaries Using WASM by int_19h on Wednesday February 27, 2019 @02:56PM (#19266404)
Does it target pure JVM bytecode and runtime? This talks about GraalVM and how it's "optimized for many different languages", and they make the same claim on their page, specifically citing LLVM.
Re:Universal Binaries Using WASM by pjmlp on Wednesday February 27, 2019 @03:35PM (#19266691)
GraalVM is based on Graal, Java's future C2 JIT compiler implemented in Java, and already part of OpenJDK 11.

Sulong makes use of Graal and Truffle to create a LLVM AST interpreter (with native code JIT via Graal, thus allowing seamless integration between C and Java code on the same JVM.

Re:Universal Binaries Using WASM by int_19h on Wednesday February 27, 2019 @11:25PM (#19268938)
When you say "reuses the JIT", does it reuse the JIT API that gets JVM bytecode as input, and native code as output? Or is it a lower layer, that JVM bytecode is implemented on top of, and that is not constrained by the Java object and memory model? Like, if it can do unbounded pointer arithmetic without emulating it with arrays (which is slow and inefficient), surely the JIT needs to have the corresponding low-level opcodes for that, like e.g. CLR does?
Re:Universal Binaries Using WASM by pjmlp on Thursday February 28, 2019 @02:35AM (#19269673)
Graal only knows about JVM bytecodes, and there isn't any emulation of pointer arithmetic.

You need first to understand the role of Truffle in this.

It is a framework to generate AST interpreters, that plugs into Graal.

So an interpreter for LLVM gets written in Truffle, which while running a specific LLVM application, generates an interpreter for that specific code, so after awhile the JIT comes into the picture optimizing the generated interpreter that is processing that LLVM code.

This goes a few rounds until it becomes almost indistinguishable from generating the code straight from LLVM.

It is the same principle behind using PyPY and RPython to add new languages into PyPy.

JRuby is one of the projects making use of this infrastructure to run C extensions.

Naturally due to the slow startup until everything is finally converted into native code, this approach is only usable for long lived server based applications.

You can get more information about it in some of these links, mostly outdated though.

https://llvm.org/devmtg/2016-01/slides/Sulong.pdf

"Using LLVM and Sulong for Language C Extensions - LLVM Cauldron 2016"

https://www.youtube.com/watch?v=bJzMfYX6n9A

"Project Sulong: an LLVM bitcode interpreter on the Graal VM"

https://www.youtube.com/watch?v=yyDD_KRdQQU

Re:Universal Binaries Using WASM by int_19h on Thursday February 28, 2019 @02:49PM (#19274443)
Regardless of how it gets there in the end - from an interpreter or otherwise - if it produces pure JVM bytecode, that means that the memory model is also JVM. How does that accommodate the C memory model? Emulating heap with giant arrays?
Re:Universal Binaries Using WASM by pjmlp on Thursday February 28, 2019 @05:27PM (#19275919)
Most likely yes, which doesn't matter, because Graal will eventually optimize bounds check away anyway, as it does for regular Java code.

The links that I provided go into detail about all of this.