Congrats to the fish team! Great writeup with lots of interesting detail.<p>I wonder if this is the biggest project that has moved from C++ entirely to Rust (or maybe even C to Rust?) It probably has useful lessons for other projects.<p>If I'm reading this right, it looks like fish was not released as a hybrid C++ / Rust program, with the autocxx-generated bindings. There was a release during that time, but it says "fish 3.7 remains a C++ program" [1]<p>It sounds like they could have released if they wanted to, but there was a last stage of testing that didn't happen until the end.<p>Some people didn't quite get the motivation for adding C++ features to Rust [2], and vice versa, to enable inter-op. But perhaps this is a good case study.<p>It would be nice if you could just write new Rust code in a C++ codebase, without writing/generating bindings, and then throwing them away, which is mentioned in this post.<p>---<p>Also the #1 gripe with Rust seems to be that it supports version detection, not feature detection.<p>But feature detection is better for distros, web browsers, and compilers:<p><i>Feature Detection Is Better than Version Detection</i> - <a href="https://github.com/oils-for-unix/oils/wiki/Feature-Detection-Is-Better-than-Version-Detection">https://github.com/oils-for-unix/oils/wiki/Feature-Detection...</a><p>Version/name detection is why Chrome and IE pretend to be Mozilla, and why Clang pretends to be GCC. Feature detection (e.g. ./configure and eval() ) doesn't cause this problem!<p>[1] <a href="https://github.com/fish-shell/fish-shell/releases">https://github.com/fish-shell/fish-shell/releases</a><p>[2] e.g. <a href="https://news.ycombinator.com/from?site=safecpp.org">https://news.ycombinator.com/from?site=safecpp.org</a>
I remember switching from bash to zsh a few years back and thinking I was the bees knees. After the switch trying other shells seemed like bike-shedding because, I mean, what more could a shell? Then I got a new computer and decided to start from scratch with my tooling and downloaded fish. I was shocked how it instantly made zsh feel <i>cumbersome and ancient</i>.<p>Heartily recommend others give it a try as a daily driver for a couple of weeks. I liken it to Sublime Text: an excellent “out of the box” tool. Just the right amount of features, with the option to add more if you want. But you also don’t feel like your missing out if you keep it bare bones. A great tool in and of itself.
> <i>The one platform we care about a bit that it does not currently seem to have enough support for is Cygwin, which is sad, but we have to make a cut somewhere.</i><p>> <i>We’re also losing Cygwin as a supported platform for the time being, because there is no Rust target for Cygwin and so no way to build binaries targeting it. We hope that this situation changes in future, but we had also hoped it would improve during the almost two years of the port. For now, the only way to run fish on Windows is to use WSL.</i><p>I understand, but this is indeed incredibly sad. To this day I still use Cygwin, and in fact prefer it to WSL depending on what I'm doing. Cygwin is an incredible project that is borderline miraculous for what it accomplished and provides. Without Cygwin I may not have any sanity left. I can't exude enough love for the Cygwin team.<p>Hopefully rust will support cygwin as a build target in the future!
> The one goal of the port we did not succeed in was removing CMake.<p>> That’s because, while cargo is great at building things, it is very simplistic at installing them. Cargo wants everything in a few neat binaries, and that isn’t our use case. Fish has about 1200 .fish scripts (961 completions, 217 associated functions), as well as about 130 pages of documentation (as html and man pages), and the web-config tool and the man page generator (both written in python).<p>Our issue for this is <a href="https://github.com/rust-lang/cargo/issues/2729">https://github.com/rust-lang/cargo/issues/2729</a><p>Personally, I lean away from Cargo expanding into these use cases and prefer another tool being implemented on top. I've written more about this at <a href="https://epage.github.io/blog/2023/08/are-we-gui-build-yet/" rel="nofollow">https://epage.github.io/blog/2023/08/are-we-gui-build-yet/</a>
As a decade-long user and as a professional C++ developer, I'm so happy they've managed to successfully port the shell to Rust. While I have a lot of fun writing C++ (and Rust), I must admit that Rust is vastly nicer to use.<p>People can complain as much as they want about the borrow checker, but you basically have to be as strict as Rust is in C++ if you want to <i>really</i> avoid use-after-free issues, ... I've been writing "Rusty C++" since before Rust was a thing, because <i>that's the only sane approach to memory safety</i>. I'd rather have a program check that I don't fumble up instead of running sanitizers when things go awry (often years later). The best bug is a bug that can't happen at all.<p>Static analyzers are sadly too limited compared to what a borrow checker can do in my experience. Some bad stuff will always slip in in C/C++.
Surprised to see the line count go up so much, 56K LOC of C++ to 75K of Rust. The blog attributes it to rustfmt using less oneliners. Even so, i would believe that should be a small factor compared to the heaps of duplicate code you get from c++ header files and all the other syntax ergonomics rust gives you.<p>Is this typical for such a translation. They also mention addition of new features contributing to more code, how much of the addition was new features vs pure translation?<p>Would be interesting to see the line count of the c++ version if it was run through a formater with similar configuration.
The tone in the "The Timeline" section seems apologetic:<p>> The initial PR had a timeline of “handwaving, half a year”. It was clear to all of us that it might very well be entirely off, and we’re not disappointed that it was.<p>I'm amazed that you estimated it at so little time originally, and I'm amazed you shipped it in full in just 2 years. Congrats!
Very nice too see Rust being used where it is actually appropriate! Hopefully Rust "easy" multi-threading will allow more parts of fish to be async, even though it's already much better in that regard than bash (or any other shell I've seen).<p>One weird thing I'd also like to see is more bash integration, as others pointed out that being their primary motivation against switching to fish full-time. My use case is mostly sourcing bashrc/bashevv, and theoretically it should be possible in fish if I understand correctly: you need to be able to import e.g. every new env variable that changed before and after sourcing a bash script via real bash.
> it is often better to use if cfg!(...) instead of #[cfg(...)] because code behind the latter is eliminated very early<p>My experience with this is the other way around, especially if you have crates tied to that feature.<p>The cfg! is a marco that compiles to true/false, so whatever is inside of the if guard needs to compile regardless.<p>E.g.:<p>Cargo.toml<p><pre><code> [features]
default = []
my_feature = ["deps:feature_dependency"]
[dependencies]
feature_dependency = "1.0.0"
</code></pre>
And in code:<p><pre><code> if cfg!(feature = "my_feature") {
feature_dependency::something::Something::invoke();
}
</code></pre>
This will fail if you compile without `my_feature`.
I am curious to ask others here, are there other low-config alternative tools like Fish that, looking back, now seem like a no brainer? Ghostty is a recent example, Helix seems like another. I’d love to know about other tools people are using that have improved or simplified their lives.
Thought for a second that this was a 4.0 release announcement but this is just about the rewrite in rust. Any fish users wanting release notes of what to look forward to can look here: <a href="https://fishshell.com/docs/4.0b1/relnotes.html" rel="nofollow">https://fishshell.com/docs/4.0b1/relnotes.html</a>. Glad the rewrite is helping the dev team make improvements, but I’m more excited for the actual new features (except the new alt-backspace behavior which I’m sure I’ll get used to).
Really happy to see this, such a mammoth effort by the team and everyone else involved.<p>I switched over from zsh about four years ago and my config went from several hundred lines to a handful with just one plugin (fzf.fish).<p>It just works how I expect it to and I can't imagine changing again any time soon.
> Fish also uses threads for its award-winning (note to editor: find an actual award) autosuggestions and syntax highlighting, and one long-term project is to add concurrency to the language.<p>(note to editor: find an actual award)
Awesome to see. Can't wait to see how things improve from here.<p>Here's the code if you were looking for it: <a href="https://github.com/fish-shell/fish-shell/tree/4.0b1">https://github.com/fish-shell/fish-shell/tree/4.0b1</a>
I'd be really interested to hear from distro packagers how this is going - how amenable is rust-fish to being packaged following e.g. Debian guidelines?
Amazing write up! Everyone at work is itching to try Rust, but I think what’s killing adoption is that it’s not very clear how to gradually transition a code base. We have a few million lines of C++, some of it written 25 years ago. A full rewrite is just out of the question, at best we could use it for new sections. This is super common in the c++ world, so it’s a pity that porting wasn’t a first class concern in rust considering C++ devs are the target audience. It sounds like it was a challenge even at 57k LOC. Congrats to the fish team though, great accomplishment!
I use the shell a lot every day, mainly bash and some ash (alpine).<p>Does something like fish make the experience a bit smoother? is it pretty easy to get into?
We're flush with new and awesome terminals lately, Ghostty public launch now a huge upgrade to fish.<p>I've tried Fish a few times but hard to migrate over from bash/zsh. Does anyone have tips on how to port over a bunch of aliases/scripts/etc. easily?
I love fish and I’ve been a user for years. In the wake of AI, I am really interested in getting out of completes via a local tiny AI model<p>Does the fish team have any plans for integrating AI models for other completion?
Congratulations. Rust is really a great language. I wrote a small rust web server and its been a year and it seems to work great on $5 vps without any issue.
> 57K Lines of C++ to 75K Lines of Rust<p>...<p>> A lot of the increase in line count can be explained by rustfmt’s formatting, as it likes to spread code out over multiple lines, like: ...<p>I wonder what the character count diff is?
I would love to use fish, but it seems there really isnt a oh-my-zsh equivalent.<p>I dont even need the OMZ prompt (i use starship for that), but the aliases from the kubectl and git plugins are just so great to have if you use kubectl and git often.<p>Other plugins (like colored-man-pages, fzf-tab and syntax-highlighting) are also nice.<p>Is there something like that for fish?<p>Oh-my-fish has some of those features, but it seems to be abandoned.
> What would test -x say on Windows, which has no executable bit?<p>It would say whether the file extension is executable (part of pathext env variable)
Glad to see at least one Rust rewrite successful (unlike [1])!<p>[1] <a href="https://github.com/remacs/remacs">https://github.com/remacs/remacs</a>