[kwlug-disc] fish vs bash: a progress bar from YSAP and some timing measurements
Ron
ron at bclug.ca
Sat Aug 23 03:28:18 EDT 2025
Thanks, Evan @ GTALUG, for bringing fish shell to my attention. I'm
really liking it - it's just what I needed and didn't even know it.
So, I'd mentioned it feeling faster, which William Park commented on.
Thanks William, you got me thinking.
"Feels faster" ≠ "is faster" and I thought I'd measure something.
And along comes Dave from YSAP with a great video on how to make a
progress bar in bash.
https://www.youtube.com/watch?v=aL3xdQyMs5o
I love his videos, he's highly knowledgeable and quite engaging. He make
bash scripting look fun.
I decided to implement his idea without too much peeking at the
solution, then re-implement it in fish.
Despite me saying earlier that I'd probably continue scripting in bash.
The fish syntax is *so much better*.
When I went to add a feature to the bash script, once again I got caught
up in punctuation hell, where fish mostly eschews that inscrutable mess
for things like:
$ math "10 * 5 / 100"
0.5
Note the floating point math...
When done, I ran them both with the `time` command, and bash version was
consistently faster (results at bottom of message).
However, if one takes into account dev time, fish is faster despite it
being new to me.
So it depends on how you rank run time vs dev time which is "faster",
but I'm giving the win to fish in this case.
Adding to that the luxurious interactive features and it's a no-brainer:
fish is the (my) future. The tab-completion is light years ahead of bash
(but so is the tab completion in node.js, bash is kind of lagging behind
here these days).
$ time ./progress-bar.bash
START: files count: 500 Batch size: 3
[||||||||||||||||||||||||||||||||||||||||||||||||||] 500/500 (100)%
________________________________________________________
Executed in 1.04 secs fish external
usr time 115.62 millis 545.00 micros 115.08 millis
sys time 58.08 millis 214.00 micros 57.87 millis
$ time ./progress-bar.fish
START: files count: 500 Batch size: 3
[||||||||||||||||||||||||||||||||||||||||||||||||||] 500/500 (100)%
________________________________________________________
Executed in 1.50 secs fish external
usr time 490.80 millis 0.00 micros 490.80 millis
sys time 148.81 millis 760.00 micros 148.05 millis
More information about the kwlug-disc
mailing list