Eco Friendly Development
"Oh mercy, mercy me
Ah things ain't what they used to be
What about
this overcrowded land
How much more abuse from man can she
stand?"
Marvin Gaye - Mercy mercy me (The ecology)
Today is World Environment
Day. This is a good day to think about what we can do to stop global
warming. Here are some ideas on how you can become a better developer and a
world citizen at the same time.
Write better code
In his excellent Programming
Pearls
, Jon Bentley shows how improving an summarization algorithm
can drastically improve the performance of an application. The naïve algorithm
performs in cubic time, or O(n3), while the fastest is a linear,
O(n), algorithm. To many developers the difference between a O(n2),
O(n log n) or an O(n) algorithm is arcane, and many don't care about the
differences as long as their code works. However, when you feed data through
these different algorithms the differences become apparent. The cubic time
algorithm takes 22 minutes to find and summarize the greatest subvector in an
vector consisting of ten thousand elements, while the linear algorithm does the
same thing in 0.5 milliseconds. If the size of the vector is multiplied by 10,
the time for the slowest algorithm increases 1000 times. The linear algorithm
only increases 10 times.
If we compare a more subtle difference, let's say an
O(n log n) algorithm with the fastest one from above, the performance difference
isn't as extreme as before; 0.94 seconds versus 48 milliseconds.
A common
solution to performance problems is to scale out. This is not only costly, it
can also be a missed opportunity to be an eco-friendly developer. Computers need
power to operate, and power plants are one of the main
sources for CO2 pollution. An average server consumes ~260 Watts a
day, and you'll need about 19 servers to get the same performance from the O(n
log n) as the fastest algorithm. By tuning your code rather than throwing more
hardware at the performance problem, you can stop as much as 800 kilograms of
CO2 from escaping into the atmosphere.
You can also improve your business logic to save the planet and money at the
same time. A great example of this is UPS who
started avoiding left turns in 2004. Standing still at a crossroad waiting to
turn left burns fuel and creates unneeded CO2 emission. UPS updated
their route planning software to lead the drivers through a route of mostly
right turns. Since January, UPS has reduced the emissions in metro New York by
1,000 tons. Within two years, the policy will be adopted across the US.
Change your UI
The Saving Energy blog has
posted an
open letter to Google to persuade them to change their color scheme. If
Google changes their background color from white to black, as much as 13,888 KWH
of electricity will be saved by their users each day. If you're not too fond of
black, check out Mark Ontkush's Emergy-C
color palette. The palette is designed to use little energy and it has nicer
colors than most websites. Yet the colors in the palette only requires 3 or 4
watts more than an all black screen.
If you want to apply an energy efficient
color scheme to Visual Studio, check out Ayende's black
editor-settings.
Be agile
Many developers claim to use agile methodologies, but few practice them to
the full extent. One of the principles of eXtreme Programming is the "forty hour
week". The idea is that programmers must be well-rested in order to produce
quality work. There is also an eco-friendly side to this. Working short days
lets you turn off lots of energy hungry equipment like air conditioning,
computer screens and similar earlier.
While you're improving the
workplace, why not a have casual Friday all summer? In 2005,
Japanese workers wore open collars and light tropical colors rather than suits
at work. It was part of the Japanese government's effort to save energy by
accepting an higher temperature indoors during the summer. The policy reduced
Japan's emissions by an estimated 79,000 tons of CO2 in one
summer.
Start making a change now!