liveBook · Manning

Sustainable software

As explained in The Art of Code

Sustainable software is software designed and developed to minimize unnecessary computational, material, and environmental resource consumption.

Sustainable software minimizes unnecessary use of computation, memory, storage, network bandwidth, and hardware. Its aim is practical as well as environmental: wasteful resource use raises operating cost, electricity demand, and infrastructure needs. The guiding question is not whether code merely works, reads well, or runs quickly, but whether it delivers an acceptable result with the smallest reasonable resource footprint. section 1.1.6 section 8.2.2 section 8.3

Sustainability complements rather than replaces clean code and performance. Clean code favors readability and maintainability; performance favors speed and responsiveness. Neither alone guarantees low impact. Efficiency joins sustainability and performance by setting an acceptable responsiveness level, then meeting it with minimal hardware resources. The broader craft goal is maintainable, efficient code that avoids unnecessary cost and environmental footprint. section 8.3

Figure 8.1 How sustainable coding fits with clean code and performance
figure

Compare sustainability with clean code and performance: sustainability focuses on impact, while efficiency is their practical overlap with performance. section 8.3

Make sustainable coding an everyday engineering practice by seeking actionable feedback:

  • Estimate a web page’s client-side footprint from page weight, request count, and DOM complexity with web-focused tools. section 8.5.2
  • Use static analysis to flag resource-wasting patterns; distinguish it from dynamic analysis, which observes running software and can measure energy-related behavior. section 8.5.2
  • Measure small alternatives with microbenchmarks and investigate CPU behavior and memory allocation with profilers. section 8.5.2
  • Treat tool feedback like IDE, test, and code-quality feedback so resource awareness becomes part of normal development work. section 8.5

Reduce a people-analysis routine’s memory footprint

When finding the youngest and oldest people and sorting names, a memory-conscious imperative variant replaces nullable boxed Integer values with primitive int sentinels and preallocates the names list to the input size. These changes avoid temporary boxed objects and reduce avoidable allocation. Functional stream pipelines may also create short-lived objects at each stage; consolidating work into one pipeline is presented as a resource-saving alternative, with tradeoffs in implementation complexity. section 10.2.2

Resource savings also affect hardware lifetime. Because device manufacturing accounts for much of a device’s carbon impact, unnecessary replacement increases environmental debt. Reducing electricity and infrastructure use while extending hardware lifespans therefore has a direct financial case alongside its environmental one. section 8.2.2

How The Art of Code covers it

How deep it goes
Defines resource-focused efficiency and supports it with feedback tools and a Java memory-optimization example.
Examples
Uses web-page carbon estimates and Java people-analysis variants that reduce boxed objects, allocations, and multiple stream passes.
What it assumes
Assumes programming familiarity and introduces sustainability as an added resource-impact dimension rather than a replacement for existing practices.
What you can do after
Apply it via measurement and analysis tools to identify resource waste and compare lower-footprint implementation choices.
How it connects
Connects sustainable software with clean code, performance, efficiency, static analysis, dynamic analysis, microbenchmarks, and profilers.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.