Rendered at 20:46:53 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
neomantra 9 hours ago [-]
I was a drive-by contributor to TinyGo, focused on getting MacOS and JS/WASM working well this summer, along with getting BubbleTea to work with it (the last of which was finally merged yesterday!). It was a lot of work, but now it unlocked so much capability for me.
The TinyGo project is an intensely talented cadre of developers. They care deeply this alternative Go compiler/runtime. It was really neat to see them in action and how an already established project accelerated in a year.
It was interesting to see how they adopted LLMs (basically use them but you better know what's going on) and how they dealt with newcomers. The project's scaffolding has improved to keep pace.
While it was intended to get Golang on small devices, the same love makes it work well for WASM. Also it improves as LLVM improves.
I rather consistently get 50% size binaries that run 10% faster and use lower memory than Vanilla Go. The drawback is 5x slower build times. So I dev-loop with Vanilla go and then prod-loop with TinyGo.
Booba will help you embed your Golang in a browser, either Vanilla or TinyGo. There's still some go.mod friction, but the next BubbleTea release will fix that.
Out of curiosity, what can and can't TinyGo do that the official Go compiler/runtime can do ?
bloppe 3 hours ago [-]
Standard Go requires a pretty big runtime, mainly due to the GC, scheduler, and reflection. TinyGo uses much simpler versions of each in its runtime, and there are some subtle behavior differences. For instance, it uses cooperative scheduling for goroutines, rather than preemptive.
It compiles to much smaller sized executables, which in some environments is very important. ie webassembly, embedded devices
wkjagt 8 hours ago [-]
The goal is to run on very limited resources, like micro controllers (ie ESP32, Arduino)
theplumber 7 hours ago [-]
does WASM actually work in browser?
I know that in the standard Go compiler it is still “experimental”. What I mean by that is the program can hang due various issues with wind/unwind browser behaviour. The memory management seems to be another issue. You just can’t ship go-> wasm app in browser in production.
My hope is that once wasi 3 and a wasm-gc implementation will be released for Go then I will finally be able to actually use Go in the browser(via WASM). Until then it’s more or less a kind of java applets experience
aaron42net 5 hours ago [-]
I used tinygo v0.4.1's WASM support in a multi-player browser game (https://smiloid.net) where I wanted to run the world simulation and drone logic to be shared between the browser and the server. In single-player, everything runs in the browser via WASM. In multi-player, the server maintains the authoritative copy and the client renders it predictively based on its user's inputs (modern game netcode style). The rendering engine is in the tinygo WASM, too, which dumps out trapezoids, circles, etc for the browser to draw.
To get the size down, I avoided including anything using reflection (including encoding/json and fmt) and left most of the runtime out, which means the WASM blob can't do concurrency or its own scheduling. The WASM blob is used basically as a set of function calls that take some input and return some output via a preallocated byte buffer shared between TypeScript and Go, with all of the timing, etc driven by the TS side.
This was a weird set of design tradeoffs, but the result is that thousands of lines of Go turn into 276k uncompressed (128k compressed) WASM blob that has 118k of minified JS (37k compressed) driving it that works pretty well. And I still got to make heavy use of Go's great fuzzing tools to chase down weird bugs in the drone logic.
Compared to "hello world" in normal Go being a few megabytes, this seemed pretty impressive, but you could certainly use more of the Go runtime and standard library if you weren't trying to optimize size as much.
stevekemp 3 hours ago [-]
It kinda depends on what you're doing.
I wrote a CP/M emulator, and only had to make trivial changes to compile it to WASM and run it in a browser with xterm.js. (Mostly relating to abstracting the filesystem, and adding a plugin for console I/O.)
No threading is involved, and nothing complex, but it does allow you to run turbo pascal, zork, etc, etc.
bankai-tensei 4 hours ago [-]
[dead]
donatj 10 hours ago [-]
Very nice! I have really been enjoying TinyGo for a couple Pi Pico projects I've been toying with.
Way saner than the C pico projects I've helped my friend work on.
Maybe it's just me but I kind of wish there was more of a way to clearly differentiate a Go project from a Tiny Go project, like .tgo file extensions or like a "compiler tinygo" directive in go.mod or something.
zanderwohl 3 hours ago [-]
C on embedded is truly painful, not for language reasons, but for tooling reasons. I have never cloned a microcontroller project and built it with the directions in the README. There is always so much tinkering to do because the toolchain is so fragile that the slightest differences in your system cause the project to fail to compile.
donatj 3 hours ago [-]
I've got my friend's projects compiling in a Docker container, so that definitely helps
K0IN 9 hours ago [-]
Sorry, I did not use tiny go yet (it's on my bucket list for a long time), i thought it's compatible with go, why would you need a differentiation?
gen2brain 10 hours ago [-]
That is usually done with the build tags, for different OSes and arches, and TinyGo defines the tinygo build tag.
worg 5 hours ago [-]
^ this, and if you really really wanted to have visual differentiation within files nothing prevents you to combine the build tag with a "compound extension" like `.tiny.go`
mkarliner 8 hours ago [-]
I've working on MicroPython with my project thingstudio.net (sorry for plug) and the biggest issue I've had is memory fragmentation, especially on ESP32's.
Does anyone have an insight/comparison on Go garbage collection vs Python?
shit_game 14 hours ago [-]
TinyGo has been my favorite means of using my Raspi Picos so far. My only gripe so far is that maps are nigh unusable due to their slowness, but this is generally simple enough to work around (at the expense of performance). I'm sure there are still more rough edges, but I don't think I'm experienced enough with embedded software to identify them.
dofm 14 hours ago [-]
Part of my LLM-and-agentic-learning phase is giving up interpreted web dev languages and forcing myself to develop agentic skills by using a language I am less familiar with.
I have some Go experience (a small utility used by some dozens of quite niche customers) and trivial experience of macOS development.
So far my two projects have been Go/Gin/goose etc. — a web app — and a small desktop Swift app. But there's GUI stuff for Go and web stuff for Swift. (I could have written my mac app exactly in Golang because there's a package that does what I need)
I had hoped I would find that one of these languages was clearly better than the other. Go is obviously better for the LLM, maybe a bit tiresome to see enormous reams of it for me. Swift is a little harder on the LLM (and it builds more slowly) but it's a bit easier on the eye; I've been very productive in it.
Here, again, it will be hard to separate TinyGo and Embedded Swift.
And there's WASM support for both.
shim__ 9 hours ago [-]
Swift has no garbage collector(just reference counting) as opposed to Go, which should make it a better fit for microcontrollers, since the runtime is lighter
pjmlp 5 hours ago [-]
Reference counting is a garbage collection algorithm.
For microcontrollers, you generally want to avoid dynamic allocation anyway. And when you do come across exceptions when dynamic allocation is appropriate you generally want to avoid deallocation, so GC (which includes reference counting) still doesn't come into play. The exceptional exceptions where you need dynamic allocation and absolutely cannot give up deallocation are not going to be meaningfully impacted by any particular GC algorithm.
TinyGo has tools to help you avoid heap allocation and forego deallocation, so you are well covered, although any language that has an implicit dynamic memory model is never going to be particularly well-suited to microcontroller development.
Lastly, while the Go spec does call for GC, it does not define any particular implementation of GC. One could use reference counting just the same. There is nothing about Go that prevents it.
13 hours ago [-]
KingOfCoders 16 hours ago [-]
I'm using it to generate WASM, sadly Go with the GC/goroutine infra is not as good a WASM language than e.g. Rust which is a very simple 'binary', TinyGo works well though.
that's really interesting, thank you. I'm not sure we're ready to use that platform, though :)
KingOfCoders 14 hours ago [-]
Many aren't, it's a big ask. But I'm more interested in spreading the idea than selling something. I found WASM an underrated gem - e.g. https://pglite.dev/
So you want to take arbitrary code in arbitrary languages, and run it on someone else's computer inside a sandbox?
Yes, wasm can do that.
You can compile the code to wasm, then run it in a runtime like wasmer or wasmtime. Or you can ahead-of-time compile it with something like wasm2c, which generates C code.
You can even compile your C code to wasm and then compile that to C with wasm2c can't you?
onlyrealcuzzo 7 hours ago [-]
This seems pretty cool, but I can't gather from the README what it does and does not do:
```
Non-goals:
* Be efficient while using zillions of goroutines. However, good goroutine support is certainly a goal.
* Be as fast as gc. However, LLVM will probably be better at optimizing certain things so TinyGo might actually turn out to be faster for number crunching.
* Be able to compile every Go program out there.
```
This could mean almost literally anything from - practically - it doesn't compile any existing commonly used Go packages, and is worse at concurrency than Java to it will compile almost anything except packages that are doing really weird, generally accepted terrible things and outside of rare p999 edge cases, it's competitive with Go.
rob74 7 hours ago [-]
The "non-goals" section probably makes more sense if you read the "goals" section first, which boils down to "very small binary sizes, support for µcontrollers and WebAssembly, CGo support, be able to compile most Go code without modifications". The "non-goals" then basically say that they have to make some compromises to achieve the goals.
onlyrealcuzzo 5 hours ago [-]
No - it still doesn't.
I get what it wants to do.
I have no idea what that costs.
jdiff 4 hours ago [-]
It's an indication of where their priorities lie and where they don't. It's a hint to say when you might want to not consider TinyGo, or at least to benchmark your specific use case against it. Optimization and performance are complex.
awesome. I love tinygo - these days mainly to be able to 'dual serve' my go services as cloudflare workers via the tinygo wasm target. works beautifully.
pjmlp 14 hours ago [-]
Lots of goodies in the release.
Congratulations to the team.
Are some of the improvements coming from TamaGo? I know there was supposed to exist a collaboration with other Go toolchains, if I remember correctly a issue that I saw fly by in the past.
kermatt 6 hours ago [-]
> Go compiler for ... command-line tools.
Is there a case for building CLIs with TinyGo meant to run on workstations, instead of the vanilla Go compiler?
flykespice 4 hours ago [-]
I don't know much about Go besides being a GC-based language. This says it also targets mcus.
First off let's not conflate mcu with Iots, that have built-in wireless support. They have more generous constraints than low grade mcus like Arduino Uno (2kb sram..).
Yet this one also says it targets arduino uno. Won't the GC runtime be too much for the small mcu strict memory constraints?
The TinyGo project is an intensely talented cadre of developers. They care deeply this alternative Go compiler/runtime. It was really neat to see them in action and how an already established project accelerated in a year.
It was interesting to see how they adopted LLMs (basically use them but you better know what's going on) and how they dealt with newcomers. The project's scaffolding has improved to keep pace.
While it was intended to get Golang on small devices, the same love makes it work well for WASM. Also it improves as LLVM improves.
I rather consistently get 50% size binaries that run 10% faster and use lower memory than Vanilla Go. The drawback is 5x slower build times. So I dev-loop with Vanilla go and then prod-loop with TinyGo.
Booba will help you embed your Golang in a browser, either Vanilla or TinyGo. There's still some go.mod friction, but the next BubbleTea release will fix that.
https://nimbleterminal.com/booba
Here's some TinyGo interactive graphics next to Vanilla:
https://nimblemarkets.github.io/ntcharts3d/?demo=gallery&com...
Pro-tip: use gc=boehm for JS/WASM targets
I know that in the standard Go compiler it is still “experimental”. What I mean by that is the program can hang due various issues with wind/unwind browser behaviour. The memory management seems to be another issue. You just can’t ship go-> wasm app in browser in production.
My hope is that once wasi 3 and a wasm-gc implementation will be released for Go then I will finally be able to actually use Go in the browser(via WASM). Until then it’s more or less a kind of java applets experience
To get the size down, I avoided including anything using reflection (including encoding/json and fmt) and left most of the runtime out, which means the WASM blob can't do concurrency or its own scheduling. The WASM blob is used basically as a set of function calls that take some input and return some output via a preallocated byte buffer shared between TypeScript and Go, with all of the timing, etc driven by the TS side.
This was a weird set of design tradeoffs, but the result is that thousands of lines of Go turn into 276k uncompressed (128k compressed) WASM blob that has 118k of minified JS (37k compressed) driving it that works pretty well. And I still got to make heavy use of Go's great fuzzing tools to chase down weird bugs in the drone logic.
Compared to "hello world" in normal Go being a few megabytes, this seemed pretty impressive, but you could certainly use more of the Go runtime and standard library if you weren't trying to optimize size as much.
I wrote a CP/M emulator, and only had to make trivial changes to compile it to WASM and run it in a browser with xterm.js. (Mostly relating to abstracting the filesystem, and adding a plugin for console I/O.)
No threading is involved, and nothing complex, but it does allow you to run turbo pascal, zork, etc, etc.
Way saner than the C pico projects I've helped my friend work on.
Maybe it's just me but I kind of wish there was more of a way to clearly differentiate a Go project from a Tiny Go project, like .tgo file extensions or like a "compiler tinygo" directive in go.mod or something.
I have some Go experience (a small utility used by some dozens of quite niche customers) and trivial experience of macOS development.
So far my two projects have been Go/Gin/goose etc. — a web app — and a small desktop Swift app. But there's GUI stuff for Go and web stuff for Swift. (I could have written my mac app exactly in Golang because there's a package that does what I need)
I had hoped I would find that one of these languages was clearly better than the other. Go is obviously better for the LLM, maybe a bit tiresome to see enormous reams of it for me. Swift is a little harder on the LLM (and it builds more slowly) but it's a bit easier on the eye; I've been very productive in it.
Here, again, it will be hard to separate TinyGo and Embedded Swift.
And there's WASM support for both.
Chapter 5, https://gchandbook.org
"A Unified Theory of Garbage Collection"
https://web.eecs.umich.edu/~weimerw/2012-4610/reading/bacon-...
For microcontrollers, you generally want to avoid dynamic allocation anyway. And when you do come across exceptions when dynamic allocation is appropriate you generally want to avoid deallocation, so GC (which includes reference counting) still doesn't come into play. The exceptional exceptions where you need dynamic allocation and absolutely cannot give up deallocation are not going to be meaningfully impacted by any particular GC algorithm.
TinyGo has tools to help you avoid heap allocation and forego deallocation, so you are well covered, although any language that has an implicit dynamic memory model is never going to be particularly well-suited to microcontroller development.
Lastly, while the Go spec does call for GC, it does not define any particular implementation of GC. One could use reference counting just the same. There is nothing about Go that prevents it.
It relies on LLVM’s Wasm backend and some JS glue libraries for the browser.
[1] https://github.com/duckdb/duckdb-wasm
Yes, wasm can do that.
You can compile the code to wasm, then run it in a runtime like wasmer or wasmtime. Or you can ahead-of-time compile it with something like wasm2c, which generates C code.
``` Non-goals:
* Be efficient while using zillions of goroutines. However, good goroutine support is certainly a goal.
* Be as fast as gc. However, LLVM will probably be better at optimizing certain things so TinyGo might actually turn out to be faster for number crunching.
* Be able to compile every Go program out there.
```
This could mean almost literally anything from - practically - it doesn't compile any existing commonly used Go packages, and is worse at concurrency than Java to it will compile almost anything except packages that are doing really weird, generally accepted terrible things and outside of rare p999 edge cases, it's competitive with Go.
I get what it wants to do.
I have no idea what that costs.
Congratulations to the team.
Are some of the improvements coming from TamaGo? I know there was supposed to exist a collaboration with other Go toolchains, if I remember correctly a issue that I saw fly by in the past.
Is there a case for building CLIs with TinyGo meant to run on workstations, instead of the vanilla Go compiler?
First off let's not conflate mcu with Iots, that have built-in wireless support. They have more generous constraints than low grade mcus like Arduino Uno (2kb sram..).
Yet this one also says it targets arduino uno. Won't the GC runtime be too much for the small mcu strict memory constraints?