When Software Doesn't Add Up

by Marco Tabini (2006-10-24)
  Page: 1  2  [next]

Good ideas tend to be very simple, both in principle and in practice. Take, for example, hydrogen-based energy. The production of hydrogen is extremely simple—in fact, you could produce your own hydrogen by electrolysis with nothing more than a clever set up, plenty of distilled water and a bit of electricity—this simple chemical reaction gives pure oxygen as a byproduct, and the burning of hydrogen in air produces nothing more harmful to the environment than a bit of steam.

Yet, of course, our entire economy is based on fossil fuels, which are largely inefficient, pollute like there's no tomorrow (and there might well not be one) and are certainly a far more finite resource than water. All political and economical considerations aside, fossil fuels were much more readily available when the need for cheap and abundant energy arose—man having been used to burning things for fun and profit since the dawn of time—but that's hardly a consideration that can be made today: if you consider the complexity of the infrastructure that delivers gasoline to your local station—from production, to refinement, to transportation, it's clear that hydrogen-based delivery would be much simpler; in fact, each “delivery station” could well produce its own hydrogen, without requiring any sort of delivery infrastructure whatsoever.

I didn't write up this introduction because I felt like typing up a pro-environment tirade—I wanted, in fact, to make the very simple point that it's interesting to see how easily mankind seems to get stuck into a less-than-optimal solution to a problem because of the perception that replacing an existing infrastructure would be so expensive and cumbersome that it's better to stick with the current solution and find sometimes ridiculously complex workarounds to overcome its shortcomings.

Let me give a simple example that will, hopefully, strike a bit closer to home. Consider a very simple application that does nothing more than adding up two numbers and returning the result. This is about as stupid a script as you can write without entering “Hello, world!”-land. Of course, at its simplest, this script would look like nothing more than this:

  1. <?php
  2.   $a = 10;
  3.   $b = 20;
  4.  
  5.   echo $a + $b;
  6. ?>

Note that, a this point, the script is, essentially complete—that is, the underlying goal (calculating the sum of two numbers) has been achieved. Of course, this would be pretty cryptic—it would be next to impossible for someone using the script (without seeing its source) to determine what it does. Therefore, we might want to add a slightly more verbose output:

  1. <?php
  2.   $a = 10;
  3.   $b = 20;
  4.  
  5.   echo "The sum of $a and $b is " . ($a + $b);
  6. ?>

Unfortunately, this would be most unsatisfactory—we would, in fact, need to somehow find a way to allow the user to input the values to be added. Thus, we might end up doing something like this:

  1. <?php
  2.   $a = $_GET['a'];
  3.   $b = $_GET['b'];
  4.  
  5.   echo "The sum of $a and $b is " . ($a + $b);
  6. ?>
File under: art  exit(0) 
  Page: 1  2  [next]

Comments

There are no comments on this entry.

Visit the forum