Hacker News new | ask | show | jobs
by XCSme 6 days ago
Congrats, I love performance optimizations!

Hardware nowadays is so powerful, but our code so inefficient... I think most libraries/apps could easily be 10x-100x faster if we really try to optimize them.

The good thing is, that now with AI, we'll probably have the time to implement those optimizations rather quickly.

2 comments

The issue is really with testing! You can do such optimizations but you have to be sure that the result is the same in ALL your use cases, so you need very good test coverage and quite good tests as well.

LLMs can help with the amount of test, and somewhat with the quality, but that's not quite enough for doing heavy optimizations in existing, deployed products, in a normal sprint somewhere.

I think sometimes optimizations are more about using the right data structure/ideas/libraries.

In my case, I recently optimized for https://uxwizz.com the session playback: before, it was saving the entire recording in one row, with updates, and loading it client-side in one chunk. I asked thr AI to, instead, store the recorded chunks in separate rows in db, and when replaying, to stream those chunks as needed. It implemented it perfectly, and everything is much snappier and lighter now.

So, the idea was "store in chunks and stream the chunks", and the LLM does it. Yes, there were a few bugs, but those systems genetally either work or don't. So testing for a 30 minutes after was enough, and now the system is live, and a client actually told me in person yesterday he loved the playback improvements.

I said in another comment somewhere, now knowing how to code isn't important, what's important is that you know what to ask, and what to look for when testing.

> The good thing is, that now with AI, we'll probably have the time to implement those optimizations rather quickly.

Haha, yeah, product/executives will surely now see the benefits of optimizations instead of piling new features on top of new features with no cohesive idea about the design or architecture :)

In my experience, when adding new features with LLMs, most of those optimizations come automatically.

Good models now already follow best practices when implementing, better than junior devs.

I wrote a bit about this, I call it "AI slap", lol:

https://x.com/XCSme/status/2079115230567686263?s=20

> most of those optimizations come automatically

We're clearly thinking of very different "optimizations" here I think :) Do you have any concrete examples of this sort of optimizations you'd get automatically? In my experience, you get what you prompt for, if I don't include to think about performance, they won't think about performance, not sure what model would automatically consider things like that. Most of the time I use whatever SOTA OpenAI has on maximum reasoning level, fwiw.

Not only performance optimizations, but also UI/UX.

If you ask to implement a custom dropdown that does something, it often comes with good spacing, aria-accessible tags, keyboard accessibility, etc. A junior dev wouldn't think of all of those.

Also, it will probably choose the right HTML elements to use for it (i.e. maybe the modern native popover functionality instead of implementing it with custom JS, which would indeed be more efficient and less code).

I am not saying it would add caching by default (even though, it might suggest that), but it's more likely to choose whatever the best options are and to use them as they should, including going around knowing limitations and gotchas.