Green Coding: A much underestimated potential

Everyone talks about sustainable IT, primarily referring to efficiency improvements in hardware. However, even in the code, CO2 can be saved, and not just a little.

7 minutes to read
With insights from...

This guest article was originally published in "Computerworld Top 500 – The Ranking of the Swiss IT Scene" on September 14, 2023.

What do the Earth's orbit and the software sphere have in common? Not much at first glance, one might think. According to the European Space Agency (ESA), there are more than 32,000 pieces of space debris in Earth's orbit. The associated efforts and risks related to safety for humans and materials are steadily increasing. Similarly, commercial and institutional use of space is on the rise, leading to its increasing "pollution." NASA and ESA are now intensively discussing sustainability strategies, including the concept of a "garbage collection" for space debris.

Software, too, is becoming increasingly complex, and applications, along with their lines of code, continue to grow. To get a sense of the scale, David McCandless, bestselling author and founder of the blog "Information is Beautiful," illustrates with examples: a simple game app for a smartphone requires about 50,000 lines of code. The code for the software of the US Space Shuttle amounted to around 400,000 lines at that time. The software of a modern car already includes around 100 million lines of code. In contrast, Google alone requires over two billion lines of code for its internet services. And for those who remember the good old PacMan game: 36 lines of code.

These scales will continue to shift. Development-intensive software for AI and other applications is still in its infancy, as noted by the magazine "Technik und Wissen" regarding sustainable software. Swico, the economic association for the ICT and online industry in Switzerland, reports that the growth trajectory within the ICT industry will be maintained, with software as the driving force.

  • 'Applications contain redundant, unnecessary, unreachable, dead, and deactivated lines of code, which still require computing and storage resources.'

Moreover, software – and thus code – is omnipresent. A recent study by Bitkom, the German counterpart to Swico, shows that the average smartphone user has approximately 31 installed applications, in addition to the pre-installed apps. However, the zenith has not yet been reached, especially considering younger generations. 16- to 25-year-olds have an average of over 40 apps installed on their smartphones. The overarching conclusion: software and data are ubiquitous and always usable; that is our understanding as users. With this brief glimpse behind the scenes of the code world, it should become clear where the space analogy is leading: there is plenty of space, and little effort has been made to consider what should be done with all that space and waste.

Software also produces a considerable amount of junk: applications contain redundant, unnecessary, unreachable, dead, and deactivated lines of code, which still require computing and storage resources. One of the reasons is that more and more reliance is placed on a variety of existing frameworks and libraries. Swiss Made Software, an ICT label with over 1100 supporting companies in Switzerland, explains that practically no software can be developed nowadays without using these tools.

The performance and growth capabilities of existing infrastructures are being cluttered in a similar way to our Earth's orbit. At the same time, more and more new, powerful data centers need to be built to handle data and software. According to a study by Borderstep, an institute for innovation and sustainability, the global energy demand in data centers has roughly quadrupled in the last ten years. In contrast, IT performance in data centers has already increased by almost 84 percent from 2010 to 2020. According to experts, there is expected to be another increase of around 30 percent in the coming years. In German data centers alone, energy consumption is projected to rise from 18 terawatt-hours (TWh) in 2023 to between 27 TWh and 34 TWh by 2030, estimates Bitkom. Not only has consumption grown, but it's worth noting that the efficiency of data centers has also increased. The computing capacity per consumed kilowatt-hour of electricity has almost quintupled since 2010.

Cloud and data centers have become integral parts of our digital world and are now indispensable. They consume about one percent of the world's electricity and are responsible for around 0.3 percent of our global CO2 emissions. According to Kroker's Look @ IT, a blog by Wirtschaftswoche, the global data volume is projected to reach around 163 zettabytes in 2025 (that's a 163 with 21 zeros), or roughly 500 times the data volume of all series and movies stored on Netflix. In historical terms, in 1956, there was only 5 megabytes of data.

The share of digital technologies in global greenhouse gas emissions has increased from about 2.5 percent in 2013 to 3.7 percent. The connectivity within companies, between machines, and to both private and commercial consumers is also intensifying. Due to data networking, the world is evolving into a "global data village." The digital transformation is in full swing, with products and services increasingly supported or accompanied by technology. Regardless of the digital services we use, software code is the foundation that breathes life into machines.

Not only hardware but also software is becoming more resource-intensive

The trend of applications becoming increasingly "hungry" for energy, storage resources, or computing power, leading to the need for larger server farms, is evident in a recent projection. By 2040, digital emissions are expected to account for about 14 percent of global CO2 emissions. Currently, the IT sector is responsible for around 4 percent of the global greenhouse gas emissions.

The current "Transport Outlook" from the International Transport Forum (ITF), a sub-organisation of the OECD, estimates in a projection from 2015 to 2050 that passenger traffic will increase by 2.3 times, and freight traffic will increase by 2.6 times. At the current rate, passenger traffic would emit 13 percent more CO2 by 2050, and freight traffic would emit 22 percent more. This would mean that CO2 emissions would be three times higher than necessary to meet the 1.5-degree goal set in the Paris Agreement.

A single line of code typically does not require attention from management. As is often the case in life, the truth lies in the details and scale: How often are applications started or computational operations executed, causing frustration due to their slow speed? This is where the concept of Green Coding comes into play. It involves efficient programming, eliminating redundancies, and avoiding dead code, ultimately saving computational power and reducing CO2 emissions.

The previous focus in IT was mainly on using energy-efficient and more efficient hardware. From numerous conversations with IT professionals, it is evident that the concept of Green Coding has not yet established itself in their minds. This is mainly because hardware is more tangible: power consumption and processor performance can be measured and verified against planned CO2 savings. In contrast, software is typically purchased, licenses are paid for, and simply used. The question of how many lines of code a current operating or ERP system has usually doesn't cross anyone's mind. This information alone would likely not provide users with significant value. Only in a performance check does it become clear whether the existing hardware is "still coping" with the software or needs to be replaced with even more performant hardware.

The sustainability concept is slowly but surely gaining more attention

Even in the public sphere, the idea of sustainable software development plays a subordinate role. Software is a "vehicle" that should function quickly, flawlessly, and simply. What and how it is programmed is, understandably, not in the focus of the user.

A short survey among Bitkom members in 2021 revealed that sustainability is not a consideration in software development projects for 23 percent of the surveyed companies. For 70 percent of the companies, sustainability plays a role in only up to 25 percent of software development projects. In contrast, a survey by the software manufacturer Salesforce shows that around 75 percent of programmers and software designers wish to develop applications with lower CO2 emissions. Companies, as well as administrations and private households, are measuring and optimizing their CO2 emissions within the scope of Scope 1, Scope 2, and Scope 3 emissions ESG. However, sustainable optimization becomes possible only when the emission drivers have been identified.

  • 'Regardless of the digital services we use, software code is the foundation that breathes life into machines.'

From many publications, it can be inferred that Scope 1 and Scope 2 ESG are now well to very well captured and analyzed. However, about 80 percent of CO2 emissions can fall under Scope 3 ESG, as confirmed by a study from 2023 by Swissmem, the association of the Swiss machinery, electrical, and metal industries, as well as related technology-oriented industries. Scope 3 includes all indirect emissions that occur within a company's value chain. This makes it complex to evaluate the CO2 footprint for software. An online article from com!professional assumes that 55 percent of emissions caused by IT are influenced by the underlying software. By intelligently using Green Coding, resource efficiencies can be achieved.

Just over ten years ago, sustainability aspects and energy savings were minimal to no decision criteria in IT. In a representative survey at that time, only 5 percent of the surveyed companies stated that ecological aspects were considered in IT cost decisions. Again, 16 percent of the surveyed business executives stated that climate protection had little to no significance. The mindset has since changed: 69 percent of IT professionals worldwide cite the reduction of energy costs as the main reason for Green IT initiatives. The mindset regarding sustainability aspects and energy savings shows a positive trend. However, the current focus is still more on "only" more efficient hardware and its optimization. All these facts and figures show: Every line of code and its content has an impact on the environment. By establishing the sustainability concept in coding, the software sector in the ICT industry can make a significant contribution to climate protection.