D and WebAssembly (Wasm)
Ferhat Kurtulmuş
aferust at gmail.com
Mon Sep 13 17:19:23 UTC 2021
On Monday, 13 September 2021 at 16:19:31 UTC, Kenneth Dallmann
wrote:
> Greetings!
>
> Many people in the development community are very excited
> about
> WebAssembly, because it allows the browser to interpret more
> robust
> languages than JS.
>
> Rumor has it that D can compile to Wasm, but only in the
> "BetterC"
> subset.
>
> LLVM can compile to Wasm, but unfortunately it may not
> support
> systems IO calls because of the lack of operating system access.
> Emscripten is a compiler that can transform C into something
> that
> can run on Wasm without holes in the Standard Library. It does
> this by simulating an operating system, which adds overhead to
> the
> runtime, but allows a full range of C to be used, to my
> understanding.
>
> With D not being able to be run on Wasm in a meaning way: Why
> can't
> we just compile D code to C, as a compiler output, and then run
> that
> through Emscripten?
You don't need to compile d code to c. You can use d code with
emscripten. Sebastiaan Koppe was working on druntime[1] to make
it possible to use it with webassembly. Dunno its current status.
Here is also my d game using wasm. It even links with c libraries
compiled with emscripten.
https://aferust.github.io/drawee/
https://github.com/aferust/drawee
[1]: https://github.com/skoppe/druntime/tree/wasm
More information about the Digitalmars-d
mailing list