←back to thread

Introducing tmux-rs

(richardscollin.github.io)
857 points Jtsummers | 5 comments | | HN request time: 0.21s | source
Show context
starchild3001 ◴[] No.44460169[source]
This is a fantastic write-up of a truly monumental effort. I have huge respect for the author's persistence. The line "Like gardening, but with more segfaults" really resonates. It’s this kind of deep-dive hobby project where you learn the most.

The experience with `c2rust` is particularly interesting. It reminds me of a similar shift I saw years ago with automatic code translators between other languages. They're incredible for getting a project off the ground and proving feasibility, just as the author found, but you often end up with code that's completely "un-idiomatic" for the target language. The decision to throw it all away and do a manual port, while surely gut-wrenching, was the right call. You just can't automatically translate the intent of the original C code into safe, idiomatic Rust.

The "Interesting Bugs" section gave me flashbacks. Bug #2, with the mismatched struct layout due to a missing `*`, is a classic FFI (Foreign Function Interface) nightmare. I once spent the better part of a week debugging a similar issue between C++ and C# where a single change in struct packing alignment was silently corrupting data downstream in very subtle ways. It's one of those bugs that makes you question your sanity. Finding that requires some serious debugging grit, so kudos to the author.

This project is a great case study in the real-world challenges of modernizing critical infrastructure code. The author mentions the next big goal is to convert the codebase from `unsafe` to safe Rust. I'm really curious about the strategy for that.

Refactoring away the raw pointers and complex control flow (like the `goto` patterns) into safe, idiomatic Rust without breaking everything seems like it would be even more challenging than the initial port. Will the approach be to introduce lifetimes and the borrow checker module-by-module? And what's the plan for the intrusive data structures? Replacing them with standard library collections like `BTreeMap` is the obvious choice, but I wonder if that will have performance implications that the original intrusive design was meant to avoid.

In any case, amazing work. Thanks for sharing the journey in such detail. I'll be following this project on GitHub for sure.

replies(2): >>44460948 #>>44463452 #
johnisgood[dead post] ◴[] No.44463452[source]
[flagged]
Touche ◴[] No.44463712[source]
This person built a really cool project and documented how and you're throwing negative predictions about it for no reason. No one is down voting your opinions on OpenBSD
replies(1): >>44463768 #
johnisgood[dead post] ◴[] No.44463768[source]
[flagged]
ga_to ◴[] No.44463823[source]
But it's _not_ c2rust. It started that way but this approach was abandoned in favor of a manual port. From the comment you replied to: > The decision to throw it all away and do a manual port, while surely gut-wrenching, was the right call. You just can't automatically translate the intent of the original C code into safe, idiomatic Rust.

From the second paragraph of TFA: > I threw away all of the C2Rust output and decided I would translate all of the files into Rust manually from C.

Please at least read the source before shit-talking it.

replies(1): >>44463929 #
johnisgood[dead post] ◴[] No.44463929[source]
[flagged]
1. ga_to ◴[] No.44464097[source]
I usually don't comment because I am fine with reading stuff on here during my breaks and don't engage in discussions. Your poo-pooing of a hobby project that has no ambitions of being enterprise grade really rubbed me the wrong way though. If it brings you joy to call me a bot, go ahead though.
replies(2): >>44464214 #>>44474355 #
2. ◴[] No.44465299[source]
3. kbenson ◴[] No.44466962[source]
Everyone's gotta start some time. My first comment wasn't until almost exactly a year after I finally made an account (according to search, but that lines up with my memory), and I didn't even create an account until I had been reading for a couple years IIRC.

I think it's often people that have an emotional response that make their first comment if they've been a lurker for a while already.

FWIW I think people are reacting negatively to you is because you've done the equivalent of walk into a community center where someone is showing their hobbyist art project and loudly proclaimed all the problems and that you'll be more interested when they fixed it up enough to make it to a real gallery. Not only is that person missing much of the point of why that person did it and judging it by standards it was never intending to strive for, but doing so around others that are there to appreciate it for what it is actually hampers their enjoyment and the empathic happiness they feel for someone striving to do something for the fun of it.

In other words, most people don't really care if this materializes as an actual product or project that's widely usable. It's a cool hobby project and some of us appreciate that, and appreciate people documenting their process in doing such things.

replies(1): >>44471020 #
4. johnisgood ◴[] No.44471020{3}[source]
Thanks for the explanation. However, do you think that the author is going to learn Rust this way? You should honestly check out the source code. I do not think that this is in any way educational if the aim is to learn Rust. Maybe the aim is not that, but then why Rust? It could have been done in Forth, too.
5. johnisgood ◴[] No.44474355[source]
For the record, even my https://news.ycombinator.com/item?id=44464177 comment was flagged, along with EVERY single post under this submission.

See the parent of this comment, which is of course, not flagged.

Amazing times we live in.