Tinygo: LLVM-based Go compiler for microcontrollers, WASM, and CLI tools
github.com
github.com
With TinyGo + wasmer[1] I can build a library that is usable in Python, PHP, Javascript and C++. It has been a lot of fun for me. Lots of rough edges still exist when moving between WASM/calling language, but when you get it working it feels amazing.
If you're using a chip without the bells and whistles for precise timing reasons, then you're probably gonna program it in assembly too anyways
package main
import "encoding/json"
func main() {
var parsed interface{}
json.Unmarshal([]byte(`{"test":42}`), &parsed)
}
(It's been a while, so I forgot the problem with it was.)I'm curious what kind of text parsing you do. I ended up rolling with valyala/fastjson, but that's very much not what I was imagining. Lots of existing libraries don't work either, and finding out what does and what doesn't is pain. Is there some trick to working with it?
Seems to be importable now, although tests are not passing. See supported packages here: https://tinygo.org/docs/reference/lang-support/stdlib/
Definitely still a ways to go before the full stdlib is usable.
Looks like your code still fails at runtime with the error:
panic: unimplemented: (reflect.Type).NumMethod()
Tested here: https://play.tinygo.org/I know that Tailscale keeps their own fork of Golang with some optimizations for mobile as well, and where they try to merge stuff back into the mainline, so maybe in the future binary size and runtime overhead will go down for regular Golang. Tinygo seems to do a much better job at reducing that though, so it would be great to have it work on mobile.
> In my understanding it supports most of the TLS stack and many other standard libraries as well
We don't have a proper net package yet so usage on Android/iOS will be rather limited.
Go is also extremely easy to learn and get going with.
If you need wasm/wasi support, and you're ok with working around the partial support for reflect etc., it's not a bad choice.
Looks like they have support listed for lots of boards [1] and lots of devices [2]. It won't work for me yet, though, because I need USB serial and MIDI, and they seem not to be implemented yet, at least for the Teensy and Raspberry Pi Pico.
[1] https://tinygo.org/docs/reference/microcontrollers/ [2] https://tinygo.org/docs/reference/devices/
I didn't see anything specific one the supported boards page.