Closed torives closed 1 year ago
The original goal was to choose a new development language to replace Rust, evaluating Go and JavaScript mainly on the impact they would have on our (far away) goal of running a reader node in the browser. That might have been too ambitious, but we have learned some interesting things anyway.
Exploring the Go side of things, I searched for how to run Go code in a browser. I came upon three main possibilities:
GOOS=js GOARCH=wasm
was pretty much all that I needed to do to compile a simple HTTP server written in Go to WASM (goroutines and all). I was expecting it to fail as WASM doesn’t support sockets yet, but not only did the compilation succeed but it also didn’t throw any errors when executing the WASM binary in the browser. I have no idea why nothing blew up, but as expected I wasn’t able to connect to the server.
I also wrote a very simple HTTP client to query http://catfact.ninja/fact, and everything worked smoothly.After some reading, testing, and thinking, I came to some conclusions:
host-runner
’s proof generation), then we have the opportunity to reuse this code inside the browser as a WASM module. After discussing these points within the Node Unit, we've concluded that Go is a suitable and in fact the preferred option between the two. Going forward, we'll start using it for new code.
đź“š Context
Rust is a great language, with many desirable characteristics. However, its steep learning curve and the challenges it poses in terms of developer ergonomics have prompted us to explore alternative options. The two contenders are Go for its efficiency and concurrency model and Javascript/Typescript, as it would facilitate the node's integration with Sunodo and the possibility of a reader node running in the browser.
✔️ Solution
Create a small proof-of-concept project in each language to evaluate:
1) Go's integration with WASM and its limitations 2) How to adapt our current needs to Node.js/Javascript's concurrency model
These projects should provide us with enough information to make a decision.