ADR 0001: Rust + SDL2 for Handheld Development
Status
Accepted
Context
We need to build a flashcard app for the Anbernic RG35XXSP (aarch64 Linux, 1GB RAM, 640×480 screen). The device runs Knulli, a Batocera fork with SDL2 pre-installed for emulators.
Options considered:
| Option | Pros | Cons |
|---|---|---|
| Rust + SDL2 | Fast, small binaries, SDL2 already on device | Must cross-compile from macOS |
| Python + Pygame | Easy development | Large runtime, slow startup |
| C + SDL2 | Fastest, smallest | Manual memory management, slower development |
| Godot | Rich UI, visual editor | Too heavy for simple app, overkill |
| Love2D (Lua) | Simple, proven for games | Lua runtime overhead, less type safety |
Decision
Use Rust with SDL2.
Consequences
Positive
- Binary size: ~500 KB (vs Python’s ~50MB+ runtime)
- Startup time: Instant (vs Python’s import overhead)
- Memory usage: <20 MB total (fits comfortably in 1GB)
- SDL2 is already on Knulli — no additional runtime deps
- Type safety prevents common C bugs
Negative
- Cross-compilation from macOS requires Docker (SDL2 library format mismatch)
- Rust compile times are slower than Python
- Smaller ecosystem than Python for some tasks
Notes
The SDL2 window/renderer API is low-level but sufficient for a flashcard app. We don’t need GPU acceleration or complex UI widgets. The sdl2 crate provides safe bindings and sdl2_ttf handles text rendering.