logoalt Hacker News

Ask HN: Will programmers write more efficient code during the memory shortage?

91 pointsby amichailyesterday at 10:51 PM158 commentsview on HN

Maybe there will even be more interest in the invention and use of more advanced algorithms and data structures that use less memory?


Comments

astrobe_today at 8:24 AM

We sill probably see an increase in the use of OS-level memory compression tricks instead - things like zwap on Linux, for instance. Because the trend is usually to cure the symptoms, not the cause, as it is generally easier to set up and good enough. Makers who already have invested on memory-careless tech such as Electron won't rewrite; at best they'll just be replaced by better alternatives.

swiftcodertoday at 8:23 AM

Realistically, the impetus here will come from the platform holders, not the individual programmers.

Apple recently released an 8GB MacBook Neo, which bucks the previous trend of increasing RAM in low-end SKUs, and signals that software needs to be prepared to run in that configuration for a long time to come. I expect we'll see similar moves in smartphones if RAM prices stay elevated.

jpollocktoday at 3:53 AM

Programmers will write more efficient algorithms if their employers tell them to trade time-to-market for hardware cost. Previously, it was trade hardware cost for time-to-market.

"Programmers" don't make this decision, the product owner does.

show 1 reply
cornstalksyesterday at 11:16 PM

Some programmers will write more efficient code. At my $dayjob (one of the big tech companies) we're already planning a major goal next year of optimizing server code to reduce RAM requirements, and this is directly in response to the crunch.

In practice I expect most optimizations will come from "stop doing stupid stuff" and not "use fancy advanced algorithms." But that's a cynical perspective so don't be cynical like me.

show 4 replies
patrulektoday at 8:14 AM

I would say that in most cases you dont need fancy algorithms and data structures, you just need to stop treating RAM as a rough notebook. Allocating in a loop, not reusing buffers and pointer chasing are a performance killers and are quite easy to avoid before they are introduced to code. Other than that, just be more thoughtful about network and disk usage and nested loops. Its a sum of stupid things that make your program slow.

jimnotgymtoday at 6:29 AM

It is a really simple matter of incentives.

If your backlog is full of feature requests you will add features.

If your backlog is full of tasks to reduce memory usage, speed up areas etc., then that is what you will do.

Most programmers will have no choice whatsoever.

rramadasstoday at 8:24 AM

You must be joking.

Niklaus Wirth wrote his A Plea for Lean Software in 1995. Pdf at https://people.inf.ethz.ch/wirth/Articles/LeanSoftware.pdf

People did not bother and then the Web made everything worse. We are now so used to layers and layers of abstraction, humongous libraries and frameworks that most do not know anything about how to write "lean" software.

Nothing is going to change in the application/services layer.

andixyesterday at 11:22 PM

If that happens, we will see it in triple-A games first. If some new titles have significant lower hardware specs than expected.

If buyers can't afford the hardware anymore, the studios need to adjust. It's definitively possible to scale games down a lot. There are a few AAA games that were "dumbed down" for the Switch 1 (Hogwarts, cyberpunk, ...). And that's a really low-spec device.

There are two factors: existing gamers not able to afford upgrading. But also new gamers, that might only be able to afford much lower spec PCs than people who bought 2 years earlier.

Why games? Because there is a clear point where people stop buying games. Minimum hw specs are known before buying.

show 9 replies
ccotoday at 5:10 AM

I expect mobile OS and maybe mobile app developers to do so.

Google has already downgraded memory for their upcoming Pixel 11 while at the same time imposing local running models as a first-class feature. Both decreasing the memory pool and increasing the demands on it.

The key is that they own the full stack (hardware and software) and can demand the OS be more efficient, along with perhaps forcing that goal on app developers as well via tightened background limits etc.

dehrmanntoday at 6:24 AM

> advanced algorithms and data structures

This isn't where memory goes or real-world speed comes from. For most applications, it's abstractions like React running in electron that hurt performance. There are also richer resources backing parts of apps--higher resolutions, better quality, higher framerates.

naetyesterday at 11:56 PM

I don't think we will in the HN snark sense of "this react site or electron app uses way too much memory". Those companies will continue to work in the same way, maybe even less efficiently as people chase modern UIs with extra animations or videos or effects, or with some AI code generation tacking on too many features or tech debt.

In specific sectors I do think we will see more optimization. If you're working on cloud compute or AI training / large scale data processing, there will be a big focus on optimization as prices are very large at that scale and shortages have a bigger effect.

Also in gaming I think the next cycle will be different. Big game studios used to push for the best possible graphics that might require the newest consoles or high end gaming computers, but the next releases might not be as much of an upgrade. The next gen of consoles or graphics cards themselves might be delayed, or be less powerful, or be too expensive and flop, as chip manufacturing companies continue focus on more lucrative markets and leave average consumers behind.

lesuoractoday at 3:17 AM

> Will programmers write more efficient code during the memory shortage?

If we can insert "some" then Yes.

> use of more advanced algorithms and data structures that use less memory?

I don't think so.

At least at work there is a push to decrease memory usage but the way I've seen it playing out is not using some O(N) data structure instead of O(N lg(N)) per-say but instead replacing `int[]` with `byte[]` or in-lining some fields to remove some indirection costs.

nrmitchiyesterday at 11:26 PM

Until prices hit the large hyperscalers, I don't think most people are going to make significant changes. You might see a small set of open source projects related to self hosting put in an effort, but in general, I don't think so.

Some big-tech orgs (that have their own hardware) will take costs into account, but they already do that. The "optimization" is more likely to be business-optimizations; "this can be slower if it uses less memory", rather than inventing new stuff.

Note that I am excluding any of the big AI labs. They are definitely going to be working to figure out how to use less memory, but that's primarily not related to the direct cost.

sim04fultoday at 7:47 AM

I certainly hope so, it's cheaper than ever to write native code, but if sub-trillion dollar valuated companies like OpenAI have done the math and still use electron for the codex app, one has to ponder what was considered.

tincotoday at 7:32 AM

They might, but the final outcome of that depends on whether the tokenmaxxing rust-using zero-user startups are using more memory in ci/cd than the users of efficiently written successful apps are using in production.

mherkenderyesterday at 11:42 PM

Algorithms and data structures aren't the problem, bundling Chromium to make a chat app is the problem.

I think Rust's rise in popularity will probably lead to some benefits.

Games will probably get more efficient but they're easier to scale down to the memory that's available.

show 2 replies
dainiussetoday at 7:08 AM

My bigger hope (for apple ecosystem) is that macbook neo forces apple to optimize. Devs don't have that scale.

cryo32today at 6:09 AM

That’ll be a minor part of it.

The whole Electron “ship a browser for each app” ideology will die first.

show 1 reply
citrin_rutoday at 6:47 AM

If memory shortages were not caused by AI then may be (but still unlikely). In the current situation even cautious in the past companies are switching to “move fast and break things” mode to not fall behind vibe coding competitors. When the velocity is the top priority there is no time fo efficiency.

hareltoday at 6:43 AM

It's not like we're stuck back with 640kb... At the very least you probably have 8-16GB of RAM still...

kantordyesterday at 11:08 PM

For this incentive to exist, the app needs to be such an obvious memory hog that users start identifying it as the source of the problem.

Even then, a lot is required for most businesses to prioritize this (presumably) temporary issue at the cost of things like: participation in the AI race, other features, bug fixes, new markets etc.

Heck, sometimes software is so inefficient that it costs developer and tester productivity but a fix is not prioritized for years.

show 2 replies
herbsttoday at 6:17 AM

No. They won't.

Most games are written for the 3% who can afford a luxury gaming PC. That's how the market is working for a while now.

jbird99today at 5:39 AM

I'd hope so. Not just because of the memory shortage, but because of the speed at which AI can help write code. Most high-level languages came about in order to speed up development, at the cost of performance and resource consumption. It's time to revisit some of these applications and see if we can use less resources to accomplish the same task. My work laptop with Teams and 2 Edge tabs open uses roughly 11GB of memory, which is insane.

v3ss0ntoday at 7:44 AM

With the age of AISlop why you expecting better quality?

martinaldyesterday at 11:10 PM

I was thinking about this recently. If you discount web/electron bloat, actually the memory bloat of software isn't hugely terrible.

I still often notice that servers on Linux use <1GB of RAM even with relatively high use. I don't think that's really changed massively in 20 years.

pnikosisyesterday at 11:05 PM

There's hope for the extinction of Electron based apps.

show 1 reply
Shitty-kittytoday at 3:15 AM

8Gb laptops are about the only tech still selling. Exec's better think long and hard about that.

winstonwinstonyesterday at 11:02 PM

Unless users complain it’s not going to happen. Somehow SPA (Single-page application) consume memory as much as operating system.

sneilan1yesterday at 10:58 PM

I've dumped python for anything that doesn't involve scipy / pytorch in favor of go. So yes, I'm having my llm's output go now which is generally more memory efficient than python.

show 1 reply
xp84yesterday at 11:43 PM

Programmers might write more efficient code if the performance was unacceptable on their own laptops, but even in the not-flush-with-cash companies I've worked all my career, it's been easy for me to always have a dev laptop with twice as much RAM as most consumers have. I'm presently working on a laptop with 64GB, and we don't even use any local AI models. If a PE company is willing to spec dev laptops like this, even in the memory shortage, then I assume the memory pressure will never hit developers.

So, this carefree attitude directly shapes all code that runs client-side (JS + native apps) since the only impact on the company is whatever happens on the dev's laptop. The rest of the impact is "free" since it's paid (in either money or in misery) by customers.

For server side, I also highly doubt it, as being more memory efficient on the server side has always had a benefit to the company who pays the bill. The only things that may change may be the relative cost, but if management comes and says "AWS bill going up, help?" devs will say "OK, we can find ways to save RAM, but the team won't be doing any new features or fixing any customer-facing bugs during that time" and management will say "Okie dokie, we'll just pay the bigger bill then."

bborudyesterday at 11:37 PM

One can certainly wish, but I am inclined to believe that RAM use isn’t just about sloppy programmers. I think it is, to a significant degree, about the kinds of problems we solve now that we have more RAM.

And not all exorbitant RAM use is about sloppiness. Sometimes you can trade more RAM use for lower complexity. Bugs and development time were expensive. RAM was not. So sometimes there is calculation rather than sloppiness behind certain types of heavy RAM use.

HaloZeroyesterday at 11:16 PM

The memory shortage is really for these insane memory requirements for LLMs.

A web browser and the basic mobile app will be fine.

The iPhone 17 Pro has the most RAM and it's only 12GB. Hell the iPhone 16 Pro only had 8 GB. The vast majority of consumer cases don't need it. I doubt Apple and other manufacturers will go beyond that to keep prices down.

WheelsAtLargetoday at 12:40 AM

No, even at these high memory prices it's cheaper to produce code as fast as possible than to spend the time to optimize it for efficiency. It has always been the case that hardware improves at a faster pace than software. So what will happen is that we will get tech improvements in hardware that will reduce its price faster than we can write software to fully take advantage of the hardware. The current bottle neck that's causing the spike in memory prices will subside relatively soon so we'll be in better shape before we know it.

show 2 replies
__mharrison__today at 6:03 AM

I think they are writing shorter code for to token limits...

(Just refactored an app to do this. 60k lines to 20k)

asp_hornetyesterday at 11:15 PM

> will programmers write

Who’s going to tell them?

show 2 replies
xenatoday at 5:59 AM

Not unless you get promoted for writing more efficient code.

Werewolf255today at 4:44 AM

Are you joking? If anything, they'll use even more memory by shoving 8B LLMs in every single app.

int3trapyesterday at 11:05 PM

No. Customers will pay more across all markets.

show 1 reply
johanvtsyesterday at 11:04 PM

Only if people start buying computers with less memory, if they just buy fewer computers it doesn’t seem worhwhile.

linhnstoday at 6:19 AM

Probably not, clarity still triumphs

comrade1234yesterday at 11:18 PM

Will you stop using docker to deploy a simple application? No? Didn't think so.

casey2today at 7:20 AM

Backwards thinking programmers might (there is currently plenty of memory efficient software; but it's always missing that feature you really need funny how that works). Forward thinking ones will realize we are heading towards the glut of all gluts and buy 4TB to play around with.

xnxtoday at 2:16 AM

AI (like alcohol) is the cause-of and solution-to all our problems.

Computer: Rewrite this python code in Go. Make it memory efficient.

segmondytoday at 12:25 AM

Will they? I don't know. Should they? Yes. If AI is so great, we should use it to optimize. Rewrite all the bloat into lean efficient systems...

cheesecakegoodyesterday at 11:11 PM

Memory? Doubt it.

But I’m hopefully optimistic that we’ll see a renewed emphasis on speed and responsiveness, since users do notice that despite most products ignoring it.

koliberyesterday at 11:36 PM

No. The cost of one programmer’s hour of work compared to the increase in price of RAM is not very big. One is a variable cost one is fixed.

novafuncyesterday at 11:04 PM

I don't see the trend reversing, but if we're lucky, perhaps a freeze. Won't get more efficient but may not get worse.

pjmlptoday at 5:58 AM

One could hope for.

sudoshredyesterday at 11:32 PM

Depends. I can certainly offer to rewrite my old code that contributed to the memory shortage, for a price.

🔗 View 28 more comments