Field Log · Orbit 04 · 2026-11-26
Thin Foreign Boundaries Don't Stay Thin by Accident
How escape hatches quietly grow into application layers, and how Titan's native C FFI type rules push programmers back toward clean, portable boundaries.
Foreign-function bridges almost never start bloated. You add one canvas draw helper, then an event loop, then a styling tweak, and before anyone notices, 500 lines of host glue own the rendering loop and game state while the host language gets demoted to a thin callback stub.
Testing the exact opposite invariant on native C FFI was eye-opening. In
Cassini: Grand Tour, I built a 6-module playable 3D
orbital showcase directly against <SDL3/SDL.h> and <cairo/cairo.h>
with zero custom C glue. When I tried exposing a raw SDL_Surface pointer on an exported
Canvas record, the compiler refused outright: header-defined foreign types stay local to
modules that import their header. Keeping handles inside module-private local fields with
gc.finalizable teardown backup kept five of six modules completely header-free and portable.
Two craft lessons stuck: visual verification catches sign errors immediately (an inverted screen-space winding check turned both planets inside-out on the first render while Saturn's rings were already crisp!), and dogfooding your own language on real graphical programs surfaces both awkward idioms and real compiler edge cases far faster than synthetic unit tests ever do.