The Magic Behind Cubacadabra
5 days ago
- The article advocates moving shared application logic into Rust to avoid duplicating code across iOS, Android, and web clients.
- A username field can use native UI controls (SwiftUI, Compose, HTML input) but forwards edits to Rust for validation and state management.
- Examples like Litter and Mozilla's shared Rust components show successful precedents for this architecture.
- A native app ABI uses seven C functions (create, destroy, dispatch JSON, etc.) to bridge Rust and host platforms.
- Client extraction removed repetition in socket message translation, session handling, and network outbox draining.
- Rendering uses wgpu shared across platforms, with surface lifetimes and input handled by each host.
- A new morphs crate allows adding content (e.g., hats) without changing engine code, with validation via sidecar files.
- Games run Luau scripts that expose a shared API, allowing game logic changes without client or backend coordination.
- The ultimate goal is that adding a new platform only requires a thin shell, not reimplementing all product logic.