Re:WebAssembly is more than the web
by bluetech on Friday July 13, 2018 @09:36PM
(#17528265)
I think it would be neat if WebAssembly were embedded in other languages, like it is in JavaScript now. For example, suppose Python had a WebAssembly engine. I bet that could replace a lot of C extensions, and it would be as portable/universal as pure Python code, so no need for C compilers, OS-specific binary packages, etc.
[ Parent
| on HN ]
Re:WebAssembly is more than the web
by jillesvangurp on Saturday July 14, 2018 @12:10AM
(#17528775)
The Wasm tool chain is built around llvm. So, you can take some complex C code and target wasm instead of X86, ARM, or whatever. That works right now and you can already do things silly like compile emulators and vms to run in a web browser and get them to boot e.g. windows 95 or linux.
So, you could try to recompile the entire python ecosystem (interpreter, libraries, extensions, etc.) to wasm. This might be tricky right now because not all stuff readily compiles to wasm yet probably or uses gcc instead of llvm. Als, python has its own vm and compiler that would need to be reengineered on top of wasm.
Of course people have been working on moving python to llvm for some time so this might actually become feasible.
Re:WebAssembly is more than the web
by aurelian15 on Saturday July 14, 2018 @12:29AM
(#17528824)
I totally agree with what you said. Currently I'm loading compiled C code with the Python foreign function interface (often not (solely) for performance reasons, but because it just so happens that I already have a C library that solves a particular problem). It would be great if I wouldn't have to worry about providing a shared library for all possible target platforms.
In fact, when I searched for a Python WebAssembly interpreter a few weeks ago I stumbled across this project [1]. So rest assured, people are working on this already.
You'll never be as fast as compiled, unless you're thinking this engine would JIT at which point your "no need for C compilers" became "carry around a WASM compiler". The more rational approach might be to transpile into the target lang, but there are two primary reasons for C extensions, performance and/or FFI, and neither is accomplished via the transpile route. If it's the third, less oft-cited reason for C extensions, avoiding rewrite and/or reuse existing C code, then yes it has value.
In such a world we'd still need compilers to compile code _to_ WebAssembly -- it isn't really a great source language to work in.
I think that will happen actually. It would open some some interesting possibilities.
Re:WebAssembly is more than the web
by imtringued on Saturday July 14, 2018 @07:11AM
(#17529836)
It would certainly make "application level code" more portable (which is still a big win) but some sort of OS specific library still needs to talk to the filesystem, network, etc.
Re:WebAssembly is more than the web
by white-flame on Saturday July 14, 2018 @03:08AM
(#17529213)
While this would supplant "C for speed" libraries, it wouldn't supplant "C for OS access" libraries. At some point, system code needs to call the OS.
Not all OS were or are written in C.
Re:WebAssembly is more than the web
by white-flame on Saturday July 14, 2018 @04:54AM
(#17529472)
Sure, replace "C" with whatever OS language is appropriate. The situation is still the same: wasm doesn't talk directly to the host interfaces, regardless of it being low-level. You'd still need another FFI layer somewhere to talk to those.