WebAssembly/design

Language virtual machines

Closed this issue · 4 comments

Hi,

I don't really understand what mean "Virtual machines for languages such as bash, Python, Ruby should work." mentioned in design/tooling support.
Is it a virtual machine written in WebAssembly which can run in V8 to execute Python or Ruby program?

Thank you

Yes, I guess

WebAssembly itself is a low-level VM, and it's designed to be able to host other VMs such as language VMs (bash, python, ruby).

So yes: a WebAssembly VM implemented on top of V8 will be able to host bash.wasm / python.wasm / ruby.wasm which implement these languages.

Closing for now, let me know if I can clarify further!

Thanks for your reply.

I have the other question is that bash.wasm / python.wasm / ruby.wasm is it translated from C/C++ or directly written in WebAssembly by hand?

And, is it possible to write a big tool directly in WebAssembly by hand (difficult debugging?) ?

Thank you.

You would compile bash / python / ruby from their C/C++ source using a regular compiler, but targeting WebAssembly. It's the same as compiling for ARM or MIPS: you may cross-compile to another architecture.

To a C/C++ compiler WebAssembly simply looks like a different ISA and OS. We're working on teaching LLVM about it, but any other compiler could support WebAssembly code generation.

You can write .wast files by hand, (e.g. see the spec repo's tests at https://github.com/WebAssembly/spec/tree/master/ml-proto/test) but you don't really want to: WebAssembly is mainly a compiler target, not a language you'd want to write. It's the same as writing x86 assembly: you sure can, there are cases where it makes sense, but most of the time you want higher-level languages and lean on the compiler to generate the assembly.

Hope this makes sense!