8 Sustainability
Sustainability in software means looking beyond readability, simplicity, and failure handling to consider the resources software consumes: CPU, memory, storage, network traffic, electricity, and hardware. The chapter frames sustainability through environmental, social, and economic pillars, with a focus on the environmental impact of digital technology. Software contributes to emissions through the electricity used by devices, networks, and data centers, but also through the hidden lifecycle cost of hardware manufacturing, transport, and disposal. Because much of a device’s carbon footprint exists before it is ever used, extending hardware lifespan and avoiding software-driven obsolescence are essential sustainability goals.
The chapter presents sustainable coding as a practical extension of software craftsmanship. Clean code concerns maintainability, performance concerns speed and responsiveness, and sustainable coding concerns impact: using the smallest reasonable amount of infrastructure and energy while still meeting user needs. The main levers are reducing hardware demand and lowering electricity consumption, especially when power comes from carbon-intensive sources. To help developers act on these levers, the chapter introduces green design patterns: frugality, lean packaging, lean storage, lean communication, efficient execution, memory efficiency, and carbon awareness. Together, these patterns encourage developers to build only valuable features, remove unnecessary dependencies and dead code, store and transmit less data, optimize computation, manage memory carefully, and shift heavy work to cleaner times, regions, or modes of operation.
The chapter also explains that measuring the exact carbon footprint of software is difficult, because emissions depend on uncertain factors such as electricity sources, deployment regions, user devices, and embodied hardware carbon. Still, estimation methods such as Software Carbon Intensity can provide useful approximations once software is running. Developers can also use frontend analysis tools, static analysis, benchmarks, profilers, memory inspection tools, and carefully applied AI-assisted reviews to detect wasteful patterns earlier in the development process. The central message is that sustainable coding is not about optimizing everything blindly; it is about making reasonable, evidence-based choices that reduce waste, lower costs, preserve maintainability, and build software that respects both users and the environment.
How sustainable coding fits with clean code and performance.
Using the two levers of sustainability: electricity and hardware usage.
Green design patterns
Summary
- Sustainability is based on three pillars: environmental, social, and economic. These aim to balance long-term economic profit with reduced ecological impact and improved well-being for people.
- As of 2025, information and communication technology (ICT) accounts for about 4% of global greenhouse gas emissions. This impact is caused by both the electricity consumed by digital systems and the carbon-intensive manufacturing of their hardware.
- A carbon footprint measures the total greenhouse gases produced by an activity, expressed in CO₂ equivalent. This converts different gases such as carbon dioxide, methane, and nitrous oxide into a single comparable unit.
- The carbon footprint of software from electricity usage depends on both the amount of electricity consumed and how carbon-intensive the electricity is in the region where it runs.
- The embodied carbon footprint is the total emissions generated during the manufacturing, transport, and end-of-life processing of a device.
- Technological obsolescence occurs when functioning hardware becomes unusable, either when software support ends or when new software requirements exceed device capabilities.
- Efficiency is the ability to achieve acceptable performance while using as few hardware resources as possible.
- Green design patterns are practical strategies that reduce the environmental impact of software by acting on two levers, lowering electricity consumption and limiting resource usage. There are seven patterns:
- The frugality pattern keeps systems simple and resource-efficient by building only the features and technical elements that deliver real value to clients and users.
- The lean packaging pattern removes unused dependencies and dead code to reduce package size and transfer cost.
- The lean storage pattern limits stored data and removes accumulated operational waste to reduce storage.
- The lean communication pattern lowers network traffic by reducing call frequency and shrinking payloads.
- The efficient execution pattern reduces CPU work through better algorithms and workload smoothing.
- The memory efficiency pattern minimizes memory usage by choosing lightweight structures and controlling cache growth.
- The carbon-aware pattern reduces emissions by scheduling work during cleaner energy periods, shifting computation to lower-carbon regions, and scaling resource usage down when electricity is more carbon-intensive.
- Tools can only provide an estimate, and the most reliable estimates appear once the software is deployed, whether through cloud provider dashboards or installed monitoring software.
- Front-end carbon footprint can be analyzed with webpage analysis tools that measure page weight and network requests, as well as static analysis tools that flag wasteful coding patterns.
- Back-end impact can be analyzed with static code analysis, memory management tools, and performance profilers.
FAQ
What does sustainability mean in software development?
Sustainability in software means meeting current needs without compromising future generations’ ability to meet theirs. In software, it involves three pillars: environmental sustainability, such as reducing energy use and carbon emissions; social sustainability, such as accessibility, privacy, and user well-being; and economic sustainability, such as reducing operational costs and building durable systems.
Why does software have an environmental footprint?
Software consumes physical resources when it runs: CPU, memory, disk space, network bandwidth, servers, and user devices. These resources require electricity and hardware. Electricity may come from carbon-intensive sources such as coal, oil, or gas, and hardware has an embodied carbon cost from manufacturing, transportation, and end-of-life processing.
What is embodied carbon, and why does it matter for digital devices?
Embodied carbon is the carbon emitted before and after a device’s active use, including mining, manufacturing, transportation, and end-of-life processing. For smartphones, roughly three-quarters of the total carbon footprint is produced before the device is even turned on. Extending the life of devices through repair, reuse, and efficient software helps amortize this cost over a longer period.
How can software contribute to hardware obsolescence?
Software can make functioning hardware obsolete when support is dropped, cloud services are shut down, operating systems stop receiving updates, or applications become too heavy for older devices. Heavy web pages, large libraries, background scripts, and inefficient applications can push users to replace devices that still physically work, increasing environmental impact.
How is sustainable coding different from clean code and performance optimization?
Clean code focuses on readability and maintainability. Performance focuses on speed and responsiveness. Sustainable coding focuses on impact: using as little energy and hardware as possible while still providing an acceptable user experience. The ideal is code that is clean, efficient, and minimizes environmental footprint.
What are the main levers for reducing software’s environmental impact?
The chapter identifies two major levers: reducing the use and purchase of hardware, and reducing electricity consumption, especially when electricity comes from fossil fuels. Green design patterns address these levers by minimizing unnecessary computation, memory use, storage, network traffic, and infrastructure demand.
What are the seven green design patterns?
The seven green design patterns are Frugality, Lean Packaging, Lean Storage, Lean Communication, Efficient Execution, Memory Efficiency, and Carbon Aware. Together, they provide practical guidance for building software that uses fewer resources, transfers less data, stores less waste, executes more efficiently, and adapts to cleaner energy conditions.
What is the Frugality pattern?
The Frugality pattern means building only what provides real value. Functional frugality avoids unused or low-value features by checking whether features are useful, usable, and actually used. Technical frugality avoids overengineered architectures and hype-driven technology choices when simpler solutions would meet the project’s needs with less complexity and resource use.
How can developers reduce network and storage waste?
To reduce network waste, developers can design efficient endpoints, avoid unnecessary calls, use caching, support offline-first behavior, compress payloads, return only required fields, optimize images, and use lazy loading. To reduce storage waste, they can store only necessary data, choose efficient formats and field sizes, normalize when appropriate, purge logs and temporary files, clean unused Docker images or backups, and enforce clear retention policies.
What tools can help developers write more sustainable software?
Developers can use frontend tools such as Website Carbon Calculator, GreenIt Analysis, and browser network panels to estimate page weight and requests. Static analysis tools such as the Green Code Initiative plugins for SonarQube can flag wasteful patterns. Profilers and benchmark tools such as JMH, BenchmarkDotNet, pytest-benchmark, VisualVM, JDK Flight Recorder, Async-Profiler, py-spy, pprof, Clinic.js, and Java Object Layout can help identify CPU, memory, and allocation inefficiencies.
The Art of Code ebook for free