TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Fish 4.0: The Fish of Theseus

906 pointsby jdxcode5 months ago

33 comments

chubot5 months ago
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&#x27;m reading this right, it looks like fish was not released as a hybrid C++ &#x2F; Rust program, with the autocxx-generated bindings. There was a release during that time, but it says &quot;fish 3.7 remains a C++ program&quot; [1]<p>It sounds like they could have released if they wanted to, but there was a last stage of testing that didn&#x27;t happen until the end.<p>Some people didn&#x27;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&#x2F;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:&#x2F;&#x2F;github.com&#x2F;oils-for-unix&#x2F;oils&#x2F;wiki&#x2F;Feature-Detection-Is-Better-than-Version-Detection">https:&#x2F;&#x2F;github.com&#x2F;oils-for-unix&#x2F;oils&#x2F;wiki&#x2F;Feature-Detection...</a><p>Version&#x2F;name detection is why Chrome and IE pretend to be Mozilla, and why Clang pretends to be GCC. Feature detection (e.g. .&#x2F;configure and eval() ) doesn&#x27;t cause this problem!<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;releases">https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;releases</a><p>[2] e.g. <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;from?site=safecpp.org">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;from?site=safecpp.org</a>
评论 #42537298 未加载
评论 #42538340 未加载
评论 #42537070 未加载
评论 #42540158 未加载
scop5 months ago
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.
评论 #42536846 未加载
评论 #42536344 未加载
评论 #42536820 未加载
评论 #42541418 未加载
评论 #42538933 未加载
评论 #42536547 未加载
评论 #42539627 未加载
评论 #42540791 未加载
freedomben5 months ago
&gt; <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>&gt; <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&#x27;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&#x27;t exude enough love for the Cygwin team.<p>Hopefully rust will support cygwin as a build target in the future!
评论 #42539112 未加载
评论 #42536552 未加载
评论 #42537299 未加载
epage5 months ago
&gt; The one goal of the port we did not succeed in was removing CMake.<p>&gt; 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:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;cargo&#x2F;issues&#x2F;2729">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;cargo&#x2F;issues&#x2F;2729</a><p>Personally, I lean away from Cargo expanding into these use cases and prefer another tool being implemented on top. I&#x27;ve written more about this at <a href="https:&#x2F;&#x2F;epage.github.io&#x2F;blog&#x2F;2023&#x2F;08&#x2F;are-we-gui-build-yet&#x2F;" rel="nofollow">https:&#x2F;&#x2F;epage.github.io&#x2F;blog&#x2F;2023&#x2F;08&#x2F;are-we-gui-build-yet&#x2F;</a>
评论 #42536492 未加载
qalmakka5 months ago
As a decade-long user and as a professional C++ developer, I&#x27;m so happy they&#x27;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&#x27;ve been writing &quot;Rusty C++&quot; since before Rust was a thing, because <i>that&#x27;s the only sane approach to memory safety</i>. I&#x27;d rather have a program check that I don&#x27;t fumble up instead of running sanitizers when things go awry (often years later). The best bug is a bug that can&#x27;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&#x2F;C++.
评论 #42547687 未加载
Too5 months ago
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.
评论 #42539149 未加载
underdeserver5 months ago
The tone in the &quot;The Timeline&quot; section seems apologetic:<p>&gt; 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&#x27;m amazed that you estimated it at so little time originally, and I&#x27;m amazed you shipped it in full in just 2 years. Congrats!
评论 #42539536 未加载
nasretdinov5 months ago
Very nice too see Rust being used where it is actually appropriate! Hopefully Rust &quot;easy&quot; multi-threading will allow more parts of fish to be async, even though it&#x27;s already much better in that regard than bash (or any other shell I&#x27;ve seen).<p>One weird thing I&#x27;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&#x2F;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.
gorgoiler5 months ago
I try not to post unsubstantive comments here but I’m just so moved by this success that I have to say an enormous <i>Congratulations</i>!
WD-425 months ago
Congrats to the Fish team. The best shell just got better.<p>How about updating the project tagline to: &quot;Finally, a shell for the 00s!&quot;
评论 #42537363 未加载
OptionOfT5 months ago
&gt; 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&#x2F;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 = [&quot;deps:feature_dependency&quot;] [dependencies] feature_dependency = &quot;1.0.0&quot; </code></pre> And in code:<p><pre><code> if cfg!(feature = &quot;my_feature&quot;) { feature_dependency::something::Something::invoke(); } </code></pre> This will fail if you compile without `my_feature`.
评论 #42536416 未加载
评论 #42538541 未加载
评论 #42542058 未加载
outlore5 months ago
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.
评论 #42539251 未加载
评论 #42542971 未加载
评论 #42548158 未加载
评论 #42540295 未加载
评论 #42538582 未加载
memco5 months ago
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:&#x2F;&#x2F;fishshell.com&#x2F;docs&#x2F;4.0b1&#x2F;relnotes.html" rel="nofollow">https:&#x2F;&#x2F;fishshell.com&#x2F;docs&#x2F;4.0b1&#x2F;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).
petepete5 months ago
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&#x27;t imagine changing again any time soon.
Spoof77265 months ago
&gt; 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)
评论 #42536073 未加载
评论 #42539304 未加载
评论 #42536051 未加载
评论 #42536472 未加载
nixpulvis5 months ago
Awesome to see. Can&#x27;t wait to see how things improve from here.<p>Here&#x27;s the code if you were looking for it: <a href="https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;tree&#x2F;4.0b1">https:&#x2F;&#x2F;github.com&#x2F;fish-shell&#x2F;fish-shell&#x2F;tree&#x2F;4.0b1</a>
akdor11545 months ago
I&#x27;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?
评论 #42537370 未加载
评论 #42537218 未加载
abbefaria275 months ago
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!
评论 #42601816 未加载
LAC-Tech5 months ago
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?
评论 #42538696 未加载
评论 #42538321 未加载
评论 #42538076 未加载
naurupatel5 months ago
We&#x27;re flush with new and awesome terminals lately, Ghostty public launch now a huge upgrade to fish.<p>I&#x27;ve tried Fish a few times but hard to migrate over from bash&#x2F;zsh. Does anyone have tips on how to port over a bunch of aliases&#x2F;scripts&#x2F;etc. easily?
评论 #42540422 未加载
msoad5 months ago
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?
评论 #42537753 未加载
wellthisisgreat5 months ago
Is fish better than Zsh?
评论 #42536935 未加载
评论 #42542391 未加载
评论 #42542925 未加载
评论 #42537559 未加载
cute_boi5 months ago
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.
jsx25 months ago
It seems the upgrade to 4.0 isn&#x27;t available from Homebrew yet (brew upgrade fish -&gt; Warning: fish 3.7.1 already installed)
评论 #42573510 未加载
jedisct15 months ago
For end users who don&#x27;t care much about the internals, what are the new features of Fish 4.0? Anything worth the upgrade from Fish 3.0?
评论 #42548430 未加载
djoldman5 months ago
&gt; 57K Lines of C++ to 75K Lines of Rust<p>...<p>&gt; 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?
评论 #42541323 未加载
preisschild5 months ago
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.
评论 #42537506 未加载
评论 #42545714 未加载
chris_wot5 months ago
Wow, amazing!<p>I wonder how a conversion of a C++ project that makes extensive usage on ranges would go.
rmac5 months ago
fish &gt; zsh &gt; bash &gt; *
apatheticonion5 months ago
Can I `source` my custom .bash_profile file into Fish? Trying it out it doesn&#x27;t seem to work
评论 #42545399 未加载
oguz-ismail5 months ago
Another rewrite? Hope it&#x27;ll take off this time
eviks5 months ago
&gt; 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)
评论 #42537168 未加载
djaouen5 months ago
Glad to see at least one Rust rewrite successful (unlike [1])!<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;remacs&#x2F;remacs">https:&#x2F;&#x2F;github.com&#x2F;remacs&#x2F;remacs</a>