❓ Hey Masto, I got a #webdev and #greenIT question for you.

I have worked with Python/Django and PHP/Symfony for 15 years.

🌱 I'm deeply concerned about the tech environmental footprint, so I want to learn a new stack that requires less energy from servers.

Based on this (https://thenewstack.io/which-programming-languages-use-the-least-electricity/), and on the fact that my skills are mainly OOP and I like full-featured #webframeworks , I'm considering Go/Gin or Java/SpringBoot.

Do you have any advice/feedback? Is this even a good idea?

#eroom

Which Programming Languages Use the Least Electricity?

Can energy usage data tell us anything about the quality of our programming languages? Last year a team of six

The New Stack

@david_guillot
First, do you make "basic" websites or web apps?
Meaning, if the content you serve is more or less static, then caching the response could be all you need.

If webapps:

That article is a bit old, and energy consumption is not a common consideration.

Would requests per second allow for a decent estimation? The more requests per second, the least overall resources needed per request.
Then you can find more comparisons, and made more recently.

@Olissipo My focus is on webapps, or at least complex websites. The first obvious thing is of course to avoid heavy JS-first front-end, which is why I've been a #htmx advocate for a long time. But on server side my guess is that a Python/Django application takes a lot of CPU, which makes the cloud's autoscaling service bring new containers even when the requests/s is quite low. I wonder if faster/leaner languages would be more efficient on that matter.
@david_guillot can’t beat go/gin in my opinion, brilliantly combined with gorm or sqlc
@lil5 Thanks for the suggestion! After looking at it I'm a bit worried about #GinGonic : is this project alive? No blog entry since 2020, documentation is really poor, no release in the past 7 months, less than 1 closed issue per week while 600+ are opened... Is it a safe bet? When you're used to Django vibrant community as I am, it's worrying...

@david_guillot

https://pkg.go.dev/github.com/gin-gonic/gin?tab=versions

As you can see from gin versions they don’t release very often. But the project is maintained.

Anthony (@[email protected])

Attached: 1 image Remember that paper that ranked programming languages by energy consumption? The one that said that TypeScript was 4.8Γ— less energy efficient than Javascript (⁉️) and never mentioned which runtime they used for this benchmark? Well, there's a new paper debunking it and showing that, as per usual, it depends. Energy consumption depends on the programming language, the interpreter or compiler used and how the application is written. https://arxiv.org/html/2410.05460v1

Indieweb.Social
@anthony Aha, thanks, that's my next read on the topic πŸ‘€

@anthony Yes this paper explains that (obviously) things are more complicated than a simple language->energy thing.

It made me realize that more than energy consumption, what matters to me is: if I'm deploying my app to a container-based hosting, is there a tech stack that will minimize how many containers I need to serve my clients? Probably compiled languages could help on stopping the CPU to be the bottleneck...

I might give #golang + #ginframework a try πŸ€“

@david_guillot I find most web things to be I/O bound (talking to databases) rather than CPU bound. Rather than looking for a faster server language, I'm (personally) more interested in optimising data storage and retrieval, along with making sure there is a good HTTP caching strategy.
@anthony In my recent experience I've seen Python using a considerable amount of CPU while browsing through complex datasets coming from a PostgreSQL db through Django's ORM (with multiple `prefetch_related` clauses like you end up with when you try really hard to avoid N+1 problems on a sophisticated website). Even with PostgreSQL running on localhost, I've found page load time slowed down by CPU usage by Python. This is why I want to try something totally different πŸ˜‰

@david_guillot Very fair.

If you're looking for a challenge, it might also be interesting to see if there are any perf improvements to bring to Django for your use case.

@david_guillot elixir + Phoenix, exceptional DX, quite performant especially for the web, beautiful language not that far from python(functional though), currently trying to learn it, not enough free time
@tobide Hm thank you, I did not realize Elixir could be a good candidate. Gonna take a look πŸ‘€