logoalt Hacker News

j0e1yesterday at 6:31 PM5 repliesview on HN

> Garbage collection. In addition to expanding the capabilities of raw linear memories, Wasm also adds support for a new (and separate) form of storage that is automatically managed by the Wasm runtime via a garbage collector. Staying true to the spirit of Wasm as a low-level language, Wasm GC is low-level as well: a compiler targeting Wasm can declare the memory layout of its runtime data structures in terms of struct and array types, plus unboxed tagged integers, whose allocation and lifetime is then handled by Wasm. But that’s it.

Wow!


Replies

teleforceyesterday at 10:45 PM

It's very refreshing and good to see WASM is embracing GC in addition to non-GC support. This approach is similar to D language where both non-GC and GC are supported with fast compilation and execution.

By the way now you can generate WASM via Dlang compiler LDC [1].

[1] Generating WebAssembly with LDC:

https://wiki.dlang.org/Generating_WebAssembly_with_LDC

Zarifftoday at 7:12 AM

I'm not familiar with WASM. Can someone explain why this is a good thing? How does this work with languages that do not have a garbage collector, like Rust?

show 2 replies
baxuzyesterday at 10:16 PM

Does this allow for shrinking the WebAssembly.Memory object?

- https://github.com/WebAssembly/design/issues/1397

- https://github.com/WebAssembly/memory-control/issues/6

This is a crucial issue, as the released memory is still allocated by the browser.

show 2 replies
wyagertoday at 5:21 AM

This seems less than ideal to me.

1. Different languages have totally different allocation requirements, and only the compiler knows what type of allocator works best (e.g. generational bump allocator for functional languages, classic malloc style allocator for C-style languages).

2. This perhaps makes wasm less suitable for usage on embedded targets.

The best argument I can make for this is that they're trying to emulate the way that libc is usually available and provides a default malloc() impl, but honestly that feels quite weak.

show 1 reply
satellite2today at 2:47 AM

That sounds like WASM is going into the Java direction. Is that really a good thing?