News for hackers. Stuff that matters.
Re:Making WebAssembly better for Rust and for all languages by harpocrates on Wednesday March 14, 2018 @12:54PM (#16586179)
One thing that continues to amaze me is that WebAssembly isn't being discussed more outside of the context of the web. Think about it just as a format that (a) is low-level enough to support performance tricks, (b) is fast to turn into native code, and (c) easy to check.

Compilers could stop worrying about obscure/old architectures. Deploying an application onto multiple platforms is no longer a problem. Sandboxing is much simpler. Formal verification becomes possible (the WebAssembly spec actually reads like a spec, unlike the C standard which reads more like a religious text).

I'm so excited about WebAssembly, but really not because of the web.

Re:Making WebAssembly better for Rust and for all languages by kllrnohj on Wednesday March 14, 2018 @03:55PM (#16587742)
> Compilers could stop worrying about obscure/old architectures.

No they wouldn't. They still need to turn WebAsm/IR into assembly, which is the thing they already do today anyway. Nothing changes for compilers, other than the potential for optimizations gets much, much worse as the IR is comparatively crippled and restricted to the IR they already have.

> Deploying an application onto multiple platforms is no longer a problem.

This has never been the result of CPU instructions. That's a library problem, not an IR problem. WebAsm does nothing to help with this, particularly as it intentionally has no real standard library to speak of.

Or put another way every compiled program is already on a perfectly portable IR called x86_64. Runs on just about every desktop, laptop, and nearly every server in the world. Yet good luck writing a portable "hello world" in it.

It marginally reduces your release artifacts as you only produce a single webasm set instead of x86, x86_64, arm7, and armv8, but using webasm instead comes at non-trivial costs, too. Instead of compiling once on a known toolchain you're now compiling millions of times on uncontrolled, unknown toolchains. That's not a great trade-off in many, if not most, circumstances.

> Sandboxing is much simpler.

Sandboxing is already a solved problem using process isolation, which has the nice property of not caring how your process runs at all. What benefit does WebAsm add to this?

> Formal verification becomes possible (the WebAssembly spec actually reads like a spec, unlike the C standard which reads more like a religious text).

WebAsm is an intermediate, not a source. Formally verifying it is about as useful as formally verifying assembly. Which is to say, not useful at all. That doesn't help you verify anything about your code, which was a compiler, optimizer, and god knows what else away from the webasm that was generated.

It's good that the spec is actually a spec, but this isn't a unique trait to webasm and it won't help your code any since your code isn't in webasm. It's still in C/C++, Rust, or whatever else and they all remain just as verifiable (or not) as they always were.

Re:Making WebAssembly better for Rust and for all languages by pcwalton on Wednesday March 14, 2018 @06:42PM (#16589007)
> Or put another way every compiled program is already on a perfectly portable IR called x86_64. Runs on just about every desktop, laptop, and nearly every server in the world.

But not mobile.

(Besides, I'm also somewhat uneasy with accepting that the computing lingua franca will forever be proprietary to Intel, covered by innumerable patents, and backwards compatible to 1978.)

> Sandboxing is already a solved problem using process isolation

If only it were. Process isolation does not protect against kernel attacks or attacks against whatever IPC mechanism you use to call out to the privileged broker process.

> Formally verifying it is about as useful as formally verifying assembly. Which is to say, not useful at all.

You can verify memory safety of the compiled code, which is a useful and important property.

(I think nobody seriously doubts that Web Assembly is memory safe assuming a bounds checked heap, though, so it's not that practically interesting of a result. Maybe it'll be more so when GC support lands.)

Re:Making WebAssembly better for Rust and for all languages by kllrnohj on Wednesday March 14, 2018 @07:13PM (#16589217)
> (Besides, I'm also somewhat uneasy with accepting that the computing lingua franca will forever be proprietary to Intel, covered by innumerable patents, and backwards compatible to 1978.)

Well, x86_64 is actually AMD's creation not Intel's. But replace x86_64 with ARM on mobile and it's the same thing - a portable IR/instruction set does not result in a portable application.

> Process isolation does not protect against kernel attacks or attacks against whatever IPC mechanism you use to call out to the privileged broker process.

Neither does webasm, other than by just not having any features currently. But that's obviously not a viable long-term strategy, certainly not for anything standalone-ish.

> You can verify memory safety of the compiled code, which is a useful and important property.

My native code is perfectly memory safe as well, enforced in hardware even. Has been that way for decades.

Of course that's not what anyone actually means by a "memory safe" language, but as soon as you go plop malloc/free on top of a single webasm allocation you're back to all the same memory-unsafeness of C despite the "memory safe" claims of webasm anyway. A memory safe IR is meaningless outside of the context of being embedded in another process. Aka, when used in a web browser. Or I guess as a massively overcomplicated replacement for Lua.

But the point is verifying the resulting webasm doesn't mean your code was correct, it means your code plus current toolchain selection happened to result in verified code. Whether or not that was the result of a fluke or well defined behavior is not something webasm has any impact on.

Re:Making WebAssembly better for Rust and for all languages by pcwalton on Wednesday March 14, 2018 @08:20PM (#16589548)
> Of course that's not what anyone actually means by a "memory safe" language, but as soon as you go plop malloc/free on top of a single webasm allocation you're back to all the same memory-unsafeness of C despite the "memory safe" claims of webasm anyway.

That's not true. Web Assembly semantics don't allow interpreting data as code or explicitly messing with the machine stack. This guarantees control flow integrity, preventing problems like ROP or traditional buffer overflows.

Re:Making WebAssembly better for Rust and for all languages by andromeduck on Wednesday March 14, 2018 @10:04PM (#16590008)
While webasm isn't vulnurable to traditional ROP attacks, it will also lose at least as much performance penalty as IR + g-free/indirect return.

Memory protection in terms of r/w/x been solved for at least about 3 decades now. It would be absolutely trivial to enforce via binary/IR distribution.

At the end of the day webasm is just a shitty IR that only exists because it's the path of least resistance on the web. There's really no point in going from lang-> llvm -> webasm -> llvm -> exec when you can just go from lang -> llvm -> asm.

Re:Making WebAssembly better for Rust and for all languages by pcwalton on Thursday March 15, 2018 @12:10AM (#16590355)
RWX doesn't prevent ROP!
Re:Making WebAssembly better for Rust and for all languages by andromeduck on Thursday March 15, 2018 @02:25PM (#16595316)
Sure but I brought up rwx for their data execution point and g-free/indirect return for ROP mitigation.
Re:Making WebAssembly better for Rust and for all languages by comex on Thursday March 15, 2018 @01:03AM (#16590514)
However, it only partially addresses JOP (jump-oriented programming, i.e. hijacking calls to function pointers and virtual methods). And there are CFI designs that provide equivalent or better guarantees for native code, such as Clang CFI + SafeStack. In fact, I expect Clang CFI to be more widely adopted in the future… However, the main obstacle to increased adoption has always been overhead, yet WebAssembly has significantly higher overhead.

edit: not to mention that WebAssembly is currently missing security mitigations that long have been standard in native code, such as ASLR, and… maybe stack overflow protection? (It looks like emscripten handles the latter manually by checking STACKTOP against STACK_MAX, but I'm not sure LLVM's native WebAssembly target does.) Maybe these will be addressed in the future, but for now there are some interesting exploitation opportunities.

Re:Making WebAssembly better for Rust and for all languages by pcwalton on Friday March 16, 2018 @12:32AM (#16598645)
> However, the main obstacle to increased adoption has always been overhead, yet WebAssembly has significantly higher overhead.

But you get a lot more than security for your trouble using Web Assembly. So the performance-vs.-security tradeoff isn't the only part of the calculus here.

> And there are CFI designs that provide equivalent or better guarantees for native code, such as Clang CFI + SafeStack.

Clang CFI only protects indirect calls. And SafeStack looks like it has issues, according to the Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=505015

"No. We are currently looking at other alternatives (all look grim, though). Before trying to proceed with SafeStack please get the agreement from security folks, since SafeStack doesn't actually sounds too secure any more :("

Re:Making WebAssembly better for Rust and for all languages by comex on Friday March 16, 2018 @01:16AM (#16598800)
Indirect calls as opposed to what? C++ virtual method calls are supported by Clang CFI. Direct calls are always safe because the destination address is fixed. (That is, unless you mess with the PLT, but that's what RELRO is for.)

Not sure what's up with SafeStack - though I bet it has to do with more hardware timing attacks, in this case to leak the address. The whole design is a bit of a hack since the only thing preventing the attacker from accessing the safe stack is their (theoretical) inability to guess the address. If only x86-64 hadn't gotten rid of segmentation, so normal memory accesses and stack accesses could actually use entirely separate memory regions… On the other hand, Intel CET should allow for some subset of that functionality on future hardware.

But again, to be fair, one should note that "grim" has a different meaning when the budget for acceptable performance loss is perhaps 1-5%, not 30-50% :P

Re:Making WebAssembly better for Rust and for all languages by harpocrates on Wednesday March 14, 2018 @05:01PM (#16588258)
> No they wouldn't. They still need to turn WebAsm/IR into assembly, which is the thing they already do today anyway. Nothing changes for compilers, other than the potential for optimizations gets much, much worse as the IR is comparatively crippled and restricted to the IR they already have.

Most compilers today have separate assembly generation for MIPS, ARM, x86_64. They could turn source into WebAssembly and no more (the job of WebAssembly -> native is left to some other architecture specific compiler).

> This has never been the result of CPU instructions. That's a library problem, not an IR problem. WebAsm does nothing to help with this, particularly as it intentionally has no real standard library to speak of.

If any one language targets WebAssembly, as long as you resolve your libraries within that language, you'll be able to deploy to any target that supports WebAssembly. This is pretty much the defacto solution to the library problem in a variety of ecosystems: in Java you'll make a fatjar and in C/C++/Rust you'll make a staticly linked binary.

> WebAsm is an intermediate, not a source. Formally verifying it is about as useful as formally verifying assembly. Which is to say, not useful at all. That doesn't help you verify anything about your code, which was a compiler, optimizer, and god knows what else away from the webasm that was generated.

Are you familiar with binary analysis?

Re:Making WebAssembly better for Rust and for all languages by andromeduck on Wednesday March 14, 2018 @10:24PM (#16590031)
But why use webasm for that when llvm already does it better?
Re:Making WebAssembly better for Rust and for all languages by harpocrates on Wednesday March 14, 2018 @11:03PM (#16590159)
I'm not sure I understand: WebAssembly is the output of a (hopefully) optimizing compiler. LLVM is such a compiler backend. If you use WebAssembly today, you are probably going through LLVM.

Perhaps you meant: why not use LLVM IR instead of WebAssembly? If so, allow me to refer you to this comment[1] (from a bit further down in this thread).

[1]: https://news.ycombinator.com/item?id=16586239

Re:Making WebAssembly better for Rust and for all languages by imtringued on Thursday March 15, 2018 @08:00AM (#16592032)
>. Nothing changes for compilers, other than the potential for optimizations gets much, much worse as the IR is comparatively crippled and restricted to the IR they already have.

The performance of an application that doesn't work is worse than a cripple application.

Re:Making WebAssembly better for Rust and for all languages by kodablah on Wednesday March 14, 2018 @02:49PM (#16587258)
> I'm so excited about WebAssembly, but really not because of the web.

You and me both. I wrote a backend for the JVM [0] and there is one in dev targetting native [1] (in Rust using an interesting alt-llvm project [2]). I suspect where you'll start to see this really shine is when a popular langauge targets WASM as the primary target and lets second-level backends compile to a specific arch. The other problem is interoperability. Until host bindings come along and the community standardizes on things like string representation and syscalls, many of uses are siloed by the frontend compilers. I think we can do better than libc+posix.

0 - https://github.com/cretz/asmble 1 - https://github.com/sunfishcode/wasmstandalone 2 - https://github.com/Cretonne/cretonne

Re:Making WebAssembly better for Rust and for all languages by fulafel on Wednesday March 14, 2018 @01:05PM (#16586285)
This has been tried many times in the history of computing (ANDF/TenDRA, JVM, NaCL, P-code, TIMI, etc). What's different this time?
Re:Making WebAssembly better for Rust and for all languages by lambda on Wednesday March 14, 2018 @01:17PM (#16586425)
It's a true open standard developed collaboratively by multiple competing top-tier companies, has multiple interoperable implementations, has been designed from the ground up for running untrusted code in a sandboxed environment, has been designed to be a general-purpose compilation target rather than with tight coupling to a specific source language, it has enough killer apps that is will likely continue to be developed and supported by these multiple companies, and it was developed with the hindsight of many of these previous failed or only partially successful efforts.

Some of these previous efforts might have one or two of these features, but none of them meet all of these criteria.

Re:Making WebAssembly better for Rust and for all languages by narag on Wednesday March 14, 2018 @01:37PM (#16586629)
...and it was developed with the hindsight of many of these previous failed or only partially successful efforts.

You seem to imply this approach wasn't successful before. IMHO it's been successful, more than once actually, just not awesome.

Re:Making WebAssembly better for Rust and for all languages by harpocrates on Wednesday March 14, 2018 @01:07PM (#16586311)
What other low-level format supports my points (a), (b), and (c)? And has an actual spec?

EDIT: you've since added some examples. Here are my (very subjective) opinions:

- The JVM isn't really all that low-level - it eeks out a lot of performance at runtime. Plus, you need to have GC, which tends to increase memory requirements and complicate real-time constraints.

- NaCL was interesting but its spec wasn't as good. IIRC Google didn't do too much in the way of asking for public input. I think some folks had some security concerns too. I really like WebAssembly's spec - I don't see any typing judgements or small-step rules for NaCL.

- Wasn't ANDF unix-bound?

Re:Making WebAssembly better for Rust and for all languages by pjmlp on Wednesday March 14, 2018 @06:26PM (#16588892)
Mesa in Xerox Star, TIMI in IBM i, Language Environment on IBM z, MCP in Unisys ClearPath, UCSD Machines are some of the most well known examples.

Using bytecode as portable executable format has been a tradition in mainframes since the early 60's.

Re:Making WebAssembly better for Rust and for all languages by fulafel on Wednesday March 14, 2018 @01:11PM (#16586353)
As far as I know, all of them match WebAssembly on those points. Though most are far back in history and not current rivals.
Re:Making WebAssembly better for Rust and for all languages by protomyth on Wednesday March 14, 2018 @01:28PM (#16586538)
UCSD p-machine?
Re:Making WebAssembly better for Rust and for all languages by e12e on Wednesday March 14, 2018 @06:07PM (#16588761)
I'm not very familiar with the various jvm profiles - but isn't javacard pretty light? (the stuff that runs on similar cards and such)?
Re:Making WebAssembly better for Rust and for all languages by imtringued on Thursday March 15, 2018 @08:13AM (#16592120)
Yes but you're still bound to java semantics. Java is very high level. Almost everything except the blessed primtives long/int/short/byte is an object. This is not a suitable target for lower level languages like C.
Re:Making WebAssembly better for Rust and for all languages by AgentME on Wednesday March 14, 2018 @02:03PM (#16586876)
While some of those were open standards, most/all of those only ever had a single implementation each. JVM's startup time is painful, and its sandboxing abilities have been frequently broken. Wasn't Microsoft p-code interpreted, or are you referring to something else? NaCL was still architecture-specific until PNaCL. PNaCL is pretty comparable to WebAssembly besides that PNaCL was driven by Google alone, and WebAssembly was worked on by many players after it evolved from asm.js.
Re:Making WebAssembly better for Rust and for all languages by seanmcdirmid on Wednesday March 14, 2018 @05:01PM (#16588254)
> most/all of those only ever had a single implementation each.

At its peak, there were many different vendors delivering JVM implementations. How we forget Kaffe, even.

Re:Making WebAssembly better for Rust and for all languages by pjmlp on Wednesday March 14, 2018 @06:29PM (#16588917)
There are still quite a few JVM implementations still, they just tend to be specialized in embedded, military or factory automation systems.
Re:Making WebAssembly better for Rust and for all languages by monocasa on Wednesday March 14, 2018 @09:04PM (#16589735)
* ANDF/TenDRA - Never really used except for research purposes, ie. no critical mass.

* JVM - Most heavily used implementation borked the sandboxing. It also forces a GC down your throat, which is great for 95% of use cases, but the other 5% are really important too.

* NaCl - Really cool, but ultimately reliant on weird CPU features for protection. PNaCl was trying to fit a square peg into a round hole with the whole trying to make LLVM IR platform independent thing. WebAsm took a lot of ideas from these projects (and asm.js).

* P-Code - Really cool, but ultimately probably a victim of it's time. A little simplistic for modern architectures as it has no real concept of a memory model or atomic primitives.

* TIMI - Unbelievably proprietary. Even if you were to document it well enough to build an implementation, IBM would almost certainly sue you into oblivion.

Re:Making WebAssembly better for Rust and for all languages by skybrian on Wednesday March 14, 2018 @01:23PM (#16586484)
None of them run in a browser (though some tried). And now that WebAssembly is the standard, they probably won't get another chance.

And the reason running in a browser matters is that it guarantees a lot of teams will put effort into improving it.

Re:Making WebAssembly better for Rust and for all languages by jcelerier on Wednesday March 14, 2018 @06:10PM (#16588784)
> None of them run in a browser

some used to, until browsers banned them

Re:Making WebAssembly better for Rust and for all languages by monocasa on Thursday March 15, 2018 @10:37AM (#16593201)
Because they couldn't get their shit together from a sandboxing perspective.
Re:Making WebAssembly better for Rust and for all languages by zem on Wednesday March 14, 2018 @01:16PM (#16586416)
languages are actually eager to target it
Re:Making WebAssembly better for Rust and for all languages by oblio on Wednesday March 14, 2018 @01:31PM (#16586564)
Yeah, the social factor is way more important. We might actually get WORA that can't be blocked by a walled garden, cause it would be a suicidal move for whichever company does it.
Re:Making WebAssembly better for Rust and for all languages by zem on Wednesday March 14, 2018 @05:56PM (#16588674)
it's not just the social factor, it's that there's an immediate benefit to using it - your code can be run in a web browser. that solves the bootstrapping problem with your shiny new WORA bytecode spec being unattractive until there are already a bunch of implementations, but there won't be a bunch of implementations until people are actively using it.
Re:Making WebAssembly better for Rust and for all languages by jhomedall on Wednesday March 14, 2018 @01:47PM (#16586733)
That appears to be an intended future use for WebAssembly: http://webassembly.org/docs/non-web/
Re:Making WebAssembly better for Rust and for all languages by swsieber on Wednesday March 14, 2018 @11:10PM (#16590174)
I think this came up recently - I know there's a project to compile webassembly to jvm byte code.
Re:Making WebAssembly better for Rust and for all languages by noahdesu on Wednesday March 14, 2018 @04:20PM (#16587954)
We've added Lua scripting into the Ceph distributed object storage system that lets you remotely compute on objects, or create I/O interfaces with new semantics [0]. I've been excited about WebAssembly as a replacement since I learned about it simply because LuaJIT can be a bit of a pain, and because the cross-compiling toolchains already exist that let me get a lot more existing code into a form that can be shipped off to run remotely.

[0]: https://nwat.xyz/blog/2018/03/13/video-of-my-talk-at-lua-wor...

Re:Making WebAssembly better for Rust and for all languages by twoquestions on Wednesday March 14, 2018 @02:22PM (#16587063)
And here I thought this entire time that Gary was joking when he predicted this, though I'm glad we didn't have to suffer a war to make this happen.

https://www.destroyallsoftware.com/talks/the-birth-and-death...

Re:Making WebAssembly better for Rust and for all languages by wvenable on Wednesday March 14, 2018 @01:48PM (#16586744)
As others have pointed out, platform independent IL is nothing new. There's nothing exciting about WebAssembly outside of the web that hasn't already been done with Java (or countless other technologies).

The true advantage of WebAssembly is that it's so sandboxed that it literally can't do anything on it's own. It can only do something when hosted in a browser where it can use JavaScript to interact with outside world.

Re:Making WebAssembly better for Rust and for all languages by imtringued on Thursday March 15, 2018 @08:31AM (#16592236)
>There's nothing exciting about WebAssembly outside of the web that hasn't already been done with Java (or countless other technologies).

This is completely wrong. The JVM works at an extremely high level. Everything is a garbage collected JVM object. You will never see raw memory at the bytecode layer.

WebAssembly gives you access to the heap and stack at byte granularity. You have to bring your own memory allocator or garbage collector. It's in the damn name: "WebAssembly"

The closest equivalent is NaCL but Google didn't really put a lot of effort into pushing it for wide adoption. If I recall correctly it is also based on LLVM IR and LLVM IR isn't known for maintaining backwards compatibility which turns it into a dead end. Of course if LLVM IR was stable then WebAssembly would be redundant.

We're not living in that world. We're living in a world were WebAssembly is winning not only because of popularity but also because of strong technical fundamentals.

Honestly it seems like HN is blind to fundamentals and everything new is just some hyped up useless piece of shit.

In JS land new = always good. On HN new = always bad. There is no middle ground. Both sides are equally bad.

Re:Making WebAssembly better for Rust and for all languages by wvenable on Thursday March 15, 2018 @03:28PM (#16595838)
> This is completely wrong. The JVM works at an extremely high level.

I'll give you that; it was just one example. There have been plenty of others in history, Pascal P-code is closer to WebAssembly and that's from the 70's! The concept of a portable assembly language is neither new or interesting. WebAssembly is just another compiler target -- if you can compile to it, you can compile to every other native CPU directly. That's just not that interesting as an intermediate form. Java was slightly more interesting as they abstracted the entire platform not just the CPU.

I stand by my statement that WebAssembly is only valuable because it's sandboxed in the browser.

> Honestly it seems like HN is blind to fundamentals and everything new is just some hyped up useless piece of shit.

Maybe being blind to the fundamentals is not knowing the 50 years of technology that has already been done. Remixing old technology in new ways is valuable and in this case remixing portable assembly with the browser sandbox is the cool part.

Re:Making WebAssembly better for Rust and for all languages by colordrops on Wednesday March 14, 2018 @05:40PM (#16588551)
I believe EOS (https://eos.io/) uses WebAssembly for non-web applications.
Re:Making WebAssembly better for Rust and for all languages by floorlamp on Wednesday March 14, 2018 @08:39PM (#16589621)
DFINITY, Polkadot, and the Ethereum WASM project are other examples of blockchain uses.
Re:Making WebAssembly better for Rust and for all languages by mattcoles on Wednesday March 14, 2018 @12:59PM (#16586230)
In what way would it noticeably differ from the LLVM IR then?
Re:Making WebAssembly better for Rust and for all languages by steveklabnik on Wednesday March 14, 2018 @01:00PM (#16586239)
LLVM IR is not platform independent, for one. See http://webassembly.org/docs/faq/#why-not-just-use-llvm-bitco... for the projects' own explanation on this topic.

I share the parents' excitement in this regard. The spec is well written for this kind of thing, and I think it has a lot of potential. We'll see!

Re:Making WebAssembly better for Rust and for all languages by andromeduck on Wednesday March 14, 2018 @11:36PM (#16590261)
Sounds like JVM
Re:Making WebAssembly better for Rust and for all languages by KMag on Thursday March 15, 2018 @01:27AM (#16590597)
The JVM also forces one to adopt the JVM's high-level object model and use the JVM's garbage collector. Plenty of languages have a large semantic mismatch with Java, and shoehorning them onto the JVM is cumbersome.
Re:Making WebAssembly better for Rust and for all languages by usrusr on Thursday March 15, 2018 @05:24AM (#16591370)
But so far, all those frankenstein hacks still had better interoperability between guest language and java than what you get between the natural peers of js and wasm. It's too early to point fingers that way.
Re:Making WebAssembly better for Rust and for all languages by zaarn on Thursday March 15, 2018 @06:24AM (#16591595)
I think someone in a chatroom I'm in is working on something like this; embed a WASM runtime in a fat ELF (or PE) that will also load a runtime from disk if it's newer and then compile/JIT the included WASM code.

IMO WASM can probably learn from the JVM mistakes a lot, especially when the runtime gets baked in so you don't need it on your computer just to run it (looking hard at you JVM, don't try to hide!)

Re:Making WebAssembly better for Rust and for all languages by earenndil on Thursday March 15, 2018 @12:15AM (#16590373)
People sometimes mention this. What about existing things that do the same? What about the JVM? What about llvm IR and bitcode? What about .net/CLR?
Re:Making WebAssembly better for Rust and for all languages by imtringued on Thursday March 15, 2018 @08:41AM (#16592290)
Well maybe it's because these existing things do completely different things and are completely inadequate?

>What about the JVM? too high level

>What about llvm IR and bitcode? no backwards compatibility

>What about .net/CLR? too high level

What the majority of people here do not comprehend is that if you look at each individual feature (low level, stable) each of them is nothing new. It's the combination of these existing features (low level and stable) that existing technologies are simply not capable of.

LLVM had almost two decades to stabilise their IR and yet they didn't so someone else has to step up and fix what they failed to do.

Re:Making WebAssembly better for Rust and for all languages by ZenPsycho on Thursday March 15, 2018 @12:13AM (#16590362)
you're reminding me of this 30 minute talk from 2014 "the birth and death of javascript", in which he supposes a future where CPUs basically run webassembly directly https://www.destroyallsoftware.com/talks/the-birth-and-death...
Re:Making WebAssembly better for Rust and for all languages by icebraining on Thursday March 15, 2018 @02:08AM (#16590748)
Reminds me of Jazelle[1], which allowed some ARM CPUs to run Java bytecode directly. AFAIK it never really caught on.

[1] https://en.wikipedia.org/wiki/Jazelle

Re:Making WebAssembly better for Rust and for all languages by baobrien on Thursday March 15, 2018 @11:23AM (#16593617)
It also probably didn't help that Jazelle was locked behind an NDA.
Re:Making WebAssembly better for Rust and for all languages by ZenPsycho on Thursday March 15, 2018 @08:06PM (#16597603)
not exactly, the idea is to have a normal cpu like arm or x86 but the kernel doesn't ever deal with native binaries, only web assembly, and the performance penalty of running stuff in a VM gets offset by disabling memory protection and its performance penalty, since memory protection is already guaranteed by the VM.
Re:Making WebAssembly better for Rust and for all languages by austincheney on Wednesday March 14, 2018 @09:04PM (#16589730)
> One thing that continues to amaze me is that WebAssembly isn't being discussed more outside of the context of the web.

Probably because WASM is a runtime blackbox locked inside a web page running in a browser. There is a huge amount of overhead to that and the ability to interact with anything external to the blackbox is severely limited.

I get that you are excited that WASM is a compile target for many languages, but it comes with a heavy dose of isolation and performance costs.

Re:Making WebAssembly better for Rust and for all languages by icebraining on Thursday March 15, 2018 @02:17AM (#16590778)
Why is there a huge overhead to that? And how much is "huge"?
Re:Making WebAssembly better for Rust and for all languages by austincheney on Thursday March 15, 2018 @06:13AM (#16591559)
Because a web browser is essentially an operating system running many internal applications. Simply open an empty browser with a single tab and watch how much memory it consumes. Compare that with a new command shell.
Re:Making WebAssembly better for Rust and for all languages by icebraining on Thursday March 15, 2018 @08:04AM (#16592058)
I think harpocrates was talking about running webassembly programs without the browser.
Re:Making WebAssembly better for Rust and for all languages by nerdponx on Wednesday March 14, 2018 @01:33PM (#16586589)
Are there Wasm->native compilers yet?
Re:Making WebAssembly better for Rust and for all languages by singularity2001 on Wednesday March 14, 2018 @01:36PM (#16586623)
node(v8) and all browsers compile Wasm->native ad hoc
Re:Making WebAssembly better for Rust and for all languages by pionar on Wednesday March 14, 2018 @03:51PM (#16587721)
I believe the grandparent was talking about machine-language. Take some WASM, produce an EXE, for example.
Re:Making WebAssembly better for Rust and for all languages by KMag on Thursday March 15, 2018 @01:15AM (#16590559)
In this context, "native" and "machine-language" are synonymous, and V8/Node do in fact generate native code/machine-language from WASM. The GP did correctly answer the OP's question, but it's not clear if the OP had a more specific question in mind.

The phrase you're looking for is "Ahead-of-Time" or "AoT" compiler. It's not clear if the OP was specifically looking for an AoT compiler, or if a JIT suffices for her/his use case.

Re:Making WebAssembly better for Rust and for all languages by imtringued on Thursday March 15, 2018 @08:44AM (#16592310)
I don't really think there is any demand for that. The generated WASM code is already optimized. The JIT is basically a very fast AOT compiler. The only advantage you're gaining is faster startup time and that could perhaps be achieved by caching the generated machine code on disk.
Re:Making WebAssembly better for Rust and for all languages by CryZe on Thursday March 15, 2018 @04:06PM (#16596126)
I compiled a GB emulator written in WASM to Rust yesterday and benchmarked it. The Rust one was about 7 times faster.
Re:Making WebAssembly better for Rust and for all languages by sametmax on Wednesday March 14, 2018 @10:03PM (#16590005)
Yep. Imagine having a webassembly to python bytecode translator in the stdlib. The possibilities...
Re:Making WebAssembly better for Rust and for all languages by mlindner on Wednesday March 14, 2018 @07:10PM (#16589196)
WebAssembly is a dead end. I don't get the hype nor the interest. People tend to forget the huge number of systems out there with tons of active development in C and early versions of C++. Those systems is what Rust would be good for, not "WebAssembly". The vast majority of workhorse code is on the backend, not the front end and UI. I think the only people interested in WebAssembly are former PHP/javascript coders wanting to actually make their code something that runs properly rather than crawls.