Comment by Someone

6 months ago

> And since a lot of devs are lazy (let’s be real), they’ll directly paste whatever they get from the platform.

If so, there will be a zillion slightly different ways to do foo in the code base. I don’t see how that would decrease bloat.

Asking the LLM to reduce code duplication might help a bit, but (call me a pessimist) I think it will introduce subtle bugs, too.

In context of UI code generation, there are only so many ways a UI can be built. For example, everyone knows that unnecessary re renders are bad, and that in React it’s best to minimize the use of useEffect and useState whenever possible. Even today, LLMs can already generate fairly optimized UI code. And if you want an even more optimized version, you can simply add instructions in the prompt, asking it to avoid useEffect, useCallback, or useMemo and so on.... unless absolutely necessary. But of course, this kind of implementation usually comes from someone with development experience.

Now, think about a new developer who has just started coding. Let’s say they build a side project called Top Million Developers, where the app fetches data from an API and renders a Table with simple pagination on client side. They launch it on Twitter, it goes viral, and suddenly they are getting thousands of page views. Very quickly, they wll notice their site is slow or even unusable because they didn’t know that rendering a large table in React is not that straightforward. They should have used virtualization to handle it efficiently.

In today’s world, though, the same developer doesn’t need to figure this out manually. Instead, they could simply ask an LLM to generate the code, and it would most likely return an optimized version with proper virtualization and pagination built in.

That is what I mean when I say LLMs can already output optimized code not perfect but quite a optimized code by default in context if UI.