using CoffeeBrain = Brain

Menu

C++ and Climate Change

The project I work on is a C++ project that is computationally massive. We are processing many, many petabytes of data that run hot at 100 percent CPU load. The machines we use have dozens of cores and we have hundreds of them. Early in the project an architect came to me and said “We have to convert this to Java, because that is what the rest of the company uses.” I balked at his arrogance. My argument to him to keep it C++ was not just technical but moral. I told him “C++ will use less energy. Performance per Watt is higher. We will need less hardware.” I also told him that I don’t want to contribute to global warming more than I have to.

He thought this argument to be very strange, but I am far from the first to make it.

Here is Bjarne Stroustrup, the creator of C++ making the same argument:

You see, the tech world promises a future that the science world won’t let happen. IPCC recently released a report titled ‘Climate Change 2014: Impacts, Adaptation, and Vulnerability’. This report details how climate change is happening now and no one will escape from the effects. But the Tech world is promising something completely different for our future. The Valley promises driveless electric cars and the singularity. Social media is advocated to be a democratizing force in society. That twitter was a catalyst for the Arab spring, while in reality there was a food crisis.

Somehow the promised future of Silicon Valley and the disaster of climate change is not in conflict in peoples minds.

The worst of it is that the software culture is completely ignoring this cognitive dissonance. Is it that engineers are somehow unscientific in their thinking? That cannot be! And those who acknowledge it reply with the tired old saw that some technology will magically come and save us.

The business people who run the Tech companies on the other hand are proud of their contribution to the problem. Google even has a special page about their contribution to consumption.

I know it may sound stupid, but using C++ in this case, for me, was a conscious moral decision, not just a technical one. Because if we want anything like the future the Valley is promising us, we need to start using less now.

Actually, C++ is not enough. While it excels at micro-optimization, it’s not very good at letting you use more complicated, but more efficient, algorithms. At the very least, you have to worry about getting a gazillion details right. Overall, C++ is a premature optimization.

It is said: “Efficiency comes from elegant solutions, not optimized programs. Optimization is just a few correctness-preserving transformations away.” (This quote is from Jonathan Sobel, and endorsed by Daniel P. Friedman in “The Role of the Study of Programming Languages”.)

If you’re really ultra-serious about optimization, you need to start with an elegant solution expressed in a very high language —possibly a DSL. Then you can apply domain specific optimizations after the fact, through what amounts to custom compilation stages. Done right, this approach would just zoom past any direct C++ solution we could have come up with.

The only ingredient missing is the unicorn —err, the language specialist. Otherwise, you won’t get far.

Thank you for bringing this up and I agree with you here. C++ is by far not enough. Elegant solutions should be first over micro optimizations. In fact, the most efficient code is code not written.

I do feel that C++ is high level enough for most solutions. It is also one of the few languages which have complexity gaurantees in the standard library. Most languages you couldn’t even reason about how elegant your solution is.

DSLs are an amazing idea that is underutilized. C++ used to be a DSL on top of C in the beginning. we need more of that.

Have you ever heard of the rebound effect and Jevons paradox? In short, it means that if your process is more efficient it will likely result in your boss buying more machines anyway and using them to get the computations done faster. Or to serve more customers. To grow the business. In the end, the energy consumption might me even greater.
I think we need to understand that we won’t resolve our societies crisis with technological improvements. Our system is built on growth, that’s how we think. Any efficiency gain will immediately used to churn out more goods, more consumption.
What I am wondering is what these Petabytes of data running hot 100% CPU are actually about? Will their output make the world a better place and why?

Now we are talking serious! I am 100% in agreement here. The fact that I used C++ in this post is just a detail. The important bit is that I used what little power I had in my situation to make a small impact.

The real solutions, as you mentioned, are not technological. The real solution is related to what the power structures are in society, and how they can be reformed to affect real change.

And are those petabytes of data going to make the world a better place? I certainly hope so! But I am a pessimist by nature.