Rust for services, data CLIs, and native extensions. Same values as everywhere else: simple, explicit dependencies, compose with pipes, JSON on stdout.
Core Principles
- Explicit dependencies: constructors take what they need; no global state,
no
lazy_static/OnceLocksingletons for things like DB pools or clients. - Errors tell a story:
thiserrorfor library error types,anyhowwith.context("what was being attempted")at application boundaries. - Tokio for services, threads for compute: every web service starts on
Tokio + axum from day one. Use threads or
rayonfor CPU-bound work: data-parallel transforms, batch jobs, CLIs with no network I/O. Inside a service, push blocking or CPU-heavy work tospawn_blocking(or a rayon pool) so it doesn't stall the runtime. - mise is the front door:
cargo build,cargo test,cargo clippy, and adevtask usingbaconorwatchexecthat tees tologs/.
References
references/async.md: Tokio's execution model, compared with Go, and cancellation: why any future can stop at any.await, the bugs that causes, and the patterns that prevent them. Read this before writing or reviewing async code.