Live data from Hacker News

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

twitter.com

41–50 of 106 posts

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

#41

What is the state of the world with wasm at this point? It seems like it's been this huge tease for 10 years now, promising that we'll be able to build web apps in any language. But as far as I'm aware, garbage collection and DOM access is still nonexistent.

There's no garbage collection in WASM. Why do you think that there is garbage collection in WASM? And WASM has been around since 2017, which is only 4 years, not 10 years... Bitcoin has been around much longer (~12 years), for example.

It's a spec proposal. https://github.com/WebAssembly/gc/blob/master/proposals/gc/O...

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

#42

What is the state of the world with wasm at this point? It seems like it's been this huge tease for 10 years now, promising that we'll be able to build web apps in any language. But as far as I'm aware, garbage collection and DOM access is still nonexistent.

Good question, still a "green" technology but I have had great successes with it for the past 4-5 years in production (ASM.JS before widespread WASM compatibility).

"promising that we'll be able to build web apps in any language" is not how I see WASM, nor is it really used in this way outside of transpiling Unity3D/Unreal games (this may be the one area there is an exception). I use it to transpile C++ to WASM libraries used within React apps, Edge Lambdas, and Node.JS servers. Primarily down to 2 reasons: speed and efficiency. WASM unlocks excellence and resources in other disciplines/languages such as AI and AR tool chains, Engineers, OpenCV, etc. When used like this, it is outstanding.

What WASM will never be good at is being used for the whole experience. You lose the semantic web, and/or accessibility tooling. Web has some outstanding guidelines and frameworks to help the impaired, screen readers and the like. Using WASM to pump a native app into a HTMLCanvasElement will lose all of these advances, therefore, WASM shouldn't be used for this use case (outside of games). Like all tooling, there is a time and a place to use them.

Below are a few links which use WASM in production:

https://holition.com/play/holition-brings-home-twenty-awards...

https://winners.webbyawards.com/2020/apps-mobile-and-voice/a...

https://www.youniqueproducts.com/beautyguide#.YIS9hOhKguU

https://www.charlottetilbury.com/us/products/charlottes-virt...

https://visagetechnologies.com/demo/

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

#43
post #9

Earlier quoted context omitted.

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…

> 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 some huge runtime. Doesnt this just imply building a 'huge runtime' into the language?

Not sure I understand. If parts of the runtime are already in the browser, then there's less to download.

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

#44
post #42

What is the state of the world with wasm at this point? It seems like it's been this huge tease for 10 years now, promising that we'll be able to build web apps in any language. But as far as I'm aware, garbage collection and DOM access is still nonexistent.

Good question, still a "green" technology but I have had great successes with it for the past 4-5 years in production (ASM.JS before widespread WASM compatibility). "promising that we'll be able to build web apps in any language" is not how I see WASM, nor is it really used in this way outside of transpiling Unity3D/Unreal games (this may be the one area there is an exception). I use it to transpile C++ to WASM libra…

> "promising that we'll be able to build web apps in any language" is not how I see WASM

Unfortunately it kind of got branded this way for people who aren't close to the front-end industry. There's a segment out there who would like to write web apps but aren't willing to touch JavaScript with a ten-foot pole, and their hopes were gotten up that WASM would give them that. It's not exactly a lie, but it has so many asterisks that it may as well be.

In practice, the reality is that JS will continue to be the only first-class language for the web. WASM has many uses, some on the web and some outside of it, but the closer your app is to the DOM and to the browser as a platform, the less likely it is that you'll ever be able to pretend JS doesn't exist.

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

#45

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.

At that point, what's the purpose of using WASM at all?

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

#46
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?

I worked on one as an undergrad: https://github.com/gwsystems/aWsm

Full AoT compilation, C programs run within 10% of native

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

#47

Earlier quoted context omitted.

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.

Note that it is possible to JIT even with W^X. What these platforms do is prevent memory that has been mapped writable and overwritten with new code from ever being mapped executable again.

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

#48
post #9

Earlier quoted context omitted.

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…

> Rust is pretty accessible to developers coming from scripting languages (JavaScript, Python, etc).

Not in a way that is unique to Rust…

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

#49

What is the state of the world with wasm at this point? It seems like it's been this huge tease for 10 years now, promising that we'll be able to build web apps in any language. But as far as I'm aware, garbage collection and DOM access is still nonexistent.

DOM access is possible with a bit of boilerplate to make the WASM aware of the APIs. In Rust, crates like js-sys and wasm-bindgen automate most of this.

Rust also has the Yew framework, which is surprisingly nice to work with given that Rust is not a frontend language and it only uses the built-in macro system rather than a preprosessor like JSX.

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

#50
post #42

What is the state of the world with wasm at this point? It seems like it's been this huge tease for 10 years now, promising that we'll be able to build web apps in any language. But as far as I'm aware, garbage collection and DOM access is still nonexistent.

Good question, still a "green" technology but I have had great successes with it for the past 4-5 years in production (ASM.JS before widespread WASM compatibility). "promising that we'll be able to build web apps in any language" is not how I see WASM, nor is it really used in this way outside of transpiling Unity3D/Unreal games (this may be the one area there is an exception). I use it to transpile C++ to WASM libra…

In general I agree with your points, but:

> What WASM will never be good at is being used for the whole experience.

The Flutter team would disagree.

They are leaning on WASM for browser builds of Flutter apps, with the whole app rendering in a canvas.

They do accessibility via separately created accessibility trees.

The experience far from great at the moment, but give it a few years and I think it will get there. (better wasm optimisations, direct host interop without JS shims, GC, threads, maybe WGPU instead of canvas, ...)

If that's a good thing for the web is another question...

Post reply on HN