←back to thread

Introducing tmux-rs

(richardscollin.github.io)
857 points Jtsummers | 1 comments | | HN request time: 0.206s | source
Show context
mbreese ◴[] No.44455951[source]
> You might be asking: why did you rewrite tmux in Rust? And yeah, I don’t really have a good reason. It’s a hobby project. Like gardening, but with more segfaults.

I love this attitude. We don’t necessarily need a reason to build new things. Who knows what will come out of a hobby project. Thanks to the author for the great write up!

Also, my gardening is full of segfaults, coding a new project is definitely safer to my yard.

replies(15): >>44456003 #>>44456205 #>>44456799 #>>44457023 #>>44457048 #>>44457108 #>>44457783 #>>44458165 #>>44458298 #>>44458461 #>>44459018 #>>44459396 #>>44459476 #>>44459885 #>>44463066 #
cultofmetatron ◴[] No.44456799[source]
> Like gardening, but with more segfaults.

interesting, I'm new to rust. what are you doing that necessitates using unsafe?

replies(2): >>44456889 #>>44457183 #
jeroenhd ◴[] No.44457183[source]
A lot of things that C will let you do (even if you enter the realm of undefined behaviour) will simply not compile to C. As the author states, there are semantic differences between pointers and Rust's references.

C pointers can have as many owners as you want, may be subjected to mathematical operations, and can be cast to any type without even an error message. The compiler will just assume you know what you're doing. If you enable enough compiler warnings, it might warn you, but C compilers don't generate a lot of those by default.

Rust will let you only generate one mutable (exclusive) reference at a time. This means straight C to Rust ports simply don't compile.

By switching to pointers, which work pretty much like their C equivalent, you can port the code much easier, but you do of course lose the benefits of Rust's safety mechanisms, because most pointer operations throw away all the safety guarantee that Rust provides.

replies(3): >>44457388 #>>44459258 #>>44459618 #
SoftTalker ◴[] No.44457388[source]
So what is the advantage of an unsafe Rust implementation? Just to have done it?
replies(5): >>44457474 #>>44457712 #>>44458531 #>>44458900 #>>44459852 #
sedatk ◴[] No.44459852[source]
In addition to other points about making it progressively safe, unsafe Rust is still safer than C. https://bsky.app/profile/ssg.dev/post/3lkjogvm2c222
replies(1): >>44460750 #
1. Nadya ◴[] No.44460750[source]
Rust is like walking across a mine field with all the mines flagged for you. You can dig up the mine and remove the flags over time. Or at least know to avoid stepping carelessly around them.

In C you only see the flags people know of or remembered to plant. There's an awful lot of mines left unflagged and sometimes you step on them.

It's very obvious to me which would be more safe and I find myself questioning why it is isn't so obvious to others.