8 Sustainability
This chapter covers
- Sustainability and software’s environmental footprint
- Applying green design patterns
- Estimating the carbon footprint of software
- Using tools to improve code efficiency
Let’s extend the scope of the art of code beyond readability, simplicity, and failure handling to consider the resources software consumes when it runs. Disk space, memory, network traffic, and CPU usage are not just technical concerns: they require electricity and hardware, all of which carry both operational and environmental costs.
We’ll start by examining how digital technology contributes to our environmental footprint. Next, we’ll explore green design patterns that give developers actionable ways to reduce unnecessary computation, storage, and data transfer. Finally, we’ll review tools developers can use to measure and improve the efficiency of their code. By the end of this chapter, you’ll understand the sources of software’s environmental footprint, how these patterns address them, and how to apply them effectively in real projects.
8.1 The three pillars of sustainability
Sustainability means meeting present needs without compromising the ability of future generations to meet theirs. It is traditionally described by three pillars: environmental, social, and economic. In software, these pillars translate as follows: