Webassembly?

Wulfklaue via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 6 11:09:03 PDT 2017


On Thursday, 6 July 2017 at 17:19:34 UTC, bauss wrote:
> I'm just curious how it doesn't support GC? Like if you can 
> allocate and free memory then you can have a GC.

Currently there is no native GC build into WebAssembly. This is 
planned for the future.

If your language is designed around allocating and freeing memory 
manually, you have no issue with WebAssembly. C/C++/Rust ...

But you can not program in D fashion ( where the GC takes care of 
things ). It means you need to write the allocation and freeing 
all the time for any code that targets WebAssembly. hat also 
means no std library etc ... Think of it as writing pure @nogc 
code ( what currently breaks like half the standard library ).

WebAssembly has plans for a native GC build into the design for 
the next version so that languages that have there own GC, can 
target this and not run into the issue of manually allocating and 
freeing. Think C#, Go, ...

The other option is for the language to have there own GC 
included that targets WebAssembly into the compiled wasm file but 
that adds overhead. And is more work for the language to support. 
That is why a lot of languages that have GCs are on the fence and 
are waiting for the default GC.

GC are nice and well but at times having a pure no-gc language 
does have its advantages ;)


More information about the Digitalmars-d mailing list