Debian Codegraph @

site/content/community/history.md

raw
1 +++
2 title = "History of wazero"
3 +++
4
5 wazero was originally developed by [Takeshi Yoneda][1] as a hobby project in
6 mid 2020. In late 2021, it was sponsored by Tetrate as a top-level project.
7 That said, Takeshi's original motivation is as relevant today as when he
8 started the project, and worthwhile reading:
9
10 If you want to provide Wasm host environments in your Go programs, currently
11 there's no other choice than using CGO leveraging the state-of-the-art
12 runtimes written in C++/Rust (e.g. V8, Wasmtime, Wasmer, WAVM, etc.), and
13 there's no pure Go Wasm runtime out there. (There's only one exception named
14 [wagon][2], but it was archived with the mention to this project.)
15
16 First, why do you want to write host environments in Go? You might want to have
17 plugin systems in your Go project and want these plugin systems to be
18 safe/fast/flexible, and enable users to write plugins in their favorite
19 languages. That's where Wasm comes into play. You write your own Wasm host
20 environments and embed Wasm runtime in your projects, and now users are able to
21 write plugins in their own favorite languages (AssemblyScript, C, C++, Rust,
22 Zig, etc.). As a specific example, you maybe write proxy severs in Go and want
23 to allow users to extend the proxy via [Proxy-Wasm ABI][3]. Maybe you are
24 writing server-side rendering applications via Wasm, or [OpenPolicyAgent][4]
25 is using Wasm for plugin system.
26
27 However, experienced Go developers often avoid using CGO because it
28 introduces complexity. For example, CGO projects are larger and complicated to
29 consume due to their libc + shared library dependency. Debugging is more
30 difficult for Go developers when most of a library is written in Rustlang.
31 [_CGO is not Go_][5] [ -- _Rob_ _Pike_][6] dives in deeper. In short, the
32 primary motivation to start wazero was to avoid CGO.
33
34 wazero compiles WebAssembly modules into native assembly (Compiler) by default. You
35 may be surprised to find equal or better performance vs mature Compiler-style
36 runtimes because [CGO is slow][7]. More specifically, if you make large amount
37 of CGO calls which cross the boundary between Go and C (stack) space, then the
38 usage of CGO could be a bottleneck.
39
40 [1]: https://github.com/mathetake
41 [2]: https://github.com/go-interpreter/wagon
42 [3]: https://github.com/proxy-wasm/spec
43 [4]: https://www.openpolicyagent.org/docs/latest/wasm/
44 [5]: https://dave.cheney.net/2016/01/18/cgo-is-not-go
45 [6]: https://www.youtube.com/watch?v=PAAkCSZUG1c&t=757s
46 [7]: https://github.com/golang/go/issues/19574