# Garbage Compilation enabled in WebAssembly (at least in Google Chrome)

**URL:** <https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757>\
**Category:** Offtopic\
**Created:** [November 3, 2023, 2:35pm UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757 "2023-11-03T14:35:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 3, 2023, 2:35pm UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/1 "2023-11-03T14:35:25Z")

</div>

What does this mean for Julia? Julia can aready work in web browser (with WebAssembly), even with out GC standardized, but possibly it could work better with the web browsers GC used?

> **[WebAssembly Garbage Collection (WasmGC) now enabled by default in Chrome -...](https://developer.chrome.com/blog/wasmgc/)**
>
> There are two types of programming languages: garbage-collected programming languages and programming languages that require manual memory management. This article explains how thanks to WebAssembly Garbage Collection, short WasmGC, garbage-collected...

> **[GitHub - WebAssembly/proposals: Tracking WebAssembly proposals](https://github.com/WebAssembly/proposals)**
>
> Tracking WebAssembly proposals. Contribute to WebAssembly/proposals development by creating an account on GitHub.

> Phase 5 - The Feature is Standardized (WG)  
> [i.e. extensions of to WebAssembly]

but GC and more interesting is under (unless this is outdated):

> Phase 4 - Standardize the Feature (WG)"

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [November 3, 2023, 11:48pm UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/2 "2023-11-03T23:48:01Z")

</div>

Viewing this in the context of this YouTube recording , this development seems promising.

[![](https://global.discourse-cdn.com/julialang/original/3X/7/3/733ad7526f0f95f5bc59c75271ff97047e63a1d8.jpeg "Julia Language on WebAssembly: Our Wish List and Experience So Far") ](https://www.youtube.com/watch?v=DUumYxjK1Xs)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 4, 2023, 7:23am UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/3 "2023-11-04T07:23:43Z")

</div>

And it already works on ODE solvers:

> **[Lorenz model · WebAssemblyCompiler](https://tshort.github.io/WebAssemblyCompiler.jl/stable/examples/lorenz/)**
>
> Documentation for WebAssemblyCompiler.

---

<div class="post-metadata">

**Author:** ![tshort](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tshort/32/43_2.png) [@tshort](https://discourse.julialang.org/u/tshort)\
**Post date:** [November 4, 2023, 6:08pm UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/4 "2023-11-04T18:08:29Z")

</div>

[WebAssemblyCompiler.jl](https://github.com/tshort/WebAssemblyCompiler.jl) is pretty new. The SciML code works well for compilation because they keep structs concrete by parameterizing types like crazy.

Less concrete code is much tougher. WebAssemblyCompiler offers overlays to redefine problem code. I’ve been playing with compiling Observables and Makie, and that’s helpful. That code has many non-concrete types, and it’s a challenge. In addition to overlays, I also needed to unroll as much as possible to keep things type stable.

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [November 5, 2023, 2:57am UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/5 "2023-11-05T02:57:45Z")

</div>

I found [A new way to bring garbage collected programming languages efficiently to WebAssembly · V8](https://v8.dev/blog/wasm-gc-porting) a more interesting article also discussing the challenges in porting languages.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 5, 2023, 5:05pm UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/6 "2023-11-05T17:05:57Z")

</div>

It’sn interesting link, I had not heard of `emmalloc` which isn’t interesting in this (GC) context, but might be for StaticCompiler.jl, from the link on it there:

> The incoming branch now has a MALLOC option which can be either dlmalloc (the standard allocator from before) or emmalloc, which is a new allocator written to be small and simple. It’s about a third of the code size of dlmalloc, which can help on small programs that use malloc/free, where sometimes malloc/free is most of the binary.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [November 5, 2023, 5:11pm UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/7 "2023-11-05T17:11:23Z")

</div>

> [@tshort](#):
>
> [WebAssemblyCompiler.jl](https://github.com/tshort/WebAssemblyCompiler.jl) is pretty new.

WebAssembly is useful for the web, its original purpose, but also elsewhere. StaticCompiler.jl currently has a limitation of not working for Windows, but WebAssembly works everywhere, including there right? With that project, it does NOT distribute its own GC (EDIT: I thought then no GC, but actually uses WASM-GC], i.e. has same limitations as StaticCompiler (except for the portability limitation)? In theory it could distribute its own GC or just use WasmGC?

---

<div class="post-metadata">

**Author:** ![tshort](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tshort/32/43_2.png) [@tshort](https://discourse.julialang.org/u/tshort)\
**Post date:** [November 5, 2023, 6:47pm UTC](https://discourse.julialang.org/t/garbage-compilation-enabled-in-webassembly-at-least-in-google-chrome/105757/8 "2023-11-05T18:47:04Z")

</div>

WebAssemblyCompiler should work on Windows, but I haven’t tried it. WebAssemblyCompiler does not have as many limitations as StaticCompiler. The big difference is that it uses WASM-GC, so it supports arrays (even Vector{Any}), mutable types, dicts, and other garbage-collected objects. You still need code that can be statically compiled, and currently, there are other limitations.
