The Architecture Demands It
Spacebot has:- Concurrent LLM processes sharing mutable state
- Async coordination between channels, branches, and workers
- Shared memory accessed from multiple processes
- Database connections pooled across tokio tasks
- Message routing across multiple platforms simultaneously
- No human in the loop for most operations
Rust’s Guarantees
Memory Safety Without Garbage Collection
No garbage collector pauses. Predictable latency. When a channel is responding to a user, there’s no mystery pause while Python’s GC runs.Fearless Concurrency
Spacebot spawns hundreds of tokio tasks:- One per channel
- One per branch
- One per worker
- One per messaging adapter
- One for the cortex
- One per compaction worker
- One per cron job
branchis moved into the task (no shared references)event_txis cloneable (explicitlySender<T>isClone)- No data races on shared state
Type System as Documentation
The type system encodes invariants:Error Handling
Errors are values, not exceptions:Performance
Single Binary
No interpreter. No runtime dependencies. Just machine code:Startup Time
Memory Usage
Rust has no GC overhead:Developer Experience
Refactoring Confidence
IDE Support
Rust Analyzer provides:- Go to definition that actually works
- Find all references across the entire codebase
- Type hints everywhere
- Inline errors as you type
- Refactoring tools (rename, extract function, etc.)
Compile-Time Guarantees
If it compiles, it probably works:Ecosystem
Tokio for Async
Tokio is the most mature async runtime:- Work-stealing scheduler — Efficient CPU utilization
- No callback hell — async/await syntax
- Backpressure — Built-in flow control
- Tracing integration — Structured logging and diagnostics
SQLx for Databases
Compile-time checked SQL queries:Serde for Serialization
Zero-cost serialization:What Rust Doesn’t Give You
Slow compile times — Full rebuilds take 2-3 minutes. Incremental builds are fast (seconds), but cold starts hurt. Steep learning curve — Ownership, lifetimes, async, Result types. First few weeks are rough. Smaller ecosystem — Fewer libraries than Python. Sometimes you have to build it yourself. More verbose — Rust code is longer than equivalent Python. Explicit > implicit.Why Not Python?
Python is great for:- Prototyping
- Data science
- Scripts
- Single-threaded tools
- Concurrent systems
- Long-running daemons
- Memory-constrained environments
- Systems where bugs cost money
- Highly concurrent
- Long-running (daemon mode)
- Sharing mutable state
- Running on user servers (not cloud VMs with infinite RAM)
Why Not TypeScript?
TypeScript is better than Python for type safety, but: Still interpreted — V8 JIT is fast, but not as fast as machine code GC pauses — Unpredictable latency Weak type system —any, type assertions, runtime casts everywhere
No compile-time memory safety — Data races are possible
Why Not Go?
Go is actually a decent choice. But: No sum types — Can’t expressResult<T, E> ergonomically
Weak error handling — if err != nil everywhere, easy to ignore errors
No generics until recently — And they’re still limited
GC pauses — Better than Python/Node, worse than Rust
The Bottom Line
Spacebot needs:- Concurrency — Rust’s ownership system prevents data races
- Performance — Single binary, no GC, predictable latency
- Reliability — Compile-time guarantees, exhaustive error handling
- Efficiency — Low memory usage, fast startup
Next Steps
Architecture
See how Rust’s guarantees enable the architecture
Contributing
Read RUST_STYLE_GUIDE.md and AGENTS.md
Tokio
Learn about Rust’s async runtime
Rig
Explore the LLM framework Spacebot uses