[ale] Bash vs Perl

Byron Jeff byronjeff at clayton.edu
Wed Oct 26 11:37:27 EDT 2016


Some snippage...

On Wed, Oct 26, 2016 at 02:05:35AM -0400, Steve Litt wrote:
> On Tue, 25 Oct 2016 11:01:40 -0400
> leam hall <leamhall at gmail.com> wrote:

> > Hey Steve, that was sort of my point. If the fork is run once a day
> > and takes 5 minutes instead of 2, is that really a problem? Granted
> > there are much better technical solutions, but if you only have so
> > much time to code, is the performace gain worth the effort?
> 
> Exactly! Bash is great for most stuff. The exception is iterating
> through a directory with a thousand or so files, and for some reason
> run the test executable on each. That could take 10 minutes for bash as
> opposed to 30 seconds for Python and 8 seconds for C (these timings are
> my best guesses).

That's sort of an arbitrary example. Bash mitigates a lot of those
performance issues ny incorporating items such as test and arithmatic
internally so that they can be executed without a fork. 

One example I use in my class is comparing arithmetic mode in bash to expr.
I start a counting loop using expr in one tab, then start explaining all of
the issues that expr brings to the table, including the fact that it's so
slow to execute. About 5-6 minutes in I explain about bash's arithmetic
mode using $[] notation and it's advantages. Finally after 10 minutes or so
I generate the same counting loop using arithmetic mode. Typically it only
takes that second loop about 30-45 seconds to catch up and surpass the
original loop using expr and fork.

So it's absolutely slow to fork a ton of times. However in many
circumstances, bash offers internal structures that can mitigate those
issues.

BAJ


-- 
Byron A. Jeff
Associate Professor: Department of Computer Science and Information Technology
College of Information and Mathematical Sciences
Clayton State University
http://faculty.clayton.edu/bjeff


More information about the Ale mailing list