5 ms·
Fish 4
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- abound 2y agoThe 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 https://github.com/fish-shell/fish-shell/pull/9512
- markstos 2y agoI'll be curious if it's faster.
- robin_reala 2y agoIt’s broadly the same speed currently, but the goal was always to do a simple port to start with, then iterate from there.
- darthrupert 2y agoFaster than previous C++? Only if there were actual performance bugs that they fixed while doing the port.
- rootnod3 2y agoWhat makes you think so? The Rust compiler is able to instrument LLVM a lot better and provide it with a lot more info than C++ can. The borrow checker does a lot of the work there to for example keep things on the stack or do LSE or GSE and other optimizations. It isn't just about "oh, the rewrite allowed them to restructure things and optimize the algos". It is also that Rust due to its nature is able to be absolutely damn fucking sure that it can remove or optimize certain parts, whereas C++ can't in many cases.
- steveklabnik 2y agoAdditionally, some people shared that they feel more comfortable making more aggressive optimizations in their Rust code because the borrow checker has their back. Stylo was tried twice in C++ before the Rust attempt, and it never worked out, because the threading was too hard to get right. In theory you could have done it. But in theory, theory and practice are the same, but in practice, they’re different.
- vanderZwan 2y agoIIRC, you yourself commented a few years ago in a thread on HN that the Rust situation was still a lot like "because of certain guarantees Rust makes we should be able to perform tons of optimizations that C++ could never do, and we haven't even gotten around to implementing most of them yet", has that situation improved a lot since? ("a few" might be off by pre-pandemic amount of years, my memory is a bit fuzzy there)
- steveklabnik 2y agoI vaguely remember that :) It's progressed in the sense of like, the Unsafe Code Guidelines and opsem teams are hammering down the exact semantics still, and have made a lot of progress. I'm not aware of any actual optimization work taking place off of it yet, which would make sense given that it's not all fully hammered out yet. I also might have been handwaving towards how restrict kept having to be turned off because it was broken, meaning very few C or C++ codebases seem to use it at all, whereas virtually every Rust reference has it on. It's been back on for a while now.
- vanderZwan 2y agoYeah I forgot the exact context of the quote too, no worries :). EDIT: it probably had something to do with aliasing and alignment (because when aren't people sighing about C/C++ when it comes to that topic?) Thank for the general update! I might not write any Rust code myself, but I do enjoy quite a few programs written in it, so I was hoping to hear there was more progress for the sake of the developers behind those programs. But I can also imagine that these kind of things take time to figure out properly, to avoid repeating mistakes of previous languages (and that's before we even get to the task of implementing anything). Wish the people working on these issues all the best, and looking forward (from the sidelines) to what eventually comes out of it!
- bjoli 2y agoAnecdote time: I did a test like this with a small hobby project of mine (c++). I ported it to rust and saw roughly a 25% speed increase because of some refactorings I was meaning to do for a long time. I then ported the rust code back to c++ and saw another 15% gain in performance. Backporting the changes to rust again yielded no significant difference. I am no rust programmer though, and I don't think the rust code was very idiomatic. But then again I apparently write c++ like a common lisp programmer...
- enriquto 2y ago[flagged]
- benrutter 2y agoWhat do you dislike about it?
- enriquto 2y agoquadratic dependency encouragement
- xigoi 2y agoIt 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 2y agothe only vcs it supports is git
- steveklabnik 2y agoThe —-vcs flag to cargo new supports git, hg, pijul, and fossil. It’s true that dependencies from a repository only supports git right now. Part of the issue there is just like, the VCS integration wasn’t don’t in a principled way (it happens!) and so it’s not simple. See here for more: https://github.com/rust-lang/cargo/issues/12102 https://github.com/rust-lang/cargo/issues/12102
- johnnyjeans 2y agono darcs? and this is why i really loathe language package managers, because they're prone to this kind of thing. assuming one has no problems with the opinions made in a language itself, when it has a tightly bound package manager embedded into it's ecosystem (using rust without cargo is like pulling teeth) you have an entire extra hurdle of far more rigid and controversial opinions to deal with. package managers are maybe next to shells with "it's several orders of magnitude harder to make a good one than it is to write a compiler." with the dozens, possibly hundreds of package managers i've touched over the years, there's only been one that i'd call "good". the absolute worst ones have always been language package managers. at this point i've basically written off the concept, even system package managers.
- nindalf 2y agoFish 4.0: The Fish Of Theseus (https://fishshell.com/blog/rustport/ 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 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 2y agoI'm surprised Rust took more lines. Perhaps formatter makes shorter lines due to method chaining? Or improved test suite?
- dartos 2y agoRust, 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_ 2y agoEfficient LOC shouldn't be a goal or metric anyway, readability trumps conciseness... except when conciseness improves readability.
- rootnod3 2y agoAgreed. I would rather be forced to explicitly cover all match cases than accidentally run into problems that are hard to debug.
- pmarreck 2y agoExactly. I wish all languages implemented things like this, a bit more strictness (such as requiring all possible match cases to be handled across a set of inputs) goes a long way
- oersted 2y agoI'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.
- BiteCode_dev 2y agoThe 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.
- do_not_redeem 2y agoSpeak 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.
- guytv 2y agoCan 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?
- bitdivision 2y agoThere's some context here: https://news.ycombinator.com/item?id=38423908 https://news.ycombinator.com/item?id=38423908
- albertzeyer 2y ago> 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 2y agoIf they managed to keep all the bugs as well and not to reduce them, that would be especially impressive.
- jorvi 2y agohttps://xkcd.com/1172/ https://xkcd.com/1172/
- kccqzy 2y agoI don't feel this is impressive. In Big Tech companies it's common for a team to rewrite an entire microservice without having any impact on users. Sure, a lot of that is for political reasons and unnecessary from a business perspective, and perhaps is selfish from a promotion perspective, but it's done very often.
- queuebert 2y agoI was expecting issue #9512 "Rewrite it in Rust" to have been submitted on April 1.
- Ygg2 2y agoIt's not too late for "Rewrite it in Zig" or "Rewrite it in Ada".
- queuebert 2y agoOr "Revert back to C++" would be funny. Apparently no one around here has a sense of humor, though, since my original post was heavily downvoted. I greatly prefer Rust over C++, but "rewrite it in Rust" has become kind of a meme. And if you can't laugh at yourself, who can you laugh at?
- deleted 2y ago[deleted]
- robin_reala 2y agoIf you use Homebrew it’s not available there yet, but it’s being added. See https://github.com/Homebrew/homebrew-core/pull/209124 https://github.com/Homebrew/homebrew-core/pull/209124.
- apatheticonion 2y agoYou 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_ 2y agoThat's fair but having a package manager manage all your dependencies makes maintenance and hygiene easier.
- chanux 2y agoIt has merged!
- simon04 2y agoNice, it has landed. Now I'm getting: > warning: Could not set up terminal for $TERM 'xterm-ghostty'. Falling back to hardcoded xterm-256color values
- ripped_britches 2y agoBravo, love me some fish shell
- diimdeep 2y agoLet's guess which one compiles slower
- darthrupert 2y agoOn my Macbook M1 Pro: - fish 4.0.0 / Rust: (cargo build): 16 seconds - fish 4.0.0 / Rust: (cargo build --release): 37 seconds - fish 3.7.1 / C++: cmake ..: 10 seconds + make -j8: 13 seconds = 23 seconds So yeah, C++ was slightly faster in release mode, but slower in non-release. I'd say this is yet another win for Rust, frankly.
- cemdervis 2y agoCMake + Ninja?
- m00dy 2y agoI 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.
- jitl 2y agoSome people like nice things
- johnnyjeans 2y agodifferent tastes.
- Philpax 2y agoThe second half of this comment reaches the opposite conclusion to what I would have expected from the first half.
- t43562 2y agoThe original one (bourne) had a great number of limitations and yet as part of a standard it didn't see much change. Everyone wanted something better and each person had an idea of what better was. bash became quite common because it's a superset and its' offered by GNU whose other tools made up for many other deficiencies in the various commercial UNIX implementations. Then FreeBSD and Linux made GNU stuff the default and that was a big boost. I tried fish couldn't really be bothered to persevere. A lot of the things I didn't like about bash were because I hadn't understood various bits and the more I know the more I find it fairly powerful and it has a kind of consistency. I don't love it but I found myself suddenly disempowered with things like fish.
- mamcx 2y agoI go another notch: Why are so many different ones with so little major changes. If you experience the `shell` of FoxPro DOS or other tools you will see how poor are the ones we tolerate now. Is like we still live in the age of `ed`. (I even remember one of this projects have the joke that is finally a `terminal for the 90s!` or something like. Shells in common use a very poor things!)
- OptionOfT 2y ago`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.
- pbronez 2y agoThe 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 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/79854 https://github.com/rust-lang/rust/issues/5526 https://github.com/rust-lang/rust/issues/5526
- nticompass 2y agoAs 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 autocomplete) that I might as well try and/or switch to it.
- giancarlostoro 2y agoMy only annoyance with fish is when I copy bash one liners and forget, and get errors or issues. Otherwise, fish is fantastic.
- porridgeraisin 2y agoThere's a nice way to halfway-fix that issue. It makes use of the fact that most bash commands that we copy are prefixed with a $ and a space. It also requires your terminal emulator to have a way to hook into the paste mechanism and edit the to-be-pasted text. To my knowledge, Kitty and iTerm both have this feature. Basically, the terminal will replace each line of the pasted text that match (start with) $ rest with pbash 'rest_escaped' or more elegantly \$ 'rest_escaped' We will then define a function with either of these names in fish. This function will start (if not exists) a persistent background bash instance connected on both ends to FIFOs, with the same lifetime as your fish session. We then pass the `rest_escaped` to one FIFO, capture the output from the other FIFO, and echo it. Because its a persistent session, stuff you copy that makes use of variables or bash aliases all Just Work. Being able to blindly copy-paste the entire bash codefence from a github readme.md is especially nice. It all happens automatically after a one-time setup, and overall works pretty well for me. Here is a demo: https://i.imgur.com/HdqGkRk.png https://i.imgur.com/HdqGkRk.png This is the fish function function \$ if not test -f /tmp/bash_daemon.pid; or not kill -0 (cat /tmp/bash_daemon.pid) 2>/dev/null echo "Starting bash daemon..." bash ~/scripts/bash_daemon.sh & sleep 0.5 end echo "$argv" > /tmp/bash_daemon_pipe & while read -l line if test "$line" = "###DONE###" break end echo $line end < /tmp/bash_daemon_out end And this is the bash script `~/scripts/bash_daemon.sh` #! /usr/bin/env bash rm -f /tmp/bash_daemon_pipe /tmp/bash_daemon_out mkfifo /tmp/bash_daemon_pipe mkfifo /tmp/bash_daemon_out echo $$ > /tmp/bash_daemon.pid while true; do read cmd < /tmp/bash_daemon_pipe { eval "$cmd"; echo "###DONE###"; } > /tmp/bash_daemon_out done
- deleted 2y ago[deleted]
- dgregd 2y agoA question for people who have already switched to the fish shell: What is the biggest drawback of using fish? For example, you get accustomed to it on your system and then have to work with Bash or Zsh on your company’s server systems. And if I’m going to make such a big switch from Bash to fish, then why not switch to Nushell instead?
- iN7h33nD 2y agoBiggest drawback is unfamiliarity with the syntax, but that comes with time in my experience. I think the syntax is overall better and much better documented. I switched to fish because for most interactive use case it’s so much better, without requiring any new muscle memory. I tried zsh at first but it winds up slow to get even close to where fish is out of the box. I still end up scripting in bash or sh for portability. nu-shell won’t be available in as many places, and it looks to me like it would change paradigm in a way that would hinder working with bash or zsh over time. That’s just my 2c though as I have only briefly glanced at it and haven’t truly considered using it.
- timlyo 2y agoI use Fish as a user shell everywhere I can and end up using Bash daily for scripting and on servers/VMs/containers at work, I've also been using Nushell a lot recently for personal scripts. Biggest drawbacks for me is mixing up a few bits of syntax and some software doesn't ship Fish completion scripts, although I never write scripts in Fish which reduces the syntax I actually use. In my opinion Fish is worth it just for the auto complete suggestions alone, but I also really like the way it handles editing config, it's sane default config, understandable error messages, and plug-ins. Nushell is very nice, but I find it doesn't match the usability of Fish for interactive shells. Love it for scripts though.
- maleldil 2y agoThe main drawback is that I'm used to all the goodness that comes by default and have to get used to how primitive Bash is when I'm forced to use it. I also prefer fish's scripting syntax (and built-in utilities) over bash, and some people don't like installing fish to run my scripts. Nushell is far from fish in terms of interactive usage, and I find the scripting language to be too unstable for writing scripts you want to keep in the medium term.
- xigoi 2y agoHow much larger is the binary after rewriting it in Rust?
- maleldil 2y agoThe Rust version (4.0.0) has 73k lines of Rust, builds in 1m34s, and the binary is 4.3 MB. The C++ version (3.7.1) has 55k lines of C++, builds in 1m8s, and the binary is 2.4 MB. Both were built with CMake with default settings on a MacBook with M1 Pro. So, the new binary is 1.8x in size and takes 1.4x of the time to build.
- yencabulator 2y agoTab completing "car" to "blkdiscard" just because I don't happen to have "cargo" in that $PATH is pretty nasty. How do I force tab completion to prefixes only?