The author ported tmux’s ~67,000 lines of C code to ~81,000 lines of unsafe Rust as a hobby project.
Starting with C2Rust autogenerated code demonstrated feasibility but resulted in inflated, unmaintainable output, prompting a manual translation.
Integrating Rust with tmux’s autotools build required custom scripts, later simplified by using cargo’s build.rs and the cc crate to compile remaining C.
Common C-to-Rust translation challenges included handling raw pointers, emulating goto logic, interfacing intrusive macros, and replacing the Yacc parser with Lalrpop.
Debugging revealed bugs caused by implicit C declarations truncating pointers and mismatched struct field types between C and Rust.
The development workflow evolved to translate and test one function at a time using Vim macros and occasional AI assistance to speed refactoring.
Although the codebase is now fully in unsafe Rust, the next goal is to improve safety and stability before broader release.
Get notified when new stories are published for "🇺🇸 Hacker News English"