5 ms·
Tinygo: LLVM-based Go compiler for microcontrollers, WASM, and CLI tools
- ThePhysicist 4y agoTinygo 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.
- aykevl 4y agoRight 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.
- socialdemocrat 4y agoI 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.
- rowanG077 4y agoTinygo is honestly extremely niche. Similar to circuitpython or micropython I really wouldn't reccomend anything but hobby toys to be written in it.
- dkegel 4y agoTinygo is supported by several edge computing platforms, and works well for at least one commercial application. 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.
- kyrra 4y agoAside: the go team maintains frontends for gcc and llvm, though not targeting microcontrollers like this. https://github.com/golang/gofrontend https://github.com/golang/gofrontend https://go.googlesource.com/gollvm/ https://go.googlesource.com/gollvm/
- svnpenn 4y agodo either one of those have builds? I would like to try them out, but not enough to build myself
- yjftsjthsd-h 4y agoOof - 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.
- 4ad 4y agoGccgo is packaged by any reasonable Linux distribution.
- Sean-Der 4y agoHuge 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. [0] https://github.com/pion/explainer https://github.com/pion/explainer [1] https://wasmer.io/ https://wasmer.io/
- liftm 4y agoTinygo 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?
- maxmcd 4y agoI don't think "encoding/json" is fully working yet. Seems to be importable now, although tests are not passing. See supported packages here: https://tinygo.org/docs/reference/lang-support/stdlib/ 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/ https://play.tinygo.org/
- eek2121 4y agoDunno bro, it doesn't work on the 6502, so... ;)
- Joker_vD 4y ago
- mseepgood 4y agoThe website: https://tinygo.org/ https://tinygo.org/
- skybrian 4y agoFor 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. [1] https://tinygo.org/docs/reference/microcontrollers/ https://tinygo.org/docs/reference/microcontrollers/ [2] https://tinygo.org/docs/reference/devices/ https://tinygo.org/docs/reference/devices/
- tony-allan 4y agoIs Wi-Fi for ESP32 devices is working yet? I didn't see anything specific one the supported boards page.
- sp33k3rph433k 4y agoI 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): https://github.com/tinygo-org/tinygo/issues/1427 https://github.com/tinygo-org/tinygo/issues/1427 https://github.com/tinygo-org/drivers/pull/320 https://github.com/tinygo-org/drivers/pull/320
- avl999 4y agoAnother 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.