What tool to use?

Björn Lindberg d95-bli.no.spam at nada.kth.se
Sun Aug 11 02:28:09 PDT 2002


Rob 'Feztaa' Park wrote:
> 
> Alas! Björn Lindberg spake thus:
> > > Thanks Rob, this works great.
> 
> No problem.
> 
> > Correct. You can write both dc and sokoban in sed (it has been done),
> > together with awk and shell scripting there simply is no need to ever
> > touch perl. :-)
> 
> Well, aside from the fact that perl is a million times faster than bash,
> sure.

What I meant is that for simpler text file manipulations, you can write
the entire program in sed or awk, which should be fast enough, esp sed.
Bash (or Korn Shell for that matter) can be pretty fast if you manage to
use the built in functionality, and avoid too many external program
invocations.

Actually, if you check out the first link I posted, it is really
impressive what the "sedders" manage to get sed to do. One person has
written an implementation of dc (the reverse Polish notation calculator)
entirely in sed, complete with arithmetic calculations. It is obvioulsy
not fast though, but shows that sed is capable of far more than the
usual s/// substitutions it is normally used for. Oh, and another person
actually wrote the game "sokoban", also entirely in sed. :-)

Awk, then of course, is a complete programming language that can be used
for most high level programming tasks. (But it's better suited for
certain tasks, just like any language).

Anyways, don't want to start a holy war here. Only pointing out that the
good old UNIX tools often solves a problem at least as well as Perl
does. Any tool that solves the problem is good, of course. :-)

Speaking of speed, have you seen this cool link:

	http://www.bagley.org/~doug/shootout/

It is a collection of benchmark tests performed on a large selection of
languages. Maybe not of much practical importance, but fun nonetheless.


Björn
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe blfs-support' in the subject header of the message



More information about the blfs-support mailing list