3 ms·
I don't think its possible to efficiently compile a dynamically-typed language like Python to statically-typed WASM.
by bakery2k 7y ago
I don't think its possible to efficiently compile a dynamically-typed language like Python to statically-typed WASM.
- buu700 7y agoThought experiment: what about transpiling Python to JS? https://github.com/QQuick/Transcrypt https://github.com/QQuick/Transcrypt looks like a nice implementation, but their readme just talks about deployment to browsers — I'm curious about outside of the browser whether Transcrypt + Node might be more efficient than CPython. (Not even just CPython, but really any dynamic language implementation.) And then of course wasm could still be used for C extensions.
- mixmastamyk 7y agoNot random code, but specifically written with type checking should be doable. There was an asm,js subset for example.
- ufo 7y agoCalling asm.js a subset of Javascript is a bit of a stretch. It looks nothing like idiomatic Javascript, and was more of a low-level statically-typed language dressed up in Javascript clothing. At some point they realized that representing this low-level code as Javascript text instead of as specially-designed bytecode added a significant ammount of parsing and compilation overhead, which was one of the initial motivations for the creation of WebAssembly. If I had to sum up WASM in one sentence, it is that it is kind of like the JVM, except that its instruction set was designed specifically for running programs downloaded from the web. Special attention was paid to security and startup latency.
- cwp 7y agoErm... the JVM was also designed specifically for running programs downloaded from the web. Special attention was paid to security and startup latency. Javascript got its name because it was the only other language designed to be downloaded and executed in a browser!
- firethief 7y agorpython might be a better example
- simonh 7y agoYou’d have to compile the CPython interpreter to WASM.