When I think of the colour green, to me it represents refreshing, nature, renewal. Afterall, green is everywhere. However, as part of this software industry, it makes me think — Are we doing enough to ensure that green colour in the nature remains dominant?
The Paris Agreement signed in 2016 looks at climate change mitigation, adaptation, and finance. Several organizations have since come forward to crack the climate crisis and solve the challenges of decarbonizing the economy. We do hear regularly about organizations disclosing their reduction in carbon footprint, or their plans to achieve net zero emissions.
There is also a shift that was accelerated due to the pandemic around digitalization of businesses. IDC has predicted digital transformation investments to reach USD 6.8 trillion  by 2023. Technology enabled by software is the foundation stone for this digitalization. Software needs storage, compute, networks to run and function. All of this consumes energy. Hence, there is an urgent need for the software engineering community to understand the impact of software on the carbon footprint.
Recently, there was a study undertaken by researchers in Portugal,  where they published some interesting findings. On average, compiled languages consume 120J [joules] and interpreted languages consume 2365J to execute given sample solutions. That essentially means C code is 75 times more energy efficient than Python code. MIT Technology Review article  stated that training a single AI model can emit as much carbon as five cars in their lifetime.
So as software engineers, we should start by asking two questions –
- How do I know what is the carbon impact of the code that I write?
- What can I do to reduce the carbon footprint of my code?
These are the questions that the “Green Software Engineering” movement is attempting to answer. Green Software Engineering brings in holistic view around climate science, software practices and architecture, cloud, data centres and hardware.
Measuring Green Debt
Today, calculating technical debt is a standard practice for software engineers. Tools like SonarQube and CAST are used to understand the code performance. The outputs from these tools can be extended to calculate the “Green Debt”. Research is also happening in the software community around dedicated tools and plug-ins that can directly provide statistics around energy performance. As these tools become mainstream, I will not be surprised to see “Green Debt” become one of the key metrics for software quality and maintainability.
Leveraging approaches like either Serverless architectures or Containerization is a good first step towards designing the code that is more energy efficient. Essentially, serverless computing provides services only when they are needed. This architecture can be further enhanced using other sustainable patterns like Edge computing and Delayed compute. A container is a stand-alone, scaled-down unit of computing environment that can run executable code contributing to a smaller carbon footprint. In addition to that focusing on code optimization techniques  while writing the code itself — like reuse already computed values or avoid unnecessary stores of variables, extra loads of memory and register-to-register moves. If you are designing a data intensive application, you can focus on solutions patterns that reduce the data movement.
While these are few glimpses of techniques that a software engineer can start with, a lot more needs to be done to enable the green software engineering. Right from creating awareness via training and enablement to bringing in standardized SDLC processes and practices that incorporate this thinking is crucial. It is high time we as software engineers start thinking about the footprints that our code leaves behind and truly embrace “Green as our colour”. Do you agree?
Energy Efficiency across Programming Languages (uminho.pt)