Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Oct 2017 17:01:55 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Paul Pathiakis <pathiaki2@yahoo.com>
Cc:        Paul Schmehl <pschmehl_lists@tx.rr.com>, Polytropon <freebsd@edvax.de>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Scripting problem
Message-ID:  <alpine.BSF.2.21.1710111652460.80616@wonkity.com>
In-Reply-To: <1984508980.4145408.1507553196491@mail.yahoo.com>
References:  <7AB396F429EEB6890100F082@Pauls-MacBook-Pro.local> <VI1PR02MB1200B33C1F59A223B84E9153F6770@VI1PR02MB1200.eurprd02.prod.outlook.com> <8C8E7D66788801594EC0FC4C@Pauls-MacBook-Pro.local> <20171008100017.30ab5987.freebsd@edvax.de> <88D321A2CCD516AEF39DE8C3@Pauls-MacBook-Pro.local> <alpine.BSF.2.21.1710090615040.94613@wonkity.com> <1984508980.4145408.1507553196491@mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 9 Oct 2017, Paul Pathiakis wrote:

>> Quoting is sh's biggest weakness. Well, that and lack of basic data
>> structures, and the weak logical structures, and so on.
> 
> ### Well, yes and no. I consider it both a strength and a weakness. I find sh to be exactly what I think of a scripting language to be... glue. I don't
> expect to write a fully versed program in sh. I wouldn't be using sh for that. I find sh to be that 'tool' to use when I want to call other tools and
> utilities. (sed, awk, tr, etc)
> 
> ### I think people have gone way too far in creating 'scripting' languages that are more programming languages than scripting.... Personally, I tried
> learning PERL which tries to be everything to regex. The problem? Lack of coherence... "I can do this 5 different ways in PERL" Is that supposed to be a
> good thing when all five seem to execute at different speeds, using different resources, etc? (apologies to Larry Wall and the rest)

The multiple domains that are utterly different are not just in Perl. 
In sh, you can use sed and awk, which have very little overlap.  In 
fact, you pretty much have to use sed *and* awk, because each is not 
quite powerful enough to do particular jobs.  Or use Perl, 
which is a superset of both.

The trouble with sh is that it is so weak that it takes a lot of code to 
accomplish anything. That comes back to haunt the programmer in the long 
term, because simpler, shorter programs that use more powerful 
constructs are much easier to maintain.

Perl is much-maligned, but every time I rewrite a shell script in Perl 
it gets shorter and easier to maintain.  Or longer and more powerful. 
Python and Ruby are similar.

>> Someone once said that if a script is longer than twenty lines or so, 
>> it probably ought to be done in a real scripting langugage. That was 
>> me, but Stephen Bourne has also said it. Yes, that Stephen Bourne.
> 
> ### I'll go off a little on this with kind of a corollary.... No sh script should be more than 20 lines, however, I typically will call shell scripts from
> other scripts. But I do agree, if you want to program, use a programming language. (IMHO, C is still the best, most powerful language around but, again,
> read a book, talk to the people who are in the know - My 'C' guru is a guy who has written code that utterly shocked me in its elegance, execution, and
> simplicity - and the occasional "You can do something like that in C?" thoughts running through my head.)

The distinction between programming and "scripting" has always been 
artificial to me.  You write a series of instructions for a computer, 
that's a program.  Give me powerful tools, I'm not interested in doing 
it the hard way to build character.  I have enough character. What I 
want back is the time I spend trying to fix sh scripts.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.21.1710111652460.80616>