Hacker News new | ask | show | jobs
by dmitriid 2115 days ago
> If packages were distributed in Wasm (plus headers/type declarations), you could JIT or quickly AOT compile them.

Why though? For compiled languages it would make significantly more sense to distribute them in LLVM intermediate representation than WASM.

2 comments

I would agree with you, except that LLVM IR isn’t platform independent. For all of Wasm’s warts it’s the best supported low level cross platform IR we have.
Well, I'll be! This really is a sad development IMO.
The LLVM IR isn't portable. e.g., you can't take the LLVM IR for one CPU or OS and use it on another CPU or OS.
Ah, didn't realize it wasn't portable.
It makes sense if you think about it -- the front-end that used LLVM to create this IR consumed a whole lot of platform specific information, like the layout of structs, system call numbers, library names, and function names, etc and distilled it to something that knows the results of those things but no longer knows how they were derived, so it couldn't be applied as-is to some other platform.

This is why WebAssembly needs a runtime framework for making things outside WebAssembly accessible to WebAssembly code -- it has to build an abstraction around all kinds of different systems.

It's even worse, though, for LLVM IR, since it targets a specific type of CPU in various ways, where WebAssembly is a single ISA.