TinyGo 0.42 - Recover Is Real

24 points by datboi


weberc2

EDIT: A related post on the front page: https://matklad.github.io/2026/09/02/static-allocation-constant-work.html

I've been spending a lot of time writing zero-allocation Go code, not because allocations are particularly expensive, but because my theory is that systems are much more reliable and predictable when they allocate all their memory (and goroutines!) up front and also because you end up with a system that uses relatively little memory (and always exactly the same amount!). You basically can't leak memory or goroutines if you allocate a constant number of each at the start of the application. You also don't have to worry about the OOMKiller (including classes of DoS attacks)--on the other hand, more care is required to ensure that your reusable buffers are reset appropriately. Moreover, it makes capacity planning much more straightforward when each instance of your application always needs exactly the same number of bytes.

Interestingly, I've found that (1) zero-alloc interfaces aren't much harder to use than allocating interfaces and (2) after learning a few basic principles it's pretty easy to write zero-alloc code (although Go makes it harder than it needs to be by violating its own philosophy about code not doing things implicitly).

Anyway, I'm hoping that there will be a lot more crossover between the TinyGo people and the rest of us when it comes to building zero-alloc libraries.

cinemast

I love to see so much progress on tinygo. UEFI and ESP32 is impressive.