Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

OptionProsCons
Rust + SDL2Fast, small binaries, SDL2 already on deviceMust cross-compile from macOS
Python + PygameEasy developmentLarge runtime, slow startup
C + SDL2Fastest, smallestManual memory management, slower development
GodotRich UI, visual editorToo heavy for simple app, overkill
Love2D (Lua)Simple, proven for gamesLua 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.