Huge fan of Tinygo. I use it for the reduced WASM sizes. I see ~10x reduction when using it. I am working on a project that does some business logic/text parsing[0] that I want to be available on multiple platforms.
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.
Tinygo is neat, but the one time I tried to use it in practice, it failed me. The following program will panic when compiled to wasm:
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?
I mean in a world where a 32-bit microcontroller with flash in the 1-2MB range and a few hundred KiB RAM can cost less than $2 why make things harder on yourself :P
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
Tinygo is great. I think they could address a much larger "market" by improving support for ARM-based systems, notably iOS and Android. I've experimented with cross-compiling Golang code for these platforms and it works great with tools like gomobile, the binary size and runtime overhead can be prohibitive though. I looked at Tinygo to see if it could help with that but couldn't figure out how to compile code for Android, I think it would have been a perfect solution otherwise. In my understanding it supports most of the TLS stack and many other standard libraries as well, which makes it realistic to use it as a systems language on mobile platforms.
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.
Right now we don't have any support for Android and iOS in particular, but we do support Linux/ARM (regular Linux). It's an interesting use case however.
> 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.
Another advantage of tinygo is that unlike "Go proper" FFI with C code is blazingly fast, which makes it a reasonable option for inter-oping with C-library- whereas use of Cgo is actively discouraged in "Go proper" due to performance and other reasons. So using board specific libraries which are very likely to be in C is doable via tinygo.
Oof - I clicked through thinking "oh, it can't be that bad", but that looks like it's doing an llvm build which can be a bear in terms of disk/CPU/RAM IIRC.
I have been very interested in the Zig language for doing micro-controller stuff as I wanted a more modern version of C. But I am beginning to think Tinygo is a better alternative for me. No doubt Zig is a great language but I don't want to always be chasing obscure languages. Go has the benefit of being quite mainstream at this point with a decent size community.
Go is also extremely easy to learn and get going with.
For Arduino-like microcontroller programming, board and device support are pretty important (much like an operating system). Which ones you care about depends on your application.
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.
I was recently working on a project and bumped into this. It's not currently but here are the relevant Github links if you want to learn more (it doesn't look like there's much movement recently):
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.
[0] https://github.com/pion/explainer
[1] https://wasmer.io/