ad
We Should Write Energy Efficient Code

We Should Write Energy Efficient Code

I remember the days when Intel released new chips back in 2015 Intel I7 6000 Series, and it actually meant something. We had real performance improvements, and you needed the new model. Taking chips from 14nm to 10nm was a big deal.

Now we have reached the limits of physics, so basically, 3nm of the Apple M4 is the smallest we can get with small room for improvement

Progression

As we went down in nanometers, I actually thought that when we reached the limit, there would be no improvement.

But I was wrong. The problem all along was not the hardware; the problem was the software. The first to realize this were Apple developers when they changed the architecture of their CPUs and saw a massive improvement.

Imagine that a simple change to the software increased the performance of a CPU by 10 times with basically little to no improvement to the hardware.

This is a comparison of a relatively old M1 Max Chip with the latest I9 MacBooks that existed before the Apple Chips. Also, the power consumption is almost cut in half, which is why new MacBooks have much better battery life than the old Intel models.

Energy efficiency in 2010

Do you remember when buying the new iPhone actually meant something? Now every model just gets a software update, and that’s it. No actual hardware improvements.

Creating websites in 2010 with PHP was not the most energy-efficient thing. As it turned out, you needed a lot of energy to run a PHP server at scale.

Both the x86 architecture consumed a lot of power, and the old PHP needed strong hardware to handle a lot of traffic.

Compared to 2024, we are still running code on x86, but our software has gotten a lot better, consuming much less power with better languages like Go or Rust or Even Kotlin.

Writing Energy Efficient Code

Big O Notation plays a bigger role than previously imagined. You might think that as a single developer you might not make a change if you write clean and fast code, but I believe as developers we are making backward improvements, especially on the frontend.

When talking backend, Go is amazing, Kotlin is fast and clean, and even PHP is starting to become better. But on the front, energy efficiency is not something Vercel really looks into.

As time progresses, we need to realize that hardware has reached a limit and there is big room for improvement in our software.

Efficiency > Power

People in 2024 value efficiency more than horse power. People don't want beast computers that pay $6000 for and weight 20lbs. They want lightweight programs running on ARM Chips written in Go, Rust. We need to double-down on improving the performance of our code rather than wanting 1000 Watts to run Adobe Photoshop on x86.

Also battery life is much more important. That's why I made a change on my software on Kotlin for my API's and vanilla Web Components on the frontend.

Solution

The big tech companies have already started focusing on software and architecture instead of adding more transistors.

As individuals, we should shift our focus to faster and memory-efficient languages on the backend and simplify our frontend code.

Electron for desktop should be discarded, and React Native for mobile should be used with ease.

Overall, monitor metrics like size and memory consumption for your apps and try to reduce them as much as possible.

Paying $10k per month on AWS isn’t a solution just because we can. JetBrains requiring 4GB of RAM just to open the IDE isn’t normal. They should actually switch to Go or Rust.

Conclusion

We can create the illusion of faster hardware simply by making significant improvements to our software. By optimizing our code and focusing on efficiency, we can enhance performance without needing to upgrade physical components. This means writing cleaner, more efficient code, choosing faster and more memory-efficient programming languages, and simplifying our frontend frameworks.

Ultimately, by prioritizing software optimization, we can achieve the performance gains that might otherwise seem possible only with hardware upgrades. This shift in focus can lead to more sustainable and cost-effective solutions in the tech industry.

Thanks for reading, and I hope you found this article helpful. If you have any questions, feel free to email me at kourouklis@pm.me, and I will respond.

You can also keep up with my latest updates by checking out my X here: x.com/sotergreco