top | item 43888972

(no title)

gregwebs | 10 months ago

One definition of legacy code I have seen is code without tests. I don't fully agree with that, but it is likely that your untested code is going to become legacy code quickly.

Everyone should be asking AI to write lots of tests- to me that's what AI is best at. Similarly you can ask it to make plans for changes and write documentation. Ensuring that high quality code is being created is where we really need to spend our effort, but its easier when AI can crank out tests quickly.

discuss

order

dang|10 months ago

My favorite definition of "legacy code" is "code that works".

Anybody know where that quip originated? (ChatGPT tells me Brian Kernighan - I doubt it. That seems like LLM-enabled quote hopping - https://news.ycombinator.com/item?id=9690517)

turtleyacht|10 months ago

After hearing legacy code defined as "code that runs in production," it reset my perception around value and thoughtful maintenance. Cannot find the reference, though.

nonethewiser|9 months ago

"Legacy code" is such a loaded term. There is definitely large intersection between people's working definition of "legacy code" and "code that works". At the same time this is usually NOT what people intend to include. But it fits their definition nonetheless.

Take the author's definition:

>When something is older, and someone else built it

That usually describes the most important, core part of any system that has existed for any significant amount of time. It may even be well understood by most people.

nicce|10 months ago

I would say that legacy code is something that one does not simply change.

You cannot update any dependencies because then everything breaks. You cannot even easily add new features because it is difficult to even run the old dependencies your code is using.

With LLMs, creating legacy code is using some old APIs, old patterns to do something, that is not relevant anymore, but the LLM does not know about.

E.g. if you ask any LLM to use Tailwind CSS, they use V3 no matter what you try to do while the V4 is the latest. LLMs try to tell you that pure CSS configuration is wrong and you should use the .js config.

nonethewiser|9 months ago

In some way tests are the worst thing for LLMs to write. Because you have to verify what the LLMs generate. Are you going to write tests for tests? No.

I dont think this _necessarily_ makes them bad for writing tests but you really need to be careful and examine what it gives you and even tweak it to fail in a way that verifies it's working. Conversely, you could write the tests yourself and then literally copy-paste the code-to-be-tested without any significant examination.