Sustainable Solutions: Green Software Engineering from a Mobile Engineer’s Perspective

ELEKSELEKS
7 min read

In today's world, individuals and companies must acknowledge the impact of our actions on the environment. This concern includes every sector, including software development. In this blog post, we will delve into the environmental implications of software development and provide some practical solutions to mitigate these effects. Additionally, we will assess the effectiveness of tools like ecoCode, which analyse the "greenness" of code.

What is green software engineering?

Green software engineering refers to the development of sustainable solutions with minimal environmental impact. It involves employing green practices and technologies throughout the entire software lifecycle, including design, development, testing, deployment, and maintenance.

According toMcKinsey, taking immediate action to improve the sustainability of software and data could result in a reduction of approximately 5% in CO2 emissions by 2030.

Green software engineering aims to reduce energy consumption, carbon emissions, and waste production. This is achieved through various strategies such as:

  • using efficient algorithms

  • optimising code for energy efficiency

  • reducing resource usage

  • utilising renewable energy sources for hosting and deployment

  • promoting virtualisation and cloud computing

  • implementing recycling and disposal policies for hardware components.

How application development impacts the environment

Application development can have both direct and indirect effects on the environment. Direct impacts include the energy consumption from running software programs and data centres, leading to greenhouse gas emissions. Additionally, the exchange of data over networks and the cloud can also have an environmental impact due to the energy required for transmission and storage.

On the other hand, indirect impacts refer to the production and disposal of hardware. It includes servers, mobile devices, and other computer equipment, which generate electronic waste and contribute to pollution.

However, by applying green software engineering practices, developers may be able to reduce the environmental impact of app development and make their apps more sustainable.

How to make app development more environmentally friendly

Developing a greener app can be achieved through custom app development as it provides the flexibility to customise the solution according to specific requirements.

Let's explore some practical examples of actions that can be implemented during the app development process to enhance its sustainability and minimise its environmental impact:

  • Optimise algorithms and code. Write efficient algorithms and clean code to reduce CPU usage and energy consumption. Use profiling tools to identify bottlenecks and optimise performance.

  • Reduce resource usage. Create lightweight software with efficient data structures and reduce resource-intensive activities to optimise memory, storage, and processing power usage.

  • Use energy-efficient libraries and frameworks. Choose libraries and frameworks that prioritise energy efficiency and have been designed with green principles in mind.

  • Implement power-saving features. Integrate power-saving features, such as idle states or sleep modes, into your software to reduce energy consumption when the software is not in active use.

  • Use cloud computing and virtualisation. Leverage cloud-based and virtualisation technologies to reduce the need for physical hardware, lower energy usage, and minimise the carbon footprint associated with software development and deployment.

  • Encourage software longevity and backward compatibility. Design software that is easy to update and is compatible with older hardware to reduce e-waste and the need for hardware.

  • Minimise network usage. Optimise data transfers by using compression, caching, and other techniques to reduce the amount of data sent over networks, thereby reducing energy consumption.

  • Focus on long-term equipment purchases. When choosing equipment for development and deployment, consider energy efficiency, recyclability, and the manufacturer's commitment to environmental responsibility.

  • Adopt eco-friendly workplace practices. Encourage recycling, energy conservation, and other environmentally friendly activities among your development team and your organisation.

  • Monitor and assess regularly. Evaluate the environmental impact of your software products and development techniques regularly, then adjust based on your findings.

    The eight standards of green software engineering

    After the introduction of eight green software engineering principles, they have been widely accepted as fundamental pillars ensuring software development's sustainability, functionality, and environmental friendliness.

    Companies can significantly benefit from adhering to these principles as they provide a framework for creating environmentally responsible software applications. Here is a brief overview of what these principles entail:

    1. Carbon – developing carbon-efficient applications reduces the carbon footprint of software development.

    2. Electricity – developing energy-efficient applications decreases the electricity required to power them. It also potentially saves money and lowers greenhouse gas emissions.

    3. Carbon intensity – prioritising renewable energy sources and increasing energy efficiency minimises carbon and energy waste.

    4. Embodied carbon – developing hardware- and network-efficient applications optimise the environmental effect of hardware manufacturing and disposal, as well as network energy use.

    5. Energy proportionality – improving hardware energy efficiency reduces energy waste and increases the sustainability of software development.

    6. Networking – limiting the amount of data transferred and the distance it travels over the network lowers energy consumption and improves network efficiency.

    7. Demand shaping – developing carbon-aware applications raises environmental awareness and encourages sustainable habits.

    8. Measurement and optimisation – concentrating on step-by-step improvements that boost overall carbon efficiency helps to identify areas for improvement and encourage continual improvement in software development techniques.

Introducing the ecoCode plugin: the idea and tools at the core

The ecoCode plugin aims to reveal bad code practices, such as poor optimisation and memory leaks. It is compatible with Java 11 and higher and operates on docker. The plugin is already available for Android, iOS, Java, Python, and PHP.

You can check the list of Android/iOS best practices that the ecoCode development team refer to. Here is an extract of the rules for Android:

  • Use dark theme on devices.

  • Avoid third-party animations in the user interface.

  • Use workManager.

  • Avoid using Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS.

  • Monitor changes in the charging status of the device using a broadcast receiver registered in the ACTION_POWER_CONNECTED and ACTION_POWER_DISCONNECTED actions.

  • Do not use getSystemService(Context.VIBRATOR_SERVICE) unless absolutely necessary to save the battery.

  • Check if the low power mode is enabled and adapt the resource usage accordingly.

Here are the rules that have already been brought to Android:

  • FusedLocationRule.class,

  • BluetoothLowEnergyRule.class,

  • KeepScreenOnAddFlagsRule.class,

  • KeepScreenOnSetFlagsRule.class,

  • BrightnessOverrideRule.class,

  • InternetInTheLoopRule.class,

  • KeepCpuOnRule.class,

  • ThriftyMotionSensorRule.class,

  • WifiMulticastLockRule.class,

  • LocationLeakRule.class,

  • CameraLeakRule.class,

  • SensorManagerLeakRule.class,

  • DurableWakeLockRule.class,

  • MediaLeakMediaRecorderRule.class,

  • MediaLeakMediaPlayerRule.class,

  • RigidAlarmRule.class,

  • ContinuousRenderingRule.class,

  • KeepVoiceAwakeRule.class,

  • ThriftyBluetoothLowEnergySetAdvertiseModeRule.class,

  • ThriftyBluetoothLowEnergyRequestConnectionPriorityRule.class,

  • ThriftyGeolocationMinTimeRule.class,

  • ThriftyGeolocationMinDistanceRule.class,

  • ChargeAwarenessRule.class,

  • VibrationFreeRule.class,

  • TorchFreeRule.class,

  • ThriftyNotificationRule.class,

  • UncompressedDataTransmissionRule.class,

  • SensorCoalesceRule.class,

  • JobCoalesceRule.class,

  • SaveModeAwarenessRule.class,

  • ThriftyGeolocationCriteriaRule.class,

  • HighFrameRateRule.class

There are more rules registered in the candidate rules list and not implemented yet.

Putting the ecoCode to test: insights from ELEKS’ project

At ELEKS, we decided to put the ecoCode plugin to the test on one of our projects.

Sustainable Solutions: Green Software Engineering from the Perspective of a Mobile Engineer

And here is the example of issues identified on the Android app:

  • 7 issues with the use of a light theme in themes.xml which can affect power consumption on smartphones.

  • 4 issues with <uses-permission android:name="android.permission.WAKE_LOCK" /> turning on the screen that drains the battery.

  • 1 issue regarding the use of Firebase Analytics which may be a threat to privacy.

  • 10 notifications-related comments from Cordova.

Here's the result for iOS

Sustainable Solutions: Green Software Engineering from the Perspective of a Mobile Engineer

Sustainable Solutions: Green Software Engineering from the Perspective of a Mobile Engineer

Based on our experience with ecoCode, we can say that ecoCode is at the initial stage of development and still requires fine-tuning and expanding the code analysis rules. But from the results we received, you can already see what goals it sets for itself.

Key takeaways

As the world strives to become more sustainable, green software engineering is emerging as a key player in developing solutions with minimal ecological footprints.

Companies have several options to ensure a greener solution, including taking actionable steps such as optimising code, integrating energy-efficient libraries, implementing power-saving features, etc.

Following eight green software engineering standards can also help establish a framework for environmentally responsible software development. Additionally, companies can opt for external tools that help ensure the code's eco-friendliness. Our investigation has shown that even though the ecoCode plugin is still in its early stages of development, it has the potential to help develop more sustainable applications.

Ready to take the first step towards sustainable software development? Contact us today.

0
Subscribe to my newsletter

Read articles from ELEKS directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

ELEKS
ELEKS

A global software development and technology consulting company. We're passionate about pioneering innovation and crafting elegant, sustainable technology solutions.