From: Seebs on 18 Jun 2010 19:22 On 2010-06-18, John Kelly <jak(a)isp2dial.com> wrote: > On Fri, 18 Jun 2010 00:32:52 -0400, Barry Margolin <barmar(a)alum.mit.edu> > wrote: >> Design your code well first, and optimize it if performance turns >> out to be a problem. > That's like saying, design your skyscraper well first, and if it > collapses and kills a lot of people, then its performance turned out to > be a problem. I don't think it is. In a reasonable development process, you'll have plenty of time to think about, and evaluate, and test, performance. The nature of the majority of performance enhancements is that they complicate code, introducing additional points of failure, and making the code less reliable. Doing that is often a bad idea. Performance hackery introduced without a clear understanding of the actual performance characteristics of the code under discussion is often totally wasted, as well. At one point, for a writing project, I spent a day or two hand-tuning a chunk of mathematical code to use a vector processor. I got a significant speedup. Then, having done that, I made a much smaller, simpler, change to the algorithm itself, which got about three times as much speedup and took an hour including testing and debugging... If I were going to use the analogy, I'd say that worrying about performance during initial design is like building a skyscraper and, at every point in the build process, stripping out or reducing the specifications for structural components to save costs, and hoping that nothing goes wrong as a result. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Seebs on 18 Jun 2010 19:23 On 2010-06-18, Martin Vaeth <vaeth(a)mathematik.uni-wuerzburg.de> wrote: > Especially if efficiency is an issue, you should code according > to the standard: Running your script with dash instead of bash > will speed it up probably more than using some bashism. This is an extremely important point to keep in mind. The performance gap between bash and dash is enormous, and very often trumps the performance enhancements you can get from using bashisms. That said, I wouldn't say that dash is all that commonly installed; however, it doesn't matter, because a script written to the standard will work whether or not you have dash. A decent shell script will usually run perfectly well in any of ash/dash/ksh/bash without hassle. It'll probably be faster in ash/dash, and possibly in ksh, and slower in bash, but it'll run everywhere. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Seebs on 18 Jun 2010 19:28 On 2010-06-18, John Kelly <jak(a)isp2dial.com> wrote: > Most scripts are useful only in a particular local environment, and will > never be ported. This is an interesting claim. Could you point out your supporting evidence? I'd love to know if this were true. > If the script will never be ported, portability has no > value. I'm not sure this is true. Portability implies following standards. A script which is never ported may nonetheless be maintained, and one which follows standards is likely to be easier for a newcomer to maintain than one which relies on specialized knowledge. To use an example from another field, consider debates about C99 feature usage. In a recent project, I decided to use a few C99 features because they dramatically improved the clarity of some code -- but in so doing, I created a barrier to maintenance by people who weren't familiar with those features, and many people had never seen them before. I'm not totally sure I made the right choice, even now, although on the whole I think it was a good call. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Maxwell Lol on 19 Jun 2010 06:54 Sven Mascheck <mascheck(a)email.invalid> writes: > Maxwell Lol wrote: > >> Oh come on, now. shell scripts and human life? >> Are we going to refer to Nazis and Hitler next? > > ... while Seinfeld would've called some guys > a "shell nazi" in this group long ago, ha! LOL!
From: John DuBois on 19 Jun 2010 19:07
In article <hvcmp6$c56$1(a)news.m-online.net>, Marc Muehlfeld <marc.muehlfeld(a)web.de> wrote: > >how can I print n equal signs in a shell script, without using a for loop, like > >for i in `seq 1 20` ; do > echo -n "=" >done > >Is there a better way and just with bash build-ins? printf %.0s= {1..20} or if you need to use a shell variable: num=20 eval printf %.0s= {1..$num} John -- John DuBois spcecdt(a)armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ |