Wednesday, April 22, 2009

Earth Day

It's the 39th anniversary of Earth Day.

I found this poem to commemorate the event.

In Tune With Mother Nature

If you listen for the songbirds
As they greet the summer sun,
And love the way the wind can make
The trees sings just for fun;

If you like to hear the ocean
As it drums upon the shore,
And imagine all the whales out there,
And hope they'll sing some more;

If you think of all the animals
As players in a band,
Each with a lovely tune to play,
All needed on the land;

And know that as a boy or girl
A woman or a man
You have a vital role to play
In Mother Nature's plan;

If you honor every living thing
As a part of nature's treasure
You're in tune with Mother Nature
So let's all sing her song together.


It's interesting to reflect on how far we've come since the first Earth Day. People used to scoff at things like Solar Panels and Wind Farms. Now we embrace them. More people are realizing what a precious gift our little blue planet is. There's lots more to do. Here's to you planet Earth.

Monday, April 20, 2009

The Good Life Parable

Friday, April 17, 2009

The Art of Software Engineering

Eric Wise, of codebetter.com, wrote this article entitled "Rejecting Software Engineering" Here's a quote:

When I actually get some free time and surf around the blogosphere I often see people referring to software as "engineering". I've always had a problem with this term because it implies things about software development that simply are not. Let's take a look at Dictionary.com for a moment. re: engineering

the art or science of making practical application of the knowledge of pure sciences, as physics or chemistry, as in the construction of engines, bridges, buildings, mines, ships, and chemical plants.

So here's where the whole software engineering thing falls down for me. Building software is not like building a bridge. It's just not. In physical, "real world" engineering you have the laws of physics, near perfect information on durability, composition, balance, etc. A programmer, as Fred Brooks puts it (The Mythical Man Month) is like a "poet who works only slightly removed from pure thought-stuff". There is a plethora of languages and methods for achieving the same results in software development and none of them are exactly the same. For something to be labeled as an engineering science in my opinion, it needs to have known values and be infinitely repeatable. Software development meets neither of these.


For me, developing software is part art and part engineering. Developing a good software solution is a act of creativity, "Art" but also applied science "Engineering." Just as methods for building bridges have evolved over time, so have software design patterns. Finding creative ways to apply them is the artistic side. Just as an talented painter needs to be "inspired" to be truly creative, so do some software developers. There's a big difference in the quality between code that was inspired and code that's just barely good enough to pass. Why do you think there are books with titles like "The Art of Java." Software development is an art but it also requires engineering skill.

Monday, April 13, 2009

My sorting method

I devised this quirky sorting method while in college.

It works by first partially sorting the array then passing the result to the standard built-in method. In this case the std::sort is quick sort.

template< typename Iterator>
void hybridSort(Iterator first, Iterator last)
{
Iterator j,k;
// do a single sort iteration
j = first;
for (k=last-1; k!=first; --k)
{
if (*j > *k)
{
std::iter_swap(j,k);

}

}
// pass the result to the standard sorting method
std::sort(first, last);

}


It's really not a significant improvement over just using quick sort. In cases where the built-in sort is inefficient, it does work better.

Here's sample output of test program I wrote. It uses randomly generated arrays for the tests.

Testing quickSort size = 256 n_times = 1000
CPU cycles 171
Testing bubbleSort size = 256 n_times = 1000
CPU cycles 1032
Testing hybridSort size = 256 n_times = 1000
CPU cycles 156

Testing hybridSort

27455 8899 13631 3296 27180 12651 23352 18534
small array unsorted

3296 8899 12651 13631 18534 23352 27180 27455
small array sorted

Wednesday, April 01, 2009