[Media] Decompiling 700K lines of C# to learn what NOT to do before building a space sim in Rust/Bevy
![[Media] Decompiling 700K lines of C# to learn what NOT to do before building a space sim in Rust/Bevy](https://i.redd.it/a0uudyyudvug1.gif)
Context: Kerbal Space Program just hit 20,000 concurrent players for the first time in its history. The game is experiencing a massive resurgence. It's also a technical disaster held together with duct tape.
So I decompiled all 700k lines of it to study the architecture before building a spiritual successor in Rust.
What I learned from the autopsy:
Part.cs is 9,400 lines. It's responsible for:
- Physics simulation and collision
- Rendering and visual effects
- Resource flow and management
- UI state and interaction
- Serialization and persistence
- Event dispatch and module loading
Classic god class. Performance scales terribly because parts can't be processed in parallel, and Unity's GC pauses wreck framerate during staging events. The physics loop runs single-threaded on one core while the rest of your CPU idles.
The Rust rewrite — Kraken Space Program:
Built on Bevy's ECS to do what the original couldn't:
PartPhysics,PartResources,PartVisualsas separate components — systems run parallel across thousands of parts- Rapier3D for deterministic physics (50 Hz fixed timestep, multiplayer-ready from day one)
f64coordinates with origin shifting (Krakensbane pattern) — solar-system scale without float precision drift- Lua modding API built on top, not fighting the engine
- No GC pauses, real multithreading, native cross-platform
Current status: Phase 0 mostly complete. Bevy app runs, Rapier integrates, a bouncing ball proves the foundation works. CI enforces clean code. Phase 1 target: hardcoded multi-stage rocket reaches orbit.
Architectural challenge I'm solving right now: coordinate systems. Simulation runs in f64 (solar system scale), rendering needs f32 (GPU). I built render_sync.rs as the single conversion point with WorldOrigin shifting to keep render coordinates camera-centered. Open to feedback on this approach.
Why now? The original game is having a renaissance — 20K concurrent players, all-time record, community more active than ever. But everyone playing it right now is also being reminded of its limitations. This is the moment to build what it should have been.
Full design doc, roadmap, and contribution guide in the repo.
GitHub: https://github.com/Kraken-Space-Program/Kraken-Space-Program
Discord: https://discord.gg/6u3djfzMdv
Would love thoughts from Bevy devs or anyone who's tackled large-scale physics sims in Rust.