The Complete Guide to TinyGo, Zig and Ada on Microcontrollers
Compare TinyGo, Zig and Ada for microcontroller firmware: toolchains, blinky programs, memory models, interrupts, C interop and when to choose each.

Firmware in C works, and almost every vendor SDK assumes it. It also hands you a language with no bounds checks, an implicit conversion rule for every pair of integer types, and a preprocessor that decides what compiles. Three other languages target the same chips with the same compilers underneath: TinyGo, Zig and Ada. Each makes a different trade. TinyGo gives you Go syntax, goroutines and a garbage collector on a Cortex-M0 or an RP2040. Zig gives you a C-like language with explicit allocation, compile-time code execution and a cross compiler that needs no toolchain installation. Ada gives you strong typing, ranges as part of the type, a tasking model with a proven schedulability analysis, and a verifiable subset called SPARK.
This guide is the hub for all three on SystemCoding. It builds the same blinking LED in each, then covers what changes when the program grows: memory, concurrency, interrupts, calling C, size, debugging and testing. It states plainly who each language does not fit. The versions it refers to are TinyGo 0.37 with Go 1.24, Zig 0.14, and the GNAT FSF ARM ELF toolchain distributed through Alire 2.x, targeting Arm Cortex-M parts such as the RP2040 and the STM32 families. Check the release notes of each project before copying a command, because all three evolve quickly.
Nothing in this guide was run on a board. Every program was written against the documentation of the version named, and each output block shows what the code does by reading it. Compile before you trust a pin number.
Why look beyond C
C remains the default for good reasons: every chip has a header, every debugger understands it, and its output is predictable. The costs show up with scale. An out-of-range array write corrupts a neighboring variable and the program keeps running. An int and an unsigned mixed in one comparison produce a result that depends on promotion rules. A missing volatile lets the compiler remove a register read. None of these are rare, and none of them is caught at compile time.
The three languages here attack different slices of that list.
| Concern | TinyGo | Zig | Ada |
|---|---|---|---|
| Bounds checks | Yes, at run time | Yes in Debug and ReleaseSafe | Yes, with ranges in the type |
| Memory management | Garbage collector, can be switched off | Manual, explicit allocators | Manual or static, no collector |
| Concurrency | Goroutines and channels | None in the language | Tasks, protected objects |
| Compile-time code | Limited | comptime | Generics, static expressions |
| Formal verification | No | No | SPARK |
| Reach for vendor C | cgo-style import, limited | @cImport, full | Import aspect, full |
No row favors one language everywhere, which is why this guide ends with a decision table rather than a winner.
The reference program: blink an LED
The same job, in each language, shows the shape of the toolchain before any special feature appears. The target is a Raspberry Pi Pico with its LED on GPIO 25, which is the original board's pin; the Pico W routes its LED through the wireless chip, so check your variant.
TinyGo
TinyGo is an LLVM-based Go compiler for small targets. Install it from the TinyGo installation guide, then write ordinary Go:
package main
import (
"machine"
"time"
)
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
for {
led.High()
time.Sleep(500 * time.Millisecond)
led.Low()
time.Sleep(500 * time.Millisecond)
}
}Hold BOOTSEL, plug in the board, and run:
tinygo flash -target=pico main.go(no output on success; the board reboots and the LED blinks at 1 Hz)The machine package is TinyGo's hardware abstraction layer, and machine.LED is a pin constant defined by the board's target file. The time package works because TinyGo supplies a timer-backed implementation of time.Sleep. The compiler produces a UF2 or ELF file for the target and the flash command copies it. The flashing post for the Pico walks through the same program step by step.
Zig
Zig ships a cross compiler in one download, and the target is a property of the build. A bare-metal program has no main in the C sense; the linker script names the entry point. The smallest useful program sets a stack, defines the vector table, and calls the application. A real project uses a framework such as MicroZig for that, covered in the MicroZig post. The core of the application code looks like this once the framework supplies startup:
const std = @import("std");
const microzig = @import("microzig");
const rp2xxx = microzig.hal;
const time = rp2xxx.time;
const gpio = rp2xxx.gpio;
const led = gpio.num(25);
pub fn main() void {
led.set_function(.sio);
led.set_direction(.out);
while (true) {
led.put(1);
time.sleep_ms(500);
led.put(0);
time.sleep_ms(500);
}
}MicroZig's HAL names change between releases, so treat identifiers like gpio.num as the shape of the API rather than a fixed contract, and check the examples in the repository for your version. The part that is stable is the build:
zig build(output: zig-out/firmware/blinky.uf2 and blinky.elf)Ada
Ada projects use Alire, the package manager, and GNAT, the compiler. A board support crate supplies the startup and drivers, and the program is a procedure:
with RP.Device;
with RP.Clock;
with RP.GPIO;
with Pico;
procedure Blinky is
use RP.GPIO;
begin
RP.Clock.Initialize (Pico.XOSC_Frequency);
RP.Device.Timer.Enable;
Pico.LED.Configure (Output);
loop
Pico.LED.Set;
RP.Device.Timer.Delay_Milliseconds (500);
Pico.LED.Clear;
RP.Device.Timer.Delay_Milliseconds (500);
end loop;
end Blinky;alr buildThe packages RP.Device, RP.Clock and Pico come from the rp2040_hal and pico_bsp crates; the Alire build post shows how to add them. As with Zig, package names belong to the crate and can change, so read the crate's README for the version you install.
Toolchains: what you install and what you get
TinyGo needs the tinygo binary and a matching Go installation, because it reuses the Go front end. It links through LLVM and its own runtime. Flashing uses the board's bootloader, or OpenOCD for chips that need it.
Zig needs only the zig binary. It compiles C and Zig together with the same cross compiler, so a vendor HAL written in C can be built by the same command, and no arm-none-eabi-gcc is installed. The output is an ELF file; converting to UF2 or binary needs a tool, which MicroZig bundles.
Ada needs GNAT for the target. Alire installs gnat_arm_elf for Arm bare metal, along with gprbuild, so a fresh machine needs one download and no manual path setup. The compiler is the GCC front end for Ada, so the machine-code quality is that of GCC, and the linker and binutils are the standard GNU ones.
A practical consequence: if your CI image already has arm-none-eabi-gcc, Ada fits in with one more package; TinyGo needs two installs; Zig needs one self-contained archive.
Memory models
TinyGo: a collector you can turn off
Go allocates on the heap whenever a value escapes. TinyGo keeps that model and supplies a small garbage collector, selected with the -gc flag: conservative is the default on most targets, leaking allocates and never frees, and none removes the allocator entirely so any heap allocation fails at link time. The GC comparison post explains when each is safe. The practical rule is to allocate everything you need at start-up, with fixed-size arrays and slices created once, and then run allocation-free.
A fixed buffer in TinyGo is plain Go:
package main
var rx [64]byte
var rxLen int
func push(b byte) bool {
if rxLen == len(rx) {
return false
}
rx[rxLen] = b
rxLen++
return true
}
func main() {
for i := 0; i < 70; i++ {
push(byte(i))
}
println("stored", rxLen)
}stored 64Package-level arrays live in .bss, so no allocator is involved. The bounds check on rx[rxLen] is real but cannot fail here because of the guard above it.
Zig: allocators are arguments
Zig has no hidden allocation. A function that may allocate takes an std.mem.Allocator parameter, so you see it in the signature. On a microcontroller the usual choice is a fixed buffer allocator over a static array:
const std = @import("std");
var heap: [1024]u8 = undefined;
pub fn main() !void {
var fba = std.heap.FixedBufferAllocator.init(&heap);
const a = fba.allocator();
const nums = try a.alloc(u32, 8);
defer a.free(nums);
for (nums, 0..) |*n, i| n.* = @intCast(i * i);
var sum: u32 = 0;
for (nums) |n| sum += n;
std.debug.print("sum {}\n", .{sum});
}sum 140The sum of squares from 0 to 7 is 0 + 1 + 4 + 9 + 16 + 25 + 36 + 49, which is 140. On bare metal std.debug.print has no standard error to write to; real firmware logs through a UART writer instead, as the MicroZig post shows. If the buffer runs out, alloc returns error.OutOfMemory, and the try propagates it. Nothing is lost silently.
Ada: static by default
Ada embedded runtimes mostly avoid the heap. Objects are declared in the scope that needs them, arrays carry their bounds, and the stack depth is analysable. The heap exists (new), but the zero-footprint and Ravenscar runtimes either omit it or restrict it.
procedure Buffers is
type Index is range 0 .. 63;
Rx : array (Index) of Character := (others => ' ');
Length : Natural := 0;
procedure Push (C : Character; Ok : out Boolean) is
begin
if Length > Natural (Index'Last) then
Ok := False;
else
Rx (Index (Length)) := C;
Length := Length + 1;
Ok := True;
end if;
end Push;
Ok : Boolean;
begin
for I in 0 .. 69 loop
Push ('x', Ok);
end loop;
end Buffers;The array is indexed by a type whose range is 0 to 63, so an out-of-range index raises Constraint_Error rather than writing past the end, and Index'Last documents the limit in the type instead of in a comment. After the loop, Length is 64.
Concurrency and interrupts
A firmware program needs to do several things at once. The three languages answer in three ways.
TinyGo offers goroutines. On a single-core microcontroller they are scheduled cooperatively by the TinyGo runtime, switching at channel operations, time.Sleep, and runtime.Gosched(). A goroutine in a tight loop starves the rest. The scheduling rules are in the scheduler post, and interrupt handlers use Pin.SetInterrupt, shown in the interrupts post.
Zig has no tasking in the language. You write interrupt handlers as functions with the right calling convention, place them in a vector table, and structure the main loop yourself, or you use an RTOS through @cImport. The vector table post shows the handler form.
Ada has tasks and protected objects built in, with the Ravenscar and Jorvik profiles limiting them to a subset that has a bounded, analysable execution model. A periodic task is a few lines:
with Ada.Real_Time; use Ada.Real_Time;
package body Periodic is
task Sampler with Priority => 2;
task body Sampler is
Next : Time := Clock;
begin
loop
-- read the sensor here
Next := Next + Milliseconds (100);
delay until Next;
end loop;
end Sampler;
end Periodic;delay until sleeps to an absolute time, so the period does not drift, which is the property you usually have to build by hand in C or Python. Interrupt handlers are protected procedures attached with Attach_Handler, and they are covered in the Ada tasking post.
Safety features compared on one bug
The quickest way to see the difference is to write the same mistake in each language: an index one past the end of an array, and a sum that overflows an 8-bit counter.
In C both are silent. The write corrupts whatever follows the array, and the unsigned counter wraps from 255 to 0 without a word.
In TinyGo, the index is checked at run time and the program panics with panic: runtime error: index out of range, printed on the serial console if one is configured, and the board then halts or resets depending on the target's panic handler. Integer overflow is defined in Go as wraparound for every integer type, so the counter wraps from 255 to 0 as in C, with no check. Go catches the memory error and leaves the arithmetic error to you.
In Zig, safety depends on the build mode. In Debug and ReleaseSafe the compiler inserts checks for out-of-bounds access, integer overflow, and unreachable code, and a violation calls the panic handler, which your firmware defines. In ReleaseFast and ReleaseSmall the checks are removed and the same bug is undefined behavior. When you want wraparound on purpose, you say so with the +% operator, and @addWithOverflow returns both the result and an overflow bit. The debug build of a firmware image is often too large for a small flash, so the pragmatic workflow is ReleaseSafe for most of the work and ReleaseSmall for the final image once the tests pass.
In Ada, both mistakes raise Constraint_Error by default, because the index type and the counter type carry their limits. A counter declared as type Count is range 0 .. 255 fails when it passes 255, and a modular type, type Count is mod 256, wraps by declaration. The language forces you to choose between the two behaviors at the type declaration. On bare metal the exception handling is usually reduced by the runtime, and the usual configuration is to map a failed check to a call of Last_Chance_Handler, a procedure you write that logs or resets. That keeps the check and drops the exception machinery.
The summary is a spectrum. TinyGo stops memory errors but not arithmetic ones. Zig stops both in safe builds and neither in fast builds, and you decide. Ada stops both in every build unless you turn checks off with a pragma, and it is the language where the reader of the code can see the limits in the type.
Calling C from each language
Firmware rarely starts from nothing: a vendor HAL, an RTOS or a radio stack is in C. The three languages differ most in how easy it is to use it.
Zig: import the header
Zig can read C headers directly. Add the include path in build.zig, then:
const c = @cImport({
@cInclude("stm32f4xx_hal.h");
});
pub fn main() void {
_ = c.HAL_Init();
while (true) {
c.HAL_GPIO_TogglePin(c.GPIOA, c.GPIO_PIN_5);
c.HAL_Delay(500);
}
}@cImport translates declarations on the fly, so the HAL functions and macros that expand to constants are available as c.NAME. Macros that expand to expressions with casts and pointer arithmetic, which are common in vendor register headers, sometimes fail to translate, and then you wrap them in a small C file. The Zig HAL post covers those cases. The same build compiles .c files with addCSourceFiles, so no separate C toolchain is needed.
Ada: Import and Convention
Ada binds to C by declaring a procedure and saying how it is implemented:
package HAL is
function HAL_Init return Integer
with Import, Convention => C, External_Name => "HAL_Init";
procedure HAL_Delay (Ms : Interfaces.Unsigned_32)
with Import, Convention => C, External_Name => "HAL_Delay";
end HAL;You write the declarations, or generate them with GNAT's -fdump-ada-spec option, which reads a C header and emits an Ada specification. The binding is explicit, so you decide which parts of the C API the Ada code may see. The cost is typing; the benefit is that the rest of the program uses Ada types, with ranges, instead of raw C ones.
TinyGo: limited, by design
TinyGo can import C code through a cgo-like preamble, and it supports inline assembly through device/arm and the device.Asm function covered in the C and assembly post. It is the weakest of the three for large C libraries, because the preamble supports a subset of what cgo handles on desktop. The usual approach is to use TinyGo's own machine and drivers packages for peripherals, and to write C only for a small kernel that has no Go equivalent.
Size and speed: what to measure
Never choose by a number found in a blog post. Choose by building your own firmware both ways and reading the section sizes.
For TinyGo, tinygo build -size short -target=pico main.go prints a line with flash and RAM use, and -size full breaks it down by package. For Zig and Ada, run arm-none-eabi-size or llvm-size on the ELF file, and read the three columns, text, data and bss. Flash use is text + data; RAM use is data + bss.
Three effects dominate the difference between languages, and each one is a reason to read the map file rather than guess.
The runtime. TinyGo includes a scheduler, a collector and part of the runtime support for strings, maps and interfaces, and each piece is linked only if used. An Ada program on a zero-footprint runtime links almost nothing extra. A Zig program links what it uses and nothing else, since the standard library is compiled from source.
Formatting.
printlnin TinyGo,std.fmtin Zig andAda.Text_IOeach pull in code to convert numbers to text, which is often the largest single contributor to a small image. Replace them with a hand-written routine, as in the post on printing fixed-point values.Optimization level. TinyGo's
-opt=zand Zig'sReleaseSmalloptimize for size, and-Osdoes the same in GNAT. A size-optimized build is often the only one that fits on a 64 KB part.
Testing and debugging
Host-side testing is where these languages differ most from the C habit of testing on the board.
Go's testing package runs on the desktop. If you keep the logic in functions that do not touch machine, go test works unchanged, and tinygo test runs the same tests with the TinyGo compiler, which catches differences in the runtime. Hardware access goes behind an interface with a fake in the test.
Zig has test blocks in the source file and zig test or the test step in build.zig. Because comptime lets a driver be generic over its register block, you can instantiate it over a plain struct of integers in a test:
const std = @import("std");
fn Ring(comptime T: type, comptime N: usize) type {
return struct {
buf: [N]T = undefined,
head: usize = 0,
len: usize = 0,
fn push(self: *@This(), v: T) void {
self.buf[(self.head + self.len) % N] = v;
if (self.len < N) self.len += 1 else self.head = (self.head + 1) % N;
}
};
}
test "ring overwrites the oldest value" {
var r = Ring(u8, 3){};
for ([_]u8{ 1, 2, 3, 4 }) |v| r.push(v);
try std.testing.expectEqual(@as(usize, 3), r.len);
try std.testing.expectEqual(@as(u8, 2), r.buf[r.head]);
}All 1 tests passed.Ada has AUnit for unit tests and GNATtest to generate harnesses from specifications, and because GNAT also targets the host, the same package compiles for both. SPARK adds a third kind of check, proof instead of test, covered in the posts on SPARK.
On the board, all three work with GDB over a debug probe. OpenOCD or pyOCD exposes the target, arm-none-eabi-gdb loads the ELF, and DWARF information from LLVM or GCC gives source-level debugging. TinyGo includes debug information by default, and the -no-debug flag removes it, which you may do for the final image.
Ecosystems and drivers
A language is only as useful as the chips and sensors it supports.
TinyGo has the broadest hobbyist coverage. The machine package supports dozens of boards, and the separate tinygo.org/x/drivers repository holds drivers for sensors, displays and radios written in Go against machine.I2C and machine.SPI. Reading a sensor from it is usually a dozen lines, as in the TinyGo I2C post.
Zig's embedded ecosystem is younger. MicroZig supplies chip support, HALs and a build system, and covers RP2040, STM32, nRF52, AVR and other families to varying depth. Because Zig builds C beautifully, vendor C drivers fill the gaps.
Ada's strength is its libraries for safety-critical work: the Ada Drivers Library and the Alire index have board support for STM32 and RP2040, and vendors such as AdaCore support the toolchain commercially for avionics and rail, where Ada has a long record. The sensor and display driver selection is smaller than TinyGo's.
What runs before main
A microcontroller does not start at main. On reset an Arm Cortex-M core reads two words from the start of the vector table: the initial stack pointer and the address of the reset handler. The reset handler copies the initialized data from flash into RAM, zeroes the .bss section, sets up the clocks on some parts, and only then calls the program. In C the vendor supplies this as startup.s and a linker script. The three languages split the job differently, and knowing who owns it tells you where to look when a new board does nothing.
TinyGo owns startup completely. Each target file names a linker script and a start-up assembly file, and the runtime then initializes the heap, the scheduler and package-level variables before running main.main. You write no start-up code, which is also why you cannot change it without forking the runtime.
Zig owns nothing by default. The freestanding operating system tag means there is no runtime at all, so you supply the vector table as an exported array, the reset handler as a function, and a linker script. MicroZig packages all three per chip, and a project that uses it behaves like TinyGo in this respect. A project that does not use it writes about 40 lines of Zig for the vector table and the reset handler, which is a good exercise for understanding the machine.
Ada depends on the runtime. A zero-footprint runtime provides the start-up code, the linker script and little else. A Ravenscar runtime adds the tasking kernel, which initializes the scheduler before elaborating your packages. Package elaboration is an Ada concept with no C equivalent: before the main procedure runs, every package body's initialization code runs in dependency order, which is where global objects get their initial values.
The test for ownership is the question, "what happens if main returns?" In C the behavior depends on the startup file, usually an infinite loop. In TinyGo the runtime halts or exits to the board's idle loop. In Zig a freestanding main returning falls into whatever follows it in memory unless you wrote a loop, which is why bare-metal Zig examples end with while (true) {}. In Ada, a main procedure that returns reaches the runtime's finalization and then an infinite loop in the last-chance handler or the startup file.
Registers in each language
Everything on a microcontroller eventually reduces to reading and writing memory-mapped registers, so the way a language expresses that determines how readable a driver is.
TinyGo gives you generated register definitions in the device packages, produced from the vendor's SVD file, with fields such as rp.IO_BANK0.GPIO25_CTRL. The machine package wraps them, so most programs never touch them. Writing to a register uses methods like .Set() and .SetBits(), which the compiler treats as volatile accesses.
Zig expresses a register as a pointer to a volatile integer, and the MicroZig chip packages generate typed structs from SVD files too. A hand-written access is:
const GPIOA_ODR: *volatile u32 = @ptrFromInt(0x4002_0014);
pub fn setPin5() void {
GPIOA_ODR.* |= (1 << 5);
}@ptrFromInt turns an address into a pointer, and the volatile qualifier tells the compiler that every read and write matters. The underscore in the literal is a readability aid. The address 0x4002_0014 is the output data register of GPIO port A on an STM32F4 part, and a different chip uses a different address, which is the reason to generate these from SVD files.
Ada expresses registers with representation clauses, which place a record's fields at exact bit positions and the object at an exact address:
with System;
with Interfaces; use Interfaces;
package Reg is
type Output_Register is record
Pin5 : Boolean;
end record
with Volatile_Full_Access, Size => 32;
for Output_Register use record
Pin5 at 0 range 5 .. 5;
end record;
GPIOA_ODR : Output_Register
with Address => System'To_Address (16#4002_0014#), Import;
end Reg;Writing GPIOA_ODR.Pin5 := True; then updates bit 5 of that address with a read-modify-write, and the Volatile_Full_Access aspect tells the compiler to do it as one 32-bit access. The type is the documentation: a reader sees the bit layout in the declaration and not in a mask in the code. The cost is verbosity, which tools such as svd2ada remove by generating these declarations from the SVD file.
Strings, formatting and logging
Text output is the usual way a newcomer discovers their program is too big. Converting an integer to decimal digits, or a float to a string, pulls in code that can exceed the rest of a small program.
TinyGo's println is a built-in that writes to the target's default serial output, and it handles integers, strings and booleans without linking fmt. The fmt package works but adds substantial size, so keep it for boards with plenty of flash. On many targets the default output is USB serial, so a board without USB needs machine.UART0 and a configured baud rate.
Zig's std.fmt is compiled from source and links only the formatters you use, because the format string is known at compile time and comptime generates exactly the code required. A {d} specifier for an integer costs far less than a general-purpose printf, and a format string with a typo is a compile error. You still supply the writer, usually a small struct that wraps a UART's transmit function.
Ada's Ada.Text_IO needs a runtime with I/O support, and most embedded runtimes lack it or provide a minimal version. The usual approach is a board-support package with a Put_Line that writes to a UART, or the GNAT.IO package in light runtimes. Integer'Image (N) converts a number to a string and allocates a temporary on the stack, which is fine for logging and unsafe in a deeply nested call.
Whatever the language, the advice is the same: decide how the firmware reports state before the first bug. A single log(level, message) function that writes to a UART lets you replace it later with a ring buffer that a debugger reads, or with nothing in the release build.
Build systems and reproducibility
A firmware project is only as maintainable as its build.
TinyGo needs one command per build and reads configuration from flags, with board definitions in JSON files in the TinyGo installation. Pin the version by recording the TinyGo and Go versions in your CI image.
Zig's build.zig is Zig code that declares the targets, the source files, the linker script and any post-processing steps. It is the most flexible of the three, and it handles C dependencies, code generation and multiple targets in one file. The Zig version matters because the build API changes between releases. Commit the version to a .zigversion file or a tool such as zigup, and run the build in CI from a pinned download.
Ada projects use a GPR project file for GNAT and an alire.toml manifest for dependencies. Alire locks dependency versions in alire.lock, which makes builds reproducible without extra tooling. A GPR file describes the source directories, the switches for each build mode and the linker script.
The last concern is the reproducibility of the toolchain. Containerizing the build, with the compiler version in the image, matters more than which language you pick, because an unpinned compiler is the most common reason a firmware image differs between two engineers' machines.
Which language for which person
| You are | Pick | Because |
|---|---|---|
| A Go developer who wants a first microcontroller project | TinyGo | Syntax, tooling and go test carry over, and the driver library is large |
| A C programmer who wants better tooling without changing mental model | Zig | Same memory model, explicit allocation, a build system that replaces Make, and C interop |
| An engineer on a product where a fault has a cost and a certification | Ada, possibly with SPARK | Strong typing, tasking with a bounded model and formal proof |
| Someone with a 16 KB part | C, Zig or Ada | TinyGo's runtime is large for tiny devices |
| A team with years of vendor-specific C code and a deadline | C, calling Zig from it | Rewrites cost more than they return in the first year |
Who this guide does not fit
Teams on a part with 8 KB of RAM or less. Go's runtime and the standard formatting libraries consume a large share of that, and the AVR and small Cortex-M0 targets are better served by C, Zig or an Ada zero-footprint runtime.
Hard real-time work measured in microseconds. TinyGo's cooperative scheduler and collector make worst-case timing hard to bound. Use Ada's Ravenscar tasks or hand-written interrupt handlers in Zig or C, and keep Go for the supervisory code.
Projects that must follow MISRA C or a certified compiler. None of the open-source toolchains here carries a qualification by itself. Ada has qualified commercial compilers, and that is usually the reason a certified project adopts it.
Programs that depend on a vendor RTOS and its tooling. FreeRTOS, Zephyr and the vendor IDEs assume C. You can call them from Zig or Ada, but the debugging and configuration tools will still show C, and the friction can outweigh the language benefit.
A path through the posts
A reader new to all three should start with the beginner posts, which build and flash a first program: the TinyGo Pico blinky, the Zig cross-compile post, and the Alire build post. The intermediate posts add sensors, interrupts and tasking in each language, and the comparison posts, such as TinyGo versus C, put numbers on the trade by method. The advanced and expert posts go into the schedulers, comptime register generation, and SPARK proofs.
Worked scenario: a data logger
Take a battery-powered logger that samples a temperature sensor every second, stores 24 hours of readings, and sends a summary over a UART once an hour. The design is the same in all three languages; what differs is how the language helps.
The sample buffer is 86,400 entries, which at two bytes each is 172,800 bytes, too big for most microcontrollers, so the design stores a reading every minute: 1,440 entries and 2,880 bytes. That arithmetic is the first design check, and Ada's type system encodes it: type Minute_Index is range 0 .. 1_439; makes any index outside the buffer a compile-time or run-time error. In Zig the same is [1440]i16, with a bounds check in safe builds. In TinyGo it is var log [1440]int16, a package-level array, so nothing touches the heap.
The sampling loop needs a steady period. In Ada, a task with delay until gives a drift-free period. In TinyGo, a goroutine with time.Sleep(time.Minute) drifts by the work done in each pass, so you compute the next deadline from a ticker, time.NewTicker, which compensates. In Zig you read a hardware timer in the main loop or configure an interrupt.
The hourly summary needs the minimum, maximum and mean over 60 values. Written with fixed-point maths, as in the fixed-point guide, it avoids floating point and its library cost. It is the same arithmetic in every language.
Power matters too. All three can put the core to sleep between samples: TinyGo through machine and device/arm calls to wfi, Zig through inline assembly asm volatile ("wfi"), and Ada through machine-code insertion with System.Machine_Code. The sleep instruction is the same; the language only wraps it.
Common failure modes
| Symptom | Likely cause | Fix |
|---|---|---|
| Program builds but the board does nothing | Wrong target or pin number for the board variant | Check the board's pin definition; the Pico W LED is not GPIO 25 |
| TinyGo image is larger than flash | fmt or maps pulled in | Replace fmt with println or a hand-written printer; build with -opt=z |
| Zig program faults at start-up | No vector table or wrong linker script | Use MicroZig or supply .vector_table and the memory regions |
Ada program raises Constraint_Error on first run | A range that is too narrow for real data | Widen the type or validate input before conversion |
| Debugger shows no source lines | Debug information stripped | Build with debug info and load the ELF, not the UF2 |
| Goroutine never runs | Another goroutine never yields | Add a sleep or channel operation, or call runtime.Gosched() |
Reading a crash in each language
Sooner or later a program hits a fault, and the language decides how much the crash tells you.
A Cortex-M core raises a HardFault when code dereferences an invalid address, executes an undefined instruction, or divides by zero on a part configured to trap. In C the symptom is a board that stops, and the cause is somewhere in the registers saved on the stack by the fault handler. All three languages inherit that behavior for the faults that come from hardware, and add their own, earlier, software checks on top.
In TinyGo, a failed bounds check, a nil pointer use, or an explicit panic calls the runtime's panic routine, which prints the message and a location to the default serial output and then halts. The message names the kind of error, such as an index out of range, which is more than a bare HardFault gives you. Read the serial console before attaching a debugger.
In Zig, the panic handler is a function you can override by declaring pub fn panic in the root source file. The default handler is intentionally small. A useful embedded override writes the message to a UART, saves it to a retained RAM region that survives a reset, and then resets the chip, so a field unit reports its last failure on the next boot. Because safety checks vanish in the fast build modes, a crash in release may have no message at all, and the way to find it is to reproduce the problem in ReleaseSafe first.
In Ada, a failed check raises an exception, and on a minimal runtime the exception is replaced by a call to __gnat_last_chance_handler, which you define. The handler receives the source file name and line number of the failed check, so even a stripped-down runtime tells you which line failed. That information costs flash, since the file names are stored as strings, and the pragma Restrictions (No_Exception_Propagation) selects the cheaper behavior.
The common thread is to catch the failure in software where possible, with a message, and to reserve the register dump for the faults software cannot see. Whichever language you pick, wire the panic or last-chance path to the same output channel as your normal log from the first day, and test it by triggering a failure on purpose before relying on it.
Choosing for your next project
Start from the constraint that cannot move. If it is the part's memory, choose from Zig, Ada and C. If it is a certification, choose Ada. If it is team familiarity with Go and a fast first prototype, choose TinyGo. If it is gradual adoption inside an existing C codebase, choose Zig, because it compiles the C you already have. Whichever you pick, write the first version of the build and the first test before the first feature, since a language is easier to judge from a working loop of edit, build, flash and test than from its feature list.


