Saturday, October 03, 2009

The Swiss Army knife Programmer

MacGyver was unlike secret agents in other television series and films because, instead of relying on high-tech weapons and tools, he carried only a Swiss Army knife and duct tape.
[Wikipedia, MacGyver page]

After the infinite series of Duct Tape Programmer articles that has been populating my Google Reader last week, I've decided to write about a similar class of programmer who you surely know some instance of.
Just like MacGyver, the Swiss Army knife programmer carries his preferred tool along with a stock of duct tape, which as Joel says represents the using large amounts of duct tape to keep together the pieces of an application mindset.
Armed with his tool, which contains screwdrivers, a can opener, a magnifying glass, an altimeter and an mp3 player, the SAK programmer goes on and on and uses it for every task he has to do. When he has a new business idea, it involves the use of his tool to conquer the world. When he has to carry out a boring, obvious task, he tries to squeeze in his tool in some way.

Practically speaking the equivalent of Swiss Army knife is a programming language or particular technology which is overused, in applications where it is out of scope. A big toolbox is better than a Swiss Army knife if you know how to use all the tools contained instead of carrying a small one which promises to do everything you need.
These are examples of Swiss Army Knife cases:
  • using php for gtk applications. The php gtk extension, which contains the bindings for the gtk graphic library, is an edge project which provides the capability for php to build desktop applications with windows and buttons on the machine where it is run. Certainly the developers of this extension are having a lot of fun taking php to its edge, but php is a language where the interpreter comes with a default max_execution_time directive set to 30 seconds. I don't think the core developers were thinking of a php script which runs for hours when designing the engine.
  • usage of IDEs in every situation, when a bit of command line fu can solve problems efficiently and quickly. NetBeans and Eclipse try to provide every feature a developer needs in a single application, also via plugins: this resembles a overloaded knife. NetBeans here is a bit better then Eclipse in the sense that it takes avdantage of command line applications like svn.
  • the opposite overusage of command line fu when opening a text editor and doing a find&replace is enough.
  • Google Chrome operating system, which relies on web based applications only. Cloud computing is great and I strongly believe web applications are the next big thing: Gmail is proving it every day. But these kind of apps are probably not capable, at the moment, to replace every binary on your machine. Try to edit a video via web.
  • Design patterns are great standard solutions for object-oriented languages pitfalls, but their overusage can plague a code base. Factories (for entities) and above all Singletons can and should be limited to the cases where they provide real value.
  • I once fell in love with the Dojo grid and I tried to use it for every management application I could think of. It can be a serious issue if you are unaware of being a Swiss Army knife programmer on certain technologies, when you find yourself as an advocate in a religion war.
There are very few general-purpose technologies that can be used in nearly any project, and they are usually built from scratch to solve analogue and generic project management issues:
  • Subversion and other source control systems work well in many situations. As the name says, source code files were the original subject of version control, but Git and Subversion have expanded their dominion on wiki formatted documentation, xml configuration files and plain text. A common suggestion is  to put everything you cannot build under source control (and this leaves out binaries, fortunately).
  • Trac and Bugzilla can be used for every software project. Though, their scope is limited to software project management and for instance a novel developed with the help of Trac is a strange thing (unless it is written from a group of authors who need a communication tool). The power of such software is in facilitating communication between developers and usage from a single user is likely to be an overkill.
The power of open source applications resides in the reuse of code and libraries and even of entire projects in incredibly different fields, like in Subversion's case. But before stretching a technology over its limits, think if you are really using the right tool for the job.

Not so strangely, searching "the right tool for the job" on Google shows the first result is "Lisp is the best tool for large (and small!) projects."


Jani Hartikainen said...

I think having a "swiss army knife" is useful for programmers as it'll allow you to solve various things easily and efficiently, but you are right when you say that using it for everything can be a bad thing.

Talking about MacGyver, I've written a post about MacGyver and programming

Giorgio said...

Jani, wonderful things can be done with lisp/bash scripting/COW programming language. The problem comes when the code has to be maintained by someone else than the original creator. :)