Skip to content(if available)orjump to list(if available)

Fish 4.0.0

Fish 4.0.0

57 comments

·February 27, 2025

nindalf

Fish 4.0: The Fish Of Theseus (https://fishshell.com/blog/rustport/) is the full story of their rewrite from C++ to Rust.

Discussed on HN here - https://news.ycombinator.com/item?id=42535217 (906 points, 198 comments).

Highlights of the rewrite

- 1155 files changed, 110247 insertions(+), 88941 deletions(-) (excluding translations)

- 2604 commits by over 200 authors

- 498 issues

- Almost 2 years of work

- 57K Lines of C++ to 75K Lines of Rust 5 (plus 400 lines of C 6)

- C++–

ivanjermakov

I'm surprised Rust took more lines. Perhaps formatter makes shorter lines due to method chaining? Or improved test suite?

duckerude

According to the blog post (https://fishshell.com/blog/rustport/#fn:formatting):

> 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 [...] The rest is additional features. Also note that our Rust code is in some places a straight translation of the C++, and fully idiomatic Rust might be shorter.

nicce

Rust code defenitely takes more space with default formatter settings if you use functional paradigms. Every chained function call in many cases is one extra line. Default line width is not much anyway. Also if you handle all return types, lines will add up.

Since there are quite many contributors, it can be difficult to introduce some advanced macro requirements for the project, which could reduce the code.

dartos

Rust, IMO is a noisy language. So not surprising it took more lines.

Having to handle every case of every branch also probably balloons line count.

Efficient LOC is not a goal of rust at all anyway.

Cthulhu_

Efficient LOC shouldn't be a goal or metric anyway, readability trumps conciseness... except when conciseness improves readability.

darthrupert

So is C++ though. But the "wasteful" (in terms of vertical space) formatting does indeed explain the difference.

bonzini

First experiences with QEMU suggest ~10% more lines of code.

kccqzy

Not surprising to me. While learning Rust, I rewrote in Rust several existing programs I had written in C++ and all of them were longer with default formatting.

nticompass

As a zsh user, I've been meaning to give fish a try. I keep adding plugins to zsh to make it act like fish (like command autocomplte) that I might as well try and/or switch to it.

giancarlostoro

My only annoyance with fish is when I copy bash one liners and forget, and get errors or issues. Otherwise, fish is fantastic.

abound

The most interesting thing about Fish 4.0.0 for most people will be that it is now written in Rust, which they talk about here [1]. Looking forward to testing it out and seeing if there are any noticeable differences.

[1] https://github.com/fish-shell/fish-shell/pull/9512

markstos

I'll be curious if it's faster.

robin_reala

It’s broadly the same speed currently, but the goal was always to do a simple port to start with, then iterate from there.

darthrupert

Faster than previous C++? Only if there were actual performance bugs that they fixed while doing the port.

enriquto

> The most interesting thing about Fish 4.0.0 for most people will be that it is now written in Rust

tbh, the rust rewrite is a shortcoming for me. I was fish-curious (as a user of zsh) but after the rust rewrite I lost all interest. I just dislike, on a very deep level, the rust toolchain. Not the language! Rust is a beautiful language, a kind of "sane" C++. But somehow its community has inherited the worst traditions of javascript (which is another nice language with awful traditions).

RUST RULES, CARGO SUCKS

lolinder

In what way does fish being built with cargo affect you as (not even) a user? Were you fish-curious in that you were interested in becoming a contributor? Or do you make a habit of judging projects that you might be interested in using based primarily on their build system?

akdor1154

I dont like lisp but hackernews is still fine to browse?

dmd

Why would you care what it's written in at all, unless you plan to work on it yourself?

lytedev

The same reason you might care about the artist or producer of a song: its context generally implies certain characteristics you might associate and appreciate.

For example, most Rust projects use clap which provides really nice command line help menus and also have good performance in general.

arbitrandomuser

What does it matter which tool-chain they use . I can understand if the difference is it made it notably slower or they dropped some features because they couldn't get it done in rust . But purely as an end user why would it matter if it's written in rust or cpp ?

darthrupert

Everyone is entitled to opinions of course, but this is a rather weird one given how Rust's toolchain is the thing most people like most about it.

benrutter

What do you dislike about it?

xigoi

It encourages adding hundreds of dependencies to every project, taking up gigabytes of storage, making compilation slow and resulting in bloated binaries with potential vulnerabilities.

johnnyjeans

the only vcs it supports is git

enriquto

quadratic dependency encouragement

albertzeyer

> However, there should be no direct impact on users.

I find this quite impressive, that they rewrote the whole Fish core, but everything keeps working exactly in the same way (except very few minor things which change in only minor ways, which they list).

nicce

If they managed to keep all the bugs as well and not to reduce them, that would be especially impressive.

robin_reala

If you use Homebrew it’s not available there yet, but it’s being added. See https://github.com/Homebrew/homebrew-core/pull/209124.

apatheticonion

You can just get the binary from the github, it's just a single executable! Or compile it yourself with one command (cargo build --release)

Cthulhu_

That's fair but having a package manager manage all your dependencies makes maintenance and hygiene easier.

oersted

I've used Fish for many years, but frankly only for the great autocompletion. The streamlined theme/prompt system and oh-my-fish plugin management are quite nice too, but minor.

The rest of Fish features that are not bash-compatible are rather a pain, particularly environment variable management. In principle these features have a better design than in bash, but not that much better, and their use is infrequent enough to have to re-learn them every time. Unfortunately, they just end up being a minor inconvenience when you try to copy-paste setup instructions from docs, and I don't interact with these features otherwise.

rainingmonkey

It's the opposite for me; things that are intuitive in Fish would involve inscrutable magic incantations copied from StackOverflow in Bash.

If you only want to use Fish for the autocompletion though, you can! Bash is always still there alongside Fish, you can just open a Bash shell when you're copypasting instructions, or `bash $SCRIPT` any scripts.

homebrewer

ZSH is pretty compatible and has great auto completion. The best thing for me is inline documentation (bash-completion only shows the list of available completions and you have to derive their meanings by yourself).

It's also much easier to write your own completion scripts than for bash. The syntax is relatively sane, although fish completion scripts are much cleaner than bash or ZSH.

Stick to plain ZSH to avoid losing performance on bloated mess like oh-my-zsh, add fzf to quickly dig through history and find files/directories, and it's really the best option we have.

linsomniac

This.

I've been using fish as my primary shell for a couple years, primarily for the autocompletion. I started off with some zsh plugins that made the shell TOO fancy (and slow). I'd really like to see it be compatible but with some compelling improvements, rather than having them be just incompatible. Every time I can't do $() or fi... But for anything slightly complex I'll drop back down to bash rather than figure out the fish way to do it, because those things are rare enough that I have a hard time keeping them in my head.

I guess I could ask an LLM how to do it in fish, but for things that I already have stuck in my head it's just easier to drop to bash.

drcongo

Can I ask what you find difficult about the environment variables system in Fish? Personally I find it absolutely lovely to use.

BiteCode_dev

The better syntax used to be a selling point, but now with AI being able to generate any trivial one-liner and minor scripts you need on a day-to-day basics, have a bad syntax would only affect bigger projects, which I would not write in Fish shell anyway.

It's a hard sell.

tomsmeding

Generative AI might be able to generate them, but it's still on you to understand the result and check that it indeed does what you want. And with the sometimes very nuance- or foot-gun-rich syntax of bash, that's rather a significant burden, if you're not familiar enough with the syntax to write the script yourself in the first place.

do_not_redeem

Speak for yourself, but I would not want to be beholden to AI for every trivial shell one-liner. "Sorry boss, ChatGPT is down, I can't count how many *.txt files are in this directory. See you tomorrow!"

I'll take the better syntax, thanks.

queuebert

Heaven forbid you read a man page. Even though Bash is weird, it's fully documented.

kibwen

Scripting languages are so dynamic, flexible, arcane, and subtle and the consequences for getting scripts wrong are so potentially catastrophic for a system that they are absolutely the last thing I would ever dare generate via LLM.

guytv

Can someone from the team share how the dev coordination for the Rust migration was handled? I only see a single PR (#9512)—how was the work organized?

OptionOfT

`clear-commandline` is an interesting one. It's a struggle between Windows and macos to maintain some form of consistency, and I failed to use Karabiner properly.

I'll have to check later today what now the default `cancel-commandline` is set to.

ripped_britches

Bravo, love me some fish shell

m00dy

I recently built my own shell to better understand its complexity and how it works under the hood. I also implemented redirections and partial tab completion. While I get that writing a shell isn’t the easiest task, I still don’t fully understand why there are so many different ones. I’ve been using the default shell on macOS, and so far, it works just fine.

johnnyjeans

different tastes.

jitl

Some people like nice things

pbronez

The rustport blog post says they lost support for Cygwin because it's not a supported Rust target. Looks like there is a fork for this:

https://github.com/ookiineko-cygport/rust

There have been discussions about adding the target to Rust, but they have not been pursued:

https://github.com/rust-lang/rust/issues/79854

https://github.com/rust-lang/rust/issues/5526

faho

The rust cygwin target has been merged (in a different attempt): https://github.com/rust-lang/rust/pull/134999

diimdeep

Let's guess which one compiles slower