Hey everyone! I'm not really a coder, but I had some fun writing a fetch script with a scroll effect. You can check it out here: [https://codeberg.org/ldm/scr0ll]. I shared it on r/unixporn, but some folks commented that it's running slow. I'm wondering if this slowness is due to poorly written code, the limitations of Bash itself, or if there's a way to optimize the script. Any insights?
2 Answers
When people complain about Bash being slow, it's usually because of how the script is written. For example, using `sleep 0.002` in a tight loop can definitely make things laggy. Bash isn't great for precision tasks like this, but you might want to try using `read -t 0.002` instead of sleep to see if that helps.
In general, Unix-like shells are slower compared to other languages, especially for graphical tasks in the terminal. While more advanced shells like BASH and ZSH offer better performance due to enhanced tools, there's still a learning curve. But don't worry, I believe you can definitely make it run faster. I'll look more into your code when I can!
Thanks! The script was faster at first, but then I had to manage ANSI formatting and it started to slow down.