Chapter 3. Code Efficiency

I feel the need—the need for speed.

Maverick

Whenever the subject of software efficiency comes up, the first question that springs to mind for most developers is, “What’s the fastest and therefore most efficient coding language? Is it Rust, C, or Go?” Maybe it’ll surprise us all and actually be Java! (Dear reader, it isn’t. However, Java is doing work in this area. One day Java, or something similar, could be the most efficient coding language.)

Efficiency Is Everything—or Is It?

Controversially, as much as we love those languages, we’re going to argue that, for most folk, programming in them is not the optimum way to build green software. In fact, we’re going to attempt to convince you that although code efficiency is a tool in your toolbox, it is not the first one most engineers should reach for.

For most of us, writing more streamlined code is almost certainly a less effective way to reduce our carbon footprint than a combination of making operational efficiency improvements, architecting for demand shifting and shaping, and choosing the right platform.

There are circumstances where active code efficiency on your part is vital to greenness. If you are writing code that will be deployed at hyper scale, it must be optimized. You are presumably already doing that to manage your costs and SLAs and reading books specifically designed to help you with that skilled and context-specific task. However, even if you’re not running systems at scale, as a producer ...

Get Building Green Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.