4 ms·
Has anyone heard of python compiled to Web Assembly ?
by ponytech 10y ago
Has anyone heard of python compiled to Web Assembly ?
- coldtea 10y agoPython needs all the extra runtime and interpreter cannot just be compiled that easily, except with dropped features.
- Freak_NL 10y agoThat reminds me of Google's GWT, which compiled Java to JavaScript and supported a limited subset of the JDK. Maintaining a legacy GWT codebase is not a very pleasant experience, because you are stuck in a Java-like abstraction layer on top of the actual browser features and the DOM. I guess compiling a language like Rust to WebAssembly solves these issues for a part?
- k__ 10y agoI don't know, but if Web Assembly allows something like dynamic linking, it would enable, for example, Oracle to supply a WASM-JVM via CDN, that JVM based languages could target. But this would have to be a rather cut-down version of the JVM, I think, so probably not that viable.
- flohofwoe 10y agoGWT is very different because it directly 'transpiles' Java to a high-level Javascript, you basically get the worst of both worlds ;) asm.js and WebAssembly are much lower level, they are generated from LLVM bitcode, theoretically any language that can be compiled through LLVM can be used with asm.js / WebAssembly (as long as the language runtime libraries are ported to run in a browser environment).
- k__ 10y agoAs far as I know, if you don't want to add a runtime, you can only compile languages that compile to native code to Web Assembly. C, C++, D, Rust, Nim, etc. So it's more for low level lanuages to make performance easier on the Web, not for replacing JavaScript in general.
- dan00 10y agoBut don't need D und Nim a runtime for their garbage collection?
- k__ 10y agoGood point. Maybe it's small? I mean Nim already allows compilation to JavaScript.
- dangerbird2 10y agoC-python runs on a bytecode interpreter, so theoretically you could port the VM to webassembly, provided you remove features that depend on a native operating system. More bare-bones interpreters like Lua (http://daurnimator.github.io/lua.vm.js/repl.html http://daurnimator.github.io/lua.vm.js/repl.html) and Chibi-scheme (https://chibi-scheme.appspot.com/ https://chibi-scheme.appspot.com/) which have had their C compilers and vms ported to emscripten can run natively on the web. JIT interpreters like Juajit, Java Hotspot, and pypy, cannot easily run on webassembly or asm.js due to their dependency on native chipsets with self-modifying code support. Also, most of the tooling for wasm and asm.js relies on llvm, so a good amount of work would be required for compiled languages that don't have compilers emmitting llvm bytecode