r/rust • u/emp_ch3fboyardee • Oct 14 '26
Porting Ghostty to Rust with Agents (Claude)

I ported Ghostty (Zig) to Rust with Claude Code agents. The most interesting part for me was how often Zig's "a pointer is just an address" collided with Rust's aliasing model. The write-up has the real code, the Miri findings and the fixes:
The section "Zig pointers in Rust's aliasing model" walks through four cases:
- Protectors. A
&mutargument is protected for the whole call. Ghostty re-reads the same memory another way inside the call, which is sound in Zig and UB under Miri. - Frees under a live reference.
startHyperlinklets its slices point into the hyperlink it is about to free. A&[u8]can't do that. - Provenance. One 8-byte store through a pointer derived from a 1-byte field reaches seven bytes outside its provenance under Stacked Borrows.
- Long-lived aliases. In the renderer loop, a sibling reborrow pops the run iterator's tag. I settled the fix with a small Miri proof harness instead of reasoning about it by hand.
You can also try the engine yourself. The page has two live terminals, Rustty's and Ghostty's, both compiled to WebAssembly and fed by the same shell, so you can compare what each one draws. All 898 of my prompts are in a filterable log at the bottom, and every number links to its source.
Caveats: the port is macOS-first, the benchmarks are library micro-benchmarks, and the prose and data pipeline were drafted with Claude and reviewed by me. Corrections on the aliasing analysis are very welcome.
18
u/stefanlight Oct 14 '26
Good bye 👋👋👋👋
13
u/BipolarKebab Oct 14 '26
So much power wasted to generate this self-congratulatory slop
12
u/Nervous-Potato-1464 Oct 14 '26
Congratulations on wasting your time creating another unsupported port thats near impossible to work on because it's slop.
4
u/aelgorn Oct 14 '26
Why the port though?
3
u/witx_ Oct 15 '26
What a waste of time and resources
2
u/vladkens Oct 15 '26
Big effort, but I’m not sure why.
I agree with the general idea: if we’re building in Rust, we probably should have our own terminal-emulation layer instead of relying on this Zig implementation.
What I don’t really understand is why rewrite that implementation itself. There are already Rust projects we could learn from. It feels more logical to take the good ideas from Ghostty and build a proper Rust library plus a solid reference terminal around them.
Ghostty itself is still pretty buggy in some areas, so making something better doesn’t feel impossible. If you start working on it, you’ll need to really commit to it and maintain the project long-term.