DEV Community

Brian Mayo
Brian Mayo

Posted on

How "green" is your code?

Hello guys.

I often think about electricity consumption. Services and Servers running never stop (leaving aside on-demand instances, but they are also in servers).

From the moment a user navigates, lots of things happen: servers, internet providers, submarine cables, Satellites, GSM, electricity and more electricity.

How can we help our planet in our day to day work? Perhaps:

  • High efficiency algorithms: If users have 16 gigs of RAM with a Quad core CPU it doesn't mean we can use all the available resources
  • Light weight resources: making users download heavy resources consumes more data and in consequence more battery
  • Configurable background services: Why don't provide the user with settings to adjust how often he/she needs to update data?
  • Colors: don't use colors that make users increase their screen brightness
  • ...

Maybe I'm going too far, but do any of you think about this when you are writing code? Does this motivate you to write better code?
Is it possible to write energy efficient code?

Discussion (4)

Collapse
protium profile image
Brian Mayo Author • Edited on

The modality of "pay what you use" it's sort of a first step. Back in time when you had to pay monthly for the entire server you may didn't care about it. But with this modality you know that you can make a huge difference about how much money you spend running your app by improving it. And it can become a good challenge for you to decrease as much as possible that bill.

We need to bring this concerns to new developers and new start-ups. The path is long and our steps are small. But I think it's possible a future of "green" code.

Thanks for your comment

Collapse
markel profile image
Markel F.

A very interesting perspective.

As an addition, the cloud platform of choice may be important in our environmental footprint. Some companies use green electric sources while others don't.

Collapse
ojacques profile image
Olivier Jacques

Great topic. There are quite many resources on Green ICT in French, but very little if nothing in English. What I learned lately is that it is not so much about efficient code, but more about considering the impact of the service end to end. And when you do that, the impact of building the devices (PCs, phones, tablets) far exceeds the impact of the running code.
Now, that running code can be really efficient (and the service built differently) to reduce the need to have to replace the device to use the service.
Quite an amazing journey, clearly in its infancy, but with very critical impact in the medium term.