Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is bash language often slower than python or ruby?

I assume it is because of the interpreter's implementation. Can anyone give me a more in-depth answer please? Thanks.

Also, I wonder if bash has a garbage collector?


1 Answers

bash loads a large number of commands from disk. Most other scripting languages have many more instructions that they run internally.

For example, to do a simple computation in bash, you'd use a=`expr 1 + 2` and bash will first load /usr/bin/expr, run that command which writes the result in the output, bash collects the output (the ` quotes) and saves the result in the variable 'a'. That's definitively slow.

The advantage of bash is the incredible flexibility though. Each person may have a different set of powerful "instructions". For example, I have a small tool called hex to print out numbers in octal, hexadecimal and decimal all at once. Other languages would not integrate in the way bash does...

like image 88
Alexis Wilke Avatar answered May 01 '26 09:05

Alexis Wilke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!