Live data from Hacker News

Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

twitter.com

11–20 of 106 posts

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#11

I'm a newer dev so pardon my ignorance. Is webassembly the new, more open JVM? Feels like that write once, run everywhere but this time with any(most) mainstream language.

Wasm lacks a lot of lower level system specific operations that the jvm offers.

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#12
post #2

For those wondering, Wasm3 describes itself as "the fastest WebAssembly interpreter". Other webassembly runtimes are JIT based, rather than being interpreters. The project's readme ( https://github.com/wasm3/wasm3 ) talks more about this decision. For more on the difference, and an explanation of what JIT is, check out this section of the book Crafting Interpreters ( https://craftinginterpreters.com/a-map-of-the-terr…

> Other webassembly runtimes are JIT based, rather than being interpreters. Do none of the notable ones do normal compilation?

Some runtimes like wasmtime support AOT compilation artifacts that can be loaded.

But in general you can't "just compile" Webassembly, because you need a runtime.

There is a C project that can compile an executable that includes the runtime and the compiled WASM, but the name is escaping me right now.

Note that JIT in the WASM world doesn't quite mean the same thing as for eg Java. Almost all runtimes compile a whole module at once, not individual functions.

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#13

I'm a newer dev so pardon my ignorance. Is webassembly the new, more open JVM? Feels like that write once, run everywhere but this time with any(most) mainstream language.

It seems like it's headed that way. At the moment, it's only really practical to generate WASM from compiled languages, or really small languages, like Lua. And your interfaces to the browser (and thus, the outside world) itself are pretty limited, so still lots of javascript involved.

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#14

I'm a newer dev so pardon my ignorance. Is webassembly the new, more open JVM? Feels like that write once, run everywhere but this time with any(most) mainstream language.

In a way, but wasm is designed to be a lot better at sandboxing.

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#15

Earlier quoted context omitted.

What would the difference be between “JIT” and “normal” compilation for WebAssembly?

An AOT compiler would do a one-time translation to a platform-specific binary. If the environment you run on doesn’t support JIT compilation (iOS for example), AOT compiling WASM is useful.

How can a platform not support j.i.t. compilation?

In what way does a platform need to coöperate with that?

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#16
post #13

I'm a newer dev so pardon my ignorance. Is webassembly the new, more open JVM? Feels like that write once, run everywhere but this time with any(most) mainstream language.

It seems like it's headed that way. At the moment, it's only really practical to generate WASM from compiled languages, or really small languages, like Lua. And your interfaces to the browser (and thus, the outside world) itself are pretty limited, so still lots of javascript involved.

Can confirm that Lua does run in WASM in the browser: https://github.com/vvanders/wasm_lua

I sometimes wonder what the world would be like if Lua had zero based indices and saw a bit broader adoption. It's such an easy language to embed/extends although QuickJS looks like it's going to give it a run for the money in the long term given the similar goals on ease of embedding.

I wonder if anyone has compiled QuickJS to WASM and run it in the browser.

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#17

Earlier quoted context omitted.

An AOT compiler would do a one-time translation to a platform-specific binary. If the environment you run on doesn’t support JIT compilation (iOS for example), AOT compiling WASM is useful.

How can a platform not support j.i.t. compilation? In what way does a platform need to coöperate with that?

Some platforms are enforcing https://en.wikipedia.org/wiki/W%5EX because malware also wants to create novel machine code within a running process.

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#18
post #9
post #5

I feel the need to repost this link: https://www.destroyallsoftware.com/talks/the-birth-and-death...

I'm somewhat curious at what pace WASM will gain "market share" while it's only practical to target it with C, C++, Rust, etc. Supposedly, there are plans to expand it to where it looks more like a virtual machine and less like ASM. Adding things like garbage collection, direct DOM manipulation, polymorphic inline cache, etc. Things that would make it possible to run a decent scripting language without pulling in som…

it seems more like it's it's trying to be LLVM but for the web?

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#19
post #9
post #5

I feel the need to repost this link: https://www.destroyallsoftware.com/talks/the-birth-and-death...

I'm somewhat curious at what pace WASM will gain "market share" while it's only practical to target it with C, C++, Rust, etc. Supposedly, there are plans to expand it to where it looks more like a virtual machine and less like ASM. Adding things like garbage collection, direct DOM manipulation, polymorphic inline cache, etc. Things that would make it possible to run a decent scripting language without pulling in som…

Graalvm native image has the ability to target llvm with a goal of making it easier "to target a new architecture without having to implement a complete new backend for Native Image."

https://www.graalvm.org/reference-manual/native-image/LLVMBa...

Re: Wasm3 compiles itself (using LLVM/Clang compiled to WASM)

#20
post #9
post #5

I feel the need to repost this link: https://www.destroyallsoftware.com/talks/the-birth-and-death...

I'm somewhat curious at what pace WASM will gain "market share" while it's only practical to target it with C, C++, Rust, etc. Supposedly, there are plans to expand it to where it looks more like a virtual machine and less like ASM. Adding things like garbage collection, direct DOM manipulation, polymorphic inline cache, etc. Things that would make it possible to run a decent scripting language without pulling in som…

> while it's only practical to target it with C, C++, Rust, etc.

You might not want to bundle Rust in with C and C++ in this context. Rust is pretty accessible to developers coming from scripting languages (JavaScript, Python, etc).

Direct DOM manipulation (and the ability to send reference types across the JS-wasm boundary) is a pretty big deal though I think. Currently it doesn't make an awful lot of sense to build code that interacts with the DOM in WASM (although in Rust there are automatically generated bindings that go through a JavaScript shim).

Post reply on HN