12 ms·
Introducing tmux-rs
- mbreese 1y ago> 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.
- sherburt3 1y agoI was about to post a snarky comment because I have a knee jerk reaction whenever someone implies a rust application is intrinsically better than C. Sometimes I forget people do things for fun.
- upmind 1y agoI found out that quite funny, I wonder how many hours he spent on this. It seems extremely monotonous haha
- nisegami 1y agoMaybe my understanding of one or more concepts involves is wrong, but that "more segfaults" bit confuses me. Shouldn't the rust compiler prevent code that can segfault from compiling? Unless there was a lot of unsafe blocks involved. Edit: apparently it did turn out to be a lot of unsafe code
- miroljub 1y agoMy understanding is that, even though tmux-rs is written in a safer language, it still can't beat the stability of an old battle-tested well-maintained project written by a group of highly competent developers. Every new project is bound to have bugs that need to be ironed out during the time.
- Ar-Curunir 1y agoIt’s just because there are a lot of unsafes, and because the translation from C to Rust introduced semantic-mismatch bugs
- a_humean 1y agoThey wrote everything in unsafe rust where its very possible to segfault. This is not a normal C to Rust port. In a normal port you would never aim to have 100% unsafe rust code - rather you would hive off small parts of your application where you need unsafe so its highlighted and auditable. This is clearly an excerise for fun.
- nicoburns 1y agoI think it is a normal porting process, it's just only half-finished at this point. The conversion to safe Rust is yet to come.
- antonvs 1y agoNo, the issue is that doing a direct translation from a fundamentally unsafe language like C can't fix safety issues. You'd have to do a proper rewrite, in which case you could write safe code from the start. > Every new project is bound to have bugs that need to be ironed out during the time. Not on the level of the kind of critical security and reliability bugs that unsafe languages foster. That's why CISA and the FBI both strongly recommend memory-safe languages.
- cultofmetatron 1y ago> Like gardening, but with more segfaults. interesting, I'm new to rust. what are you doing that necessitates using unsafe?
- tshaddox 1y agoI suspect it's vastly easier to port C to unsafe Rust than to safe Rust.
- jeroenhd 1y agoA 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.
- SoftTalker 1y agoSo what is the advantage of an unsafe Rust implementation? Just to have done it?
- cuu508 1y agoFrom the article: "The next goal is to convert the codebase to safe Rust."
- petrzjunior 1y agoIt is rewritten to a different language and many people find Rust easier to read, it has better type hint support for IDE etc. Also, you do not lose all the safety, there are still many rules enforced, such as safe linking, no undefined functions. Unsafe Rust means that all parts of code which do illegal pointer magic are explicitly marked with an "unsafe" keyword. You can now go one by one and fix them.
- planet36 1y ago"Gardening is the handiest excuse for being a philosopher." - Ray Bradbury, Dandelion Wine
- vpShane 1y ago> You might be asking: No, not at all. Rewrite all the things in Rust. if you enjoy it, do it. It leads to learning and learning leads to new innovation. If you enjoy making it in Rust, then I'll enjoy trying it out.
- tombert 1y agoCompletely agree. Not every project has to be out there to change the world. I recently rewrote `fzf` [1] in Rust. Did I have any particular reason to do so? No, not really, regular `fzf` is fine, but I thought it would be a fun excuse to learn how fuzzy search algorithms work and how to exploit the channels in Rust. It was fun. There's no question that regular fzf is better but that wasn't the point, the point was to play with stuff and learn. [1] https://github.com/Tombert/rs-fzf-clone https://github.com/Tombert/rs-fzf-clone
- carlmr 1y agoNice, I do think fzf is a really good candidate for something that could be better if written in Rust. The fzy[1] C-rewrite is really fast, but I couldn't get it to give me as useful results when searching bash history. [1] jhawthorn/fzy: :mag: A simple, fast fuzzy finder for the terminal https://share.google/TBp3pVaFngBTfaFyO https://share.google/TBp3pVaFngBTfaFyO
- tombert 1y agoYeah, I think Rust makes some sense, and I do think I've done a few clever things like getting a linear-time "sort" by exploiting the fact that there's a discrete and finite number of "scores" [1], and avoiding copies by taking the indexed values and explicitly moving them into the source channel to avoid extra copies [2]. Someone smarter than me who is more familiar with TUI programming could almost certainly augment and improve what I wrote; I worked on it for as long as it was interesting to me. I use it for my home-built program launcher thing Sway, though most people would probably get better results with real fzf. [1] https://github.com/Tombert/rs-fzf-clone/blob/main/src/helpers.rs#L54 https://github.com/Tombert/rs-fzf-clone/blob/main/src/helper... [2] https://github.com/Tombert/rs-fzf-clone/blob/main/src/processors.rs#L359 https://github.com/Tombert/rs-fzf-clone/blob/main/src/proces...
- ricardobeat 1y agoFirst time hearing anyone say fzf can be slow. I mostly use it for filtering relatively small lists (few K items), for example git reflogs, is speed an issue when searching the whole filesystem or something on these lines? And assuming speed is not an issue, why would Rust make it better?
- rauli_ 1y agoNot every code project needs to turn out to be world changing. Experiments like this sometimes produce excellent results.
- dsp_person 1y agoLooking forward to the tmux-c re-rewrite next
- johnisgood 1y ago[flagged]
- godelski 1y agoHonestly, I often hate how people ask "why?", and don't understand how "for fun" is a legitimate answer. I get it for work or other things, but hobbies? We do lots of things for fun! Humans were born to play, just like every other animal. It's how we learn and explore the world around us. And frankly, to quote Knuth > In fact what I would like to see is thousands of computer scientists let loose to do whatever they want. That's what really advances the field. This is true for any field, or any project. We're creative creatures. We dream and explore. Major changes almost never come from doing things the way they've always been done. A lot of times "just because" gives you the freedom to try new things and challenge those paradigms. Weirdly, if you always have to justify everything you slow down progress.
- Arisaka1 1y agoI still believe that my #1 think that stunted my growth as a junior SWE was overthinking my personal projects and languages to use for them, instead of just building whatever I felt it's interesting or intriguing to build.
- godelski 1y agoIt's always hard to tell. But have you considered you might be measuring the wrong way? To me it sounds like you learned a real important lesson one that some people never seem to learn. I think one of the most beneficial aspects of doing things "just because" is these other skills or information you get along the way. It is very easy to miss all of this progress if you're too focused on the progress of the more tangible things. But that doesn't make any of that not progress. So don't put yourself down for that, because I'm sure you learned a lot. The only reason you can look back and see a better way is because you made that progress and learned those lessons. These are things mentors can usually help you get through faster but not everyone has a mentor nor access to one. But don't undermine your own progress just because you didn't finish projects or because you did things differently than others
- ku1ik 1y agoSame here!
- badgersnake 1y ago> new things Or copies of old things apparently.
- 90s_dev 1y agoIntuition and logic are the two halfs of reason (logos). We sometimes have a reason that we can't put into words (logos) but we know intuitively.
- deleted 1y ago[deleted]
- 1vuio0pswjnm7 1y ago"We don't necessarily need a reason to build new things." But tmux isn't new Is a reason necessarily needed to rewrite software in other languages
- fragmede 1y agoGNU screen would like a word.
- magarnicle 1y agoI really don't know how tmux got so much mindshare over screen. It just isn't obviously better in any way. Maybe screen is just poorly named?
- usef- 1y agoI think a lot of it is that tmux had friendler, sane defaults and clearer command design (eg. status bar out of the box). And, I suspect, people not already knowing screen. The latter reason is why Helix is slow in doing similar to vim, I think, despite being far more consistently designed and saner defaults. Everyone knows vim exists. I've still never switched from screen, personally, though I'm only a light user.
- quotemstr 1y ago> status bar out of the box Software packages win over other packages for the silliest reasons.
- vaylian 1y agoDefaults matter. I've had my screenrc with a status line but I still ended up preferring tmux in the end, because not needing a config file was a small but pleasant advantage when working with different machines. I also didn't like ctrl+a as the leader combination, because it conflicts with "go to the beginning of the line" in bash. ctrl+b is a much nicer default.
- deleted 1y ago[deleted]
- df0b9f169d54 1y agotmux has been used a lot of memory on my system, especially when scrolling buffer is large enough (I often have > 10k lines of things ). I have often executed `pkill -9 tmux` and saved my day. I hope the rust version can help a bit here?
- downrightmike 1y agoLet us know
- throwaway290 1y agoTmux has configurable scrollback buffer size, maybe set-option -g history-limit something-smaller in your config?
- 01HNNWZ0MV43FF 1y agoHow much is a lot? Even 10,000 lines of text should be on the order of megabytes, right?
- da-x 1y agoI am using tmux with a 200,000 line history and have no issues. Also, in 2017-2018 I contributed a few fixes for memory leaks related to buffer history, so make sure you are using a recent version.
- denysvitali 1y agoI like the initiative, but all this effort for ... unsafe Rust? I know it's a hot topic, and I hope the end goal is to have a memory-safe (and faster) tmux. I just hope the author doesn't stop here :) Edit: As pointed out below, I'm stupid, it's stated in the article and I didn't read that part
- verbatim 1y agoAt the end of the article he states that the next step is to work toward safe Rust.
- denysvitali 1y agoThank you! I skimmed through the article and didn't find this. Should have used CTRL+F :)
- johnisgood 1y agoI highly doubt it is going to happen. Should have started from scratch, in Rust.
- deleted 1y ago[deleted]
- riskable 1y agoIt's the first step in a two-step process: 1. Rewrite in (unsafe) Rust. 2. Update the code over time, moving towards safe Rust. It's the old, "get it working then fix it" process. In business that's normally a bad idea because you end up wasting more time than if you'd just done things correctly from the start but for a hobby project it's fine. Because then you're more likely to learn something and possibly—ultimately—end up with a better end product. To a business, time your developers spend learning things (the hard way) is wasted. To a hobbyist, taking the time to learn things is time well-spent.
- Jtsummers 1y agoIn business it can also be a good idea, because if you're waiting for it to be done correctly you may never have a delivered product even if you have a working (but not 100% ideal) product. A compromise is to get a subset of your target capabilities working correctly and the rest unimplemented and deliver that before continuing on.
- tialaramex 1y agoCoincidentally I was just watching this, "Oxidise Your Command Line" https://www.youtube.com/watch?v=rWMQ-g2QDsI https://www.youtube.com/watch?v=rWMQ-g2QDsI Some of that video is about stuff you have no use for if you're not a Rust developer, but, some of it is things that would be just as useful to anybody who is comfortable with, as it says, a command line interface.
- alexvitkov 1y agoI'll take a rust tmux if it runs on Windows. I'm currently kind of stuck on Windows and I didn't realize how much tmux means to me until Bill took it away :(
- throwaway290 1y agoWhy are you stuck on Windows?
- diggan 1y agoSome programs only run on Windows, this isn't a new problem. Personally, the only reason I have a Windows installation on my desktop is because Ableton doesn't run (well) via Wine, so not a lot of options really.
- vunderba 1y agoThis. DAW support in Linux has always been kind of rough. It's slowly getting better though with stuff like Bitwig and Reaper.
- finnjohnsen2 1y agoAt least he's not stuck on MacOS
- mystifyingpoi 1y agoMost people in big companies are stuck with Windows. But WSL2 is really amazing, even if a workaround in idea.
- joe_guy 1y agotmux runs fine in WSL1/2
- nickjj 1y agoYep I've been doing this since WSL 1 was available, it's rock solid. My dotfiles at https://github.com/nickjj/dotfiles https://github.com/nickjj/dotfiles have an install script to automatically get everything (including tmux w/ plugins) set up on Debian, Ubuntu, Arch Linux or macOS. This includes native Linux and WSL 2 support.
- submeta 1y agoTmux is a gamechanger for me. Being able to start a dozen different projects with one line (using tmuxinator): the server, tailing logfiles, activating venvs, running the docker container, all within one line of code: Awesome. Hadn’t worked with it for years, just started again two days ago as I migrated from iTerm to Ghostty. And am loving the setup. Plus nvim. Pure awesomeness. Looking forward to check out tmux-rs.
- kccqzy 1y agoSurprised to hear you migrated from iTerm. It actually has a tmux integration mode (using -CC) that's awesome. You then don't have to remember any tmux specific shortcuts. Switching window is just Cmd+` just like everywhere else. I entirely stopped using tmux when I couldn't use iTerm.
- johnisgood 1y ago[flagged]
- neuspadrin 1y agoDid you? Like 2 paragraphs in: > I threw away all of the C2Rust output and decided I would translate all of the files into Rust manually from C. The talk about starting with it, realizing it was too rough and changed approach. It's unsafe rust now but next goal at end was a safe version.
- johnisgood 1y agoYeah, time will tell. I am not going to hold my breath. You can, but you might find yourself dead (or not, actually). Have you read the conclusion, BTW?
- johnisgood 1y agoTo all the down-voters: worth reading: https://news.ycombinator.com/item?id=44459114 https://news.ycombinator.com/item?id=44459114
- uecker 1y agoI like this post, one can learn a lot. It seems automatically translating Rust to C is not a very good idea: "I threw away all of the C2Rust output and decided I would translate all of the files into Rust manually from C.". Neither seems doing it manually: "I introduced many bugs while translating the code. I’d like to share the process of discovering and fixing a couple." Or using AI: "That’s because when using cursor to translate the code it would still occasionally insert bugs, just like me. So, I spent as much time reviewing the generated code as it would have taken me to write it myself." As a hobby project, all power to you. But otherwise, maybe better not rewrite working code....
- perching_aix 1y agoThis reminded me of no-code: https://github.com/kelseyhightower/nocode https://github.com/kelseyhightower/nocode
- antonvs 1y ago> But otherwise, maybe better not rewrite working code.... Except that the eventual result allows for extension and improvements in a memory-safe language.
- uecker 1y agoThere seems to be some rather irrational obsession about this.
- antonvs 1y agoThings can seem irrational when you don't understand them. Another comment in this thread hoped for "a brand new bulletproof tmux-resurrect". The reason there's a desire for such things is closely related to the limitations of non-trivial programs written in C. They're harder to extend without bugs, harder for new team members to understand, and so on. The "irrational obsession" has to do with advancing the state of the art beyond a primitive high-level assembler that was developed in the 1970s.
- teekert 1y agoNice, I like tmux, I use it daily, I live in it. I hope this version makes it easier to just scroll with the scroll wheel or ctrl-page-up/down, or ctrl tab through your panes, or just show the whole unconcatenated title in the bottom left ;) Sorry I know this is not the place to complain, but it would be so nice!
- jayknight 1y agoFor me scroll wheel just works. The other stuff wouldn't be hard to configure with `bind-key`. I use ctrl-space to cycle through panes in a window: bind-key -n C-Space select-pane -t +1
- 0x457 1y agoYou might like zellij more than tmux.
- antonvs 1y agoI use byobu which is basically an opinionated distribution of tmux. Scroll wheel works fine, as does Alt-PgUp/PgDn. Ctrl-Tab probably won't work because terminals tend not to recognize it as different from Tab. But you might be able to bind Alt-Tab or some other such combo to cycle through panes in the tmux config. It should just be a one-liner.
- psyclobe 1y agoOh neat!!
- ethagnawl 1y agoThis announcement has my attention. I've been working on a Rust-based tmux session manager called rmuxinator (i.e. tmuxinator clone) for a few years now. It (mostly) works and been slow going because ... life but I've recently picked it back up to fix some bugs. One of the last new features I'd added was the ability to use rmuxinator as a library in other Rust programs. I'd like to try forking tmux-rs, adding rmuxinator as a dependency and seeing if it would ... just work as a way to start sessions using per-project config files. I'm definitely not advocating for adding rmuxinator upstream but it would be very nice to have this sort of session templating baked into the "terminal multiplexer" itself. The other interesting possibility I could foresee is doing things the other way around and having rmuxinator use tmux-rs as a library in order to setup and manage sessions instead of just dumping out shell commands -- which is fraught with edge cases. (Not sure if this is currently possible with tmux-rs, though.) Once I wrap up the bugfixes I'm currently working on, I may fork this project and give one or both of the above a try. Regardless, nice work by richardscollin!
- ethagnawl 1y agoAs of rmuxinator 4.0.0, you can now use tmux-rs as a configurable "terminal multiplexer" and it'll use that executable when shelling out to create and manage the session.
- echelon 1y agoI wonder if the tmux maintainers would be interested in switching to this? Transitioning more software from C to Rust is a great idea.
- joshka 1y agoTaking a look at the source earlier, I'd guess probably not. If you're going to move a project to rust, you'd want to actually make it look like rust. Currently it looks like C written in rust. That doesn't make anyone happy really. (Obv. not a slight on the maintainer here, it's a personal project with a specific approach)
- uecker 1y agoIt is a horrible idea.
- zppln 1y agoSeems like a bit entitled to expect being able to go around rewriting stuff and then have the old maintainers maintain it.
- echelon 1y ago> to expect I wonder, I don't expect. This would require first for the Rust implementation to grow beyond a POC with code translation. In its current state I doubt it could entice any of the original authors or maintainers. But if it became capable and hardened and picked up velocity, then it would pose some major questions for having two similar pieces of software.
- yjftsjthsd-h 1y agoMy understanding is that tmux is primarily an OpenBSD project, and rust isn't a good fit for them (for reasons that summarize to portability problems), so it is extremely unlikely. Also, this is a hobby project that currently is all unsafe, so there's not even any particular point. (EDIT: Of course, as it gets rewritten the latter point is likely to diminish)
- 1y ago
- rthnbgrredf 1y agoThis seems like an excellent future use case for a fully automated process by a large language model that translates a non-trivial C codebase to Safe Rust in under an hour with high accuracy. However, as the author noted, even after some attempts with Cursor at the end of development, the tool wasn't able to accelerate the translation effectively (in mid-2025). So while the potential is promising, it appears we're still some way off.
- gavmor 1y agoThese folks[0] are doing it, possibly via "codemods"[1], which utilize ASTs. 0. https://codemod.com/ https://codemod.com/ 1. https://martinfowler.com/articles/codemods-api-refactoring.html https://martinfowler.com/articles/codemods-api-refactoring.h...
- keybored 1y ago> This seems like an excellent future use case for a fully automated process by a large language model that translates a non-trivial C codebase to Safe Rust in under an hour with high accuracy. That’s specific.
- deadbabe 1y ago[flagged]
- jacobr1 1y agoIt is intended as a incremental step to now write revise the unsafe rust into more idiomatic and safe rust. I haven't done rust port yet, but when translating other projects between languages I've also found it useful to first do a 1:1 port to ensure you have a system that works as intended, then refactor from there to clean things up.
- deleted 1y ago[deleted]
- qwertywert_ 1y agoYou weren't really lying when you said "100% (unsafe) Rust" eh..
- lolive 1y ago[flagged]
- lolive 1y agoD.mn! I was hoping for the announcement of a brand new bulletproof tmux-resurrect. But no, it is (just) tmux-(recodedIn)rust.
- parhamn 1y agoInteresting, this article and the comments make no mention of LLMs for the initial translation. Really surprising given that would be the first thing I'd reach for for a translation/porting task (though verification could get tricky). Now I really wonder how a good model like Sonnet 4 would have performed.
- TechDebtDevin 1y agoIt wouldnt have gotten 2% finishd. It wouldn't have compiled. Its a waste of time to even consider.
- parhamn 1y ago> It wouldnt have gotten 2% finishd What do you mean by this? I'd assume the process would be very very incremental. One function + accompany tests at a time, verify and continue and keep moving up the tree. It's an interesting problem because I imagine in the future lots of things will be ported like this.
- TechDebtDevin 1y agoYou've been duped my friend. -edit Good luck reading 100k lines of Claude generated Rust that you know nothing about lol. LLMS are not the tool for this.
- dkdcio 1y ago[flagged]
- Jtsummers 1y ago> Interesting, this article and the comments make no mention of LLMs. https://richardscollin.github.io/tmux-rs/#ai-tools https://richardscollin.github.io/tmux-rs/#ai-tools
- parhamn 1y agoUsing Cursor to refactor the unsafe code is quite a different task than using an LLM to translate into safe rust. I was just curious how it would perform.
- xvilka 1y agoNice, hope it will become cleaner code in time. I tried zellij multiple times but despite years of development it still misses many things tmux provides. Inability to show/hide status bar[1] is the most annoying. [1] https://github.com/zellij-org/zellij/issues/694 https://github.com/zellij-org/zellij/issues/694
- imbnwa 1y agoYou can't rebind key maps to its session manager plugin, making it a no-go since I bind the same key that the plugin uses to select a directory or something. Thus, I can't create new sessions through it, have to do it from the command line.
- ConanRus 1y ago[flagged]
- tekawade 1y agoI love this. I also want to dabble into loving things to rust! Here I want to call out zellij. Zellij is rust based terminal multiplexer. I am user not creator. I love everything rust and finding and migrating to rust based solutions where feasible.
- goku12 1y agoJust curious. I'm a Rust developer. But I don't see myself discriminating between tools written in C, C++, Rust, Zig, etc. They all seem easy to install and use, as long as they're reasonably bugfree. Scripting languages are slightly different as they require me to maintain their respective interpreters and tools on my system. What difference do you see between applications written in Rust and those written in other compiled languages?
- shim__ 1y agoBuild Systems for C(++) are a mess, no package manager often means git submodules. Whereas Rust is actually easy, just requiring an `cargo install`. Don't know about Zig though Zig hasn't really taken of just yet imo.
- tkcranny 1y agoI agree the underlying technology doesn’t ultimately matter, but as user of a lot of fairly modern rust-based cli tools there definitely is something in the air worth mentioning. I suspect it’s a couple of things. A new generation of programmers are hitting the scene, wanting to do things in new ways. Not inherently good or bad, but the new tools sure usually are at least very _pretty_, and have a lot of affordances and usability improvements over the ancient tools that can never be changed for the sake of compatibility. Rust and Go make this nicer, and are the languages de jour with good cli ecosystems and performance characteristics around them. I genuinely do like most of my replacements. ripgrep for grep, eza for ls, zoxide for cd, fd for find, podman for docker, and a few more. Developer tooling is a rich and interesting space to be in, but there’s plenty of bandwagons I’m not getting on, like this or zellij for tmux, or jj for git.
- 1y ago
- londons_explore 1y agoLLM's are really good at translating one programming language into another. In fact, I sometimes port code to another language and back just as a way to do code cleanup (or at least give ideas for things that could be cleaned up) I wonder why OP didn't start from that as a starting point?
- lab14 1y agoBecause he didn't want to? He mentioned that for him, this is like a "gardening" project, so why take away the joy of programming just to become an AI operator?
- Etheryte 1y agoThis is discussed in the article? They tried cursor, but the bug rate was no better than their manual effort, so at least in this context, it did not work out.
- z3ratul163071 1y agorewriting old code in new language is the killer application for AI. should have used that instead of transpiler.
- someperson 1y agoSurely improvements be made to c2rust to reduce the cited information loss with constant naming, to reduce the initial conversion burden?
- kevincox 1y agoYeah, this seems like a huge missing feature for C2Rust. IIUC the main idea is to serve as a base for then porting to idiomatic Rust. But if you lose all of the constants that is a huge productivity loss.
- dataking 1y agoIndeed. We had experimental support for preserving (some) constants but it fell by the wayside. We're bringing it back in the coming months.
- johnisgood 1y ago[flagged]
- deleted 1y ago[deleted]
- jonpalmisc 1y agoI don't think anyone is suggesting that the generated Rust is nicer than the original C. It is auto-generated with the purpose of maintaining the exact same semantics as the C code, with no regard to safety, best practices, etc.—of course it is messier than actual, handwritten Rust. As c2rust says in its documentation [1], it's meant to be the first step in an otherwise manual and incremental port of a codebase from C to Rust, and the author recognizes this in their closing remarks: > The next goal is to convert the codebase to safe Rust. [1] https://github.com/immunant/c2rust/raw/master/docs/c2rust-overview.png https://github.com/immunant/c2rust/raw/master/docs/c2rust-ov...
- johnisgood 1y ago[flagged]
- _danielle_ 1y agoI mean what else would you expect when C is ported directly to Rust? Rust programs typically aren't written anything like C programs are.
- johnisgood 1y ago[flagged]
- _danielle_ 1y agoThen why make the original comment? :')
- 1y ago
- gmoque 1y agoI love the attitude on this project and most of the comments are supportive. While rewriting a mature application to another language always sounds like a bad idea, there are so many learnings along the way. It's not about the end it's about the process. Given the traction you got here and the advancements in AI, I'm sure this can become a very attractive hobby project for Rust beginners, there's probably a lot of easy bugs to fix. Fixing bugs, adding new features, and optimizing the code is all you need. Here's an idea to get the ball rolling: Create a scratch buffer for Gemini CLI (or your favorite LLM) and enable it to interact with the various windows and panes of the tmux session. Here's my use case, I use synchronized panes to send the commands into multiple servers, but some commands sometimes fail for various reasons. What if I can just ask the AI to send a series of commands and react based on the output and adjust along the way. It's like a dynamically generated custom shell script on the fly.
- fasterik 1y agoI'm all for people doing whatever hobby project they want to do for learning and entertainment purposes. But I don't really understand the appeal of straight porting something from one language to another. For example, I'm a daily gvim user. If I were going to do a hobby project text editor, I would emphatically not make a clone of gvim, I'd make a text editor with exactly the features I want that behaves exactly how I want. If you're going to invest that much time in a project, why not do something creative and unique?
- a-dub 1y agothe one thing i wish tmux supported was remote connections to several backend instances.
- Carrok 1y agoUse tmuxinator to start multiple ssh/mosh connections.
- snizovtsev 1y agoI started working on this feature about a month ago: https://github.com/snizovtsev/tmux https://github.com/snizovtsev/tmux (it's in early experiments, not ready for a try). Luckily tmux has a well-established "control mode" protocol designed for iTerm2 that can serialize internal state updates into a stream of text messages. So I do write client-side of this feature right inside tmux. When it's ready, you will able to embed remote sessions inside local tmux instance by calling something like "ssh example.com tmux -CC attach". It will auto-detect "control mode" escape sequence and create special "remote session" you can switch into. If you are interested, connect with me (snizovtsev@gmail.com) so I will notify when feature is ready and ask for early testing before making upstream proposal.
- malithmcr 1y agoRust is king
- aldousd666 1y agoGreat way to learn a new language!
- cchance 1y agoNext step slowly porting unsafe code to safe rust? lol
- FullyFunctional 1y agowhy is that funny? I’ve done exactly this (in a processional setting): c2rust to get something functional and then incrementally rewrote the code while producing unit tests (approval tests via insta are particularly handy). The end result was a codebase which was much easier to maintain, with much better tooling and tests.
- deleted 1y ago[deleted]
- bakugo 1y agohttps://github.com/richardscollin/tmux-rs/issues/9 https://github.com/richardscollin/tmux-rs/issues/9 120 comments and nobody has mentioned the use-after-free triggered by closing a window. Rust truly is the safest language.
- hamandcheese 1y agoThe author described the port as "100% unsafe rust". What would you expect?
- philosophty 1y ago"Despite the generated code working, it was basically unmaintainable and 3x larger than the original C." Which makes C2Rust seem pretty useless? "I’ve recently reached a big milestone: the code base is now 100% (unsafe) Rust. I’d like to share the process of porting the original codebase from ~67,000 lines of C code to ~81,000 lines of Rust (excluding comments and empty lines)." And yet somehow a hand-ported (and still unsafe) rewrite of a C program in Rust is still almost 20% larger? If I recall, the Go gc compiler was automatically converted from 80K lines of C to 80K lines of Go. A hand-ported version would have been much smaller.
- kevincox 1y ago> Which makes C2Rust seem pretty useless? It does what took him 6 months in seconds. Of course it isn't perfect, failing to keep the name of constants being an obvious flaw. But presumably with a few improvements you could then spend some of that 6 months cleaning up the code and still save time. Sounds like C2Rust is almost there, but not quite yet. > And yet somehow a hand-ported (and still unsafe) rewrite of a C program in Rust is still almost 20% larger? Size is not a very useful metric. But the port is still half-done. He has got it working in Rust, so now he is ready to do the "hard" part of the port and actually rewrite the "basically C" code into idiomatic Rust. That is where you expect to get safety improvements and hopefully more readable code.
- philosophty 1y ago"It does what took him 6 months in seconds." It generated unusuable garbage code in seconds, which is nothing like what he wrote by hand in six months. "Size is not a very useful metric." Size is a very useful metric. Counting tokens is more accurate estimate of "size" but lines of code is a good first approximation. The entire purpose of high level languages is to make it possible to do more with less code. Size isn't all that matters but it's very important. Rust code is not only more verbose than C it's also much more irregular and complex. That 20% increase in lines of code is probably more like 50% increase in code complexity, and this is without safety. Just compare tokens in the post's example: // cmd-kill-session.c RB_FOREACH(wl, winlinks, &s->windows) { wl->window->flags &= ~WINDOW_ALERTFLAGS; wl->flags &= ~WINLINK_ALERTFLAGS; } // cmd_kill_session.rs for wl in rb_foreach(&raw mut (*s).windows).map(NonNull::as_ptr) { (*(*wl).window).flags &= !WINDOW_ALERTFLAGS; (*wl).flags &= !WINLINK_ALERTFLAGS; }
- sanity 1y agoHow do people feel about tmux vs zellij?
- imbnwa 1y agoZellij has interesting ideas, but it has a ways to go. You can arbitrarily rebind the base modes and their actions, but you're F'd if those conflict with a plugin's, which seem to all have hardcoded key binds.
- seyz 1y ago> I don’t really have a good reason. It’s a hobby project. Like gardening, but with more segfaults. Love it. You definitively deserve your +350 points!
- Jtsummers 1y agoIt's not my project, I saw that line and read the rest and thought it was interesting so I submitted it.
- alberth 1y agoSlightly OT: it didn’t dawn on me until recently that terminal multiplier (like tmux) is a terminal itself. And as a result, you could be running the greatest / fastest / most feature rich desktop terminal … but if your multiplier doesn’t support something - it hinders your fancy desktop terminal. Short 3 min video explained by Ghostty creator https://youtu.be/o-qtso47ECk https://youtu.be/o-qtso47ECk
- blibble 1y agowhat is it with these re-implementations by different authors pinching the name of the original project? you want to re-implement a well known project, fine call it something else
- bitbeq 1y agowfd
- dangoodmanUT 1y agoI love this, but the examples they show of their snippets are really, really not rust idiomatic. Like they’ve basically thrown away all the rust patterns and just wrote a c program in rust (eg all the raw pointers)
- pizlonator 1y agoI just ported tmux to Fil-C in less than an hour (that included porting libevent and gettings its test suite to pass). Works great and it's totally memory safe
- deleted 1y ago[deleted]
- golem14 1y agoWould you mind porting graphviz to Fil-C ? It's probably foolish, but I have the idée fixe that there's really no solid alternative for graphviz and dot (yes, there are UI versions, and mermaid and whatnot, but nothing that works on really big graphs and has the same expressivity), and I suspect that soon all the people that wrote graphviz will die off or retire. I like to see a port to a newer language as well, so ongoing maintenance will bercome easier. Again, probably an idée fixe, and all is really well.
- pizlonator 1y agoDownload binaries here: https://github.com/pizlonator/llvm-project-deluge/releases https://github.com/pizlonator/llvm-project-deluge/releases Try to port it. Maybe it'll just work
- graphviz 1y agohaha yes
- aniviacat 1y agoDid you experience a noticable performance degradation?
- pizlonator 1y agoNot in tmux
- deleted 1y ago[deleted]
- a-a-ron_b 1y ago> Usually once I reach the point where I’ve got blisters on my fingers I think it’s better to just take a break. What a legend.
- deleted 1y ago[deleted]
- stephenlf 1y agoFun!
- deleted 1y ago[deleted]
- starchild3001 1y agoThis 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.
- chickenzzzzu 1y ago[flagged]
- starchild3001 1y agoI've seen things you people wouldn't believe
- jimrandomh 1y agoThe author doesn't claim it, but worth stating explicitly: tmux is a security-critical piece of software that doesn't get the attention it deserves.
- m3at 1y agoVery much a side note, but: > my feeling is that I’d still reach for it if my hands are really physically hurting, and I need to keep working. Usually once I reach the point where I’ve got blisters on my fingers I think it’s better to just take a break I'm dumbfounded, and impressed in an unhealthy way. Do some of you regularly type so much that you develop blisters?
- DJBunnies 1y agoEver seen somebody type on a keyboard that learned on a typewriter?
- vanderZwan 1y agoEvery day when I look in the mirror, and I don't have this problem. Then again, by the time I had a touch typing course at age ten using an old typewriter, I already had taken piano lessons for a couple of years. My music teacher was very strict on proper hand positioning, saying that future me would hate him if I didn't learn that right. I stopped taking piano lessons soon after, but I imagine that the skills involved with properly playing the piano transfer quite well to typing.
- absoluteunit1 1y agoYes - I agree. Piano skills definitely make it easier to pick up touch typing. I learned piano earlier in my life and then learned touch typing (and shameless plug: built https://www.typequicker.com https://www.typequicker.com) later on in life and I definitely had a easier time than some of my peers. I’m curious - what course did you take (might have been a while) ? I’m hoping to built features in TypeQuicker for institutional clients (schools, tutoring agencies, etc) and I’m doing research on what some schools currently use. Many don’t have any courses at all so it’s a hard sell right now
- vanderZwan 1y agoEhm.. I'm afraid I don't remember, although I doubt it would be of use to you if I did :). I'm Dutch and this was in the '90s. It was a course organized by the local community center using some Dutch book made for Dutch typewriters (so I actually had to unlearn where the dedicated IJ digraph was when I switched to computers). https://en.wikipedia.org/wiki/IJ_(digraph) https://en.wikipedia.org/wiki/IJ_(digraph)
- devy 1y agoWonder if anyone has tried these over flourishing AI code assist tools to supercharge the speed these porting projects? If so, what's the experience has been?
- chthonicdaemon 1y agoOP said they tried cursor and didn't experience a speedup over their vi macros.
- osigurdson 1y agoI don't understand mouse support in tmux. tmux works great, then when you need to enable mouse support, it takes over everything works horribly.
- sunshine-o 1y ago> I’d like to share the process of porting the original codebase from ~67,000 lines of C I was surprised to learn tmux had such a "large" codebase, where does the complexity come from?
- sriku 1y agoIn "Interesting bugs / Bug 1", I walked through the code again. Inside of the Rust function (*c).bar has a valid address, like 0x60302764, but out the function, the value received from the calling C code was 0x2764. ... That’s right, the C code was using the implicit declaration which is: int get_addr(); That explains why the value was incorrect! The C compiler was thinking a 4 byte int was returned not an 8 byte pointer. So the top 4 bytes were being truncated or ignored. That's weird as an explanation. 0x60302764 is 4 bytes and 0x2764 is 2 bytes. Why would an address get truncated to 2 bytes? Is int 2-bytes according to any intermediate compilation stage? (Been at least 25 years since I saw int be 2 bytes, if ever).
- wiz21c 1y ago> the code base is now 100% (unsafe) Rust > ... It’s a hobby project. Like gardening, but with more segfaults. From now on, it's like gardening, but in hell :-)
- meindnoch 1y agoTmux is only 67k lines of C? That's surprisingly small.
- zoobab 1y agoI was searching the other day for a Tmux/Screen replacement in python, anyone?
- usrbinbash 1y ago> the code base is now 100% (unsafe) Rust So the primary (or rather: only) reason for using Rust over C (memory safety) is out the window. > I’d like to share the process of porting the original codebase from ~67,000 lines of C code to ~81,000 lines of Rust And the codebase got bigger. So yeah, as the author explains, hobby project, and kudos to that, but nothing that I will install on any box of mine any time soon. Besides, applications like tmux would much rather be prime candidates for a rewrite in a garbage collected systems language (aka.; Go) than in Rust. tmux spends 99% of its time waiting for the user to hit a key, there is nothing performance critical in such an app that wouldn't be 100% adequately served by Go.
- MuffinFlavored 1y ago> but nothing that I will install on any box of mine any time soon. A little harsh. Rome wasn't built in a day.
- johnisgood 1y ago[flagged]
- tekkk 1y agoJust appalling. Someone publishes a post about their WIP project reaching an important milestone, and here comes the naysayers whining about the fact it's not finished yet. Did you even the article? He clearly states his aims to convert it to safe rust. And for the code size, he clearly hasn't needed to optimize it yet and I don't think you necessarily want to code golf codebase like this.
- usrbinbash 1y agoSince when is "Giving an honest opinion" considered "appalling"?
- tekkk 1y agoIf your "honest opinion" is just a take down without much thought behind it, you could just as well keep it to yourself is my opinion. If you want to provide criticism, please at least put a little effort to it. So simply referencing the article can't refute you.
- hyvan 1y agoHi
- Stranger_X 1y agoJust launched StrangerMeet, a simple platform to chat anonymously with strangers via text — no signup needed. Inspired by the old-school internet randomness (think Omegle, but cleaner and focused on meaningful or just fun conversations). Would love your feedback — especially on performance, UX, and privacy concerns. It's super new (just 8 days live), so things might be a bit rough, but I'm improving it daily!