help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simpler question about my script


From: Greg Wooledge
Subject: Re: simpler question about my script
Date: Thu, 17 Feb 2022 21:11:42 -0500

On Fri, Feb 18, 2022 at 12:06:05AM +0100, Sysadmin Lists wrote:
> > ----------------------------------------
> > Message: 1
> > Date: Tue, 15 Feb 2022 17:17:19 -0600
> > From: Dennis Williamson <dennistwilliamson@gmail.com>
> > To: Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
> > Cc: help-bash <help-bash@gnu.org>
> > Subject: Re: simpler question about my script
> > 
> > A few tips (some are specific to shell scripts):
> > ....
> > Avoid being clever. Clarity is important. Avoid side effects whenever
> > possible.
> > ....
> > Know when and why to bend the rules, but keep it to a minimum.
> > 
> > Some of these tips are intended to draw a distinction between command-line
> > use where brevity has value and scripting where clarity is a higher
> > priority.
> 
> That's an excellent list except for the (qualified) part about cleverness, 
> IMO. If you read through old (I mean 70s and 80s) code, it's stuffed with 
> cleverness. Being clever forces a deeper understanding of the language in 
> use, forces brevity, and forces tight flow-control. It doesn't take away from 
> readability if you comment your code well (which is also a dying art probably 
> tied to the advice about cleverness). I see "avoid being clever" becoming "be 
> lazy" in the real world.

I agree with Dennis here.  What you think is "clever" today is "unreadable
gibberish, what the hell was I thinking" 6 months from now.  You're just
hurting yourself.

Also bear in mind that programs written in the 1970s may have needed to
work on extremely limited or bizarre systems.  Couple that with compiler
optimizations being quite poor, and you had people trying desperately
just to get *anything* to work.  It's not a fair comparison to today's
needs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]