Computers, Science, Technology, Xen Virtualization, Hosting, Photography, The Internet, Geekdom And More

Why my programs are usually bourne bash

Posted on | October 10, 2007 | No Comments

Many things that I write and release freely start out as bash scripts. While working, I rely heavily on bash. Many people have e-mailed me to ask “Why don’t you use python? Why don’t you use perl? Didn’t you know that PHP was useful as a scripting language?” To those folks, I can only answer a question with a question and answer:

Q: How many system integrators does it take to write a program?

A: 12. One to do it, eleven to tell the one who did it how he could (or should) have done it.

I need to take many things into consideration when I write a program:

  • What is the programming skill level of those who might need to modify or debug whatever it is that I’m writing?
  • How much memory do I have to work with? Can I get by with something ‘forky’ that calls other programs notorious for over-malloc()’ing their way to dirty pages?
  • How much am I getting paid to fix whatever this program is fixing? Many times, I’m paid a quoted price and need to have it ‘fixed’ within x amount of hours.

If it runs on a computer, it delights in breaking while you are trying to sleep. Nearly every self-respecting GNU/Linux system administrator in the world can figure out a semi-well commented bash script. They can also (usually) find their way around perl, sometimes they can find their way around python. PHP is huge for scripting unless your using something like Roadsend (with bigloo) to produce a sensible ELF executable. The point, I don’t want a phone call at 3 AM to fix something trivial.

I’ve worked on utilities such as grawk which help me to compensate for not having much ‘elbow room’ and cutting fork / malloc() rates in pipes. I don’t use grep, awk or other similar things unless I need something that grawk can’t do. Bash + SQlite is a very good combo.

Bash has arrays (though not nested), basic built in regular expressions, easy ‘natural’ syntax and is extremely forgiving, a great tool to get something put together that ‘just works’ quickly. If my band-aid turns into a useful stand-alone utility, I often re-write it in C.

When I produce free stuff geared for system administrators, I produce it in hopes of many people finding it useful. I’m not going to sacrifice usership for a few miliseconds, unless I really need those few miliseconds. I want people from amateur to pro to be able to work with my stuff, so I try to write it as simply as possible. To work with a program (to me) means, I can download it, compile it and modify it to do what I want within a few hours.

Take another look at bash. Sure, you need to write a (bit) more code however it can usually get most simple jobs done quickly. I use it for back end stuff, or even generating web pages from sqlite databases.

Hopefully, this post addresses the questions that I received :)


Leave a Reply

  • Monkey Plus Typewriter
  • Stack Overflow

  • Me According To Ohloh

  • Meta