Sustainability treats software as a consumer of real resources, not only as code to maintain. Disk space, memory, network traffic, and CPU usage require hardware and electricity, creating operational costs and environmental impact. Sustainable design therefore seeks useful software that meets present needs while preserving resources and options for the future. section 8.0 section 8.1
In software, sustainability balances three pillars. Environmental sustainability reduces emissions through energy efficiency, less unnecessary computation, storage, and data transfer, and lower-emission infrastructure. Social sustainability includes accessibility, equal access, privacy, user well-being, and responsible AI. Economic sustainability creates value while respecting people and preserving resources; it includes durable systems and lower operating costs. section 8.1
Sustainable coding is distinct from clean code and performance. Clean code emphasizes maintainability and understandable form; performance emphasizes speed and responsiveness. Sustainability emphasizes impact: energy consumed and resources used. The practical overlap is efficiency—delivering an acceptable result and user experience with the minimum hardware resources and infrastructure needed. section 8.3
Figure 8.1 How sustainable coding fits with clean code and performance
Use the relationship diagram to place sustainability alongside clean code and performance: the goal is not to trade away maintainability or responsiveness, but to achieve acceptable responsiveness with restrained resource use. section 8.3
Green design patterns turn resource awareness into engineering choices:
- Build only features and technical elements that provide real user or client value, keeping systems frugal and simple. section 8.6
- Remove unused dependencies and dead code to reduce package size and transfer cost. section 8.6
- Limit retained data and remove operational waste to reduce storage needs. section 8.6
- Reduce network call frequency and payload size to lower communication traffic. section 8.6
- Reduce CPU work with better algorithms and workload smoothing, and minimize memory through lightweight structures and controlled consumption. section 8.6
A decision criterion for efficient systems
Do not equate sustainability with making every operation as fast as possible. First define an acceptable level of responsiveness for users. Then meet it with the smallest practical infrastructure and fewest hardware resources. This frames optimization around sufficient outcomes rather than resource-heavy overprovisioning. section 8.3
A sustainable system can also reduce cost and extend hardware usefulness. Reducing electricity use lowers impact according to both consumption and the carbon intensity of the region supplying power. Avoiding unnecessary software demands can help prevent technological obsolescence, where functioning hardware becomes unusable because support ends or requirements outgrow it. The reusable heuristic is simple: preserve value, remove waste, and measure efficiency rather than assuming that tidy or fast code is automatically sustainable. section 8.6 section 8.3
