Hacker News new | past | comments | ask | show | jobs | submit

Prevent cognitive debt by manually retyping LLM-generated code

https://ankursethi.com/blog/prevent-cognitive-debt-by-manually-retyping-llm-generated-code/
loading story #49155229
loading story #49154929
loading story #49153987
Good advice yesterday, good advice today, and good advice tomorrow.

I don't remember if I read this advice or just intuited it myself (perhaps after some hard lessons), but it's a programming habit I've kept for as long as I can remember (I started coding in the 90s). If I feel rushed, e.g. someone looking over my shoulder, and I copy+paste something, it always leaves me with a sense of unease. It creates a memory & comprehension hole that sticks out like a sore thumb, even for seemingly simple snippets. You can't really be sure it's simple without stepping through it carefully, and simple can be deceptive because it's usually the interactions and assumptions wrt surrounding code that lead to surprises. Typing out code manually gives you time and space to consider the broader picture.

loading story #49156525
loading story #49160578
What I did is kinda similar, I downgraded to $20 plan and just ask questions and almost never let it write the code, and if I can I use the web ui like the good old days and not spend my CLI tokens.
loading story #49153905
loading story #49154216
loading story #49157006
loading story #49159121
loading story #49154114
loading story #49154721
loading story #49159472
This is a new form of prayer for those who can't break their religious addiction to LLM code generators.
loading story #49153798
loading story #49158332
loading story #49156437
loading story #49155166
loading story #49155497
loading story #49159893
loading story #49156780
loading story #49154099
loading story #49153939
loading story #49154529
loading story #49158919
loading story #49158904
loading story #49154200
loading story #49160661
loading story #49156723
loading story #49158684
You are cooked if you can’t actually write better code than llm. Try reading some books or documentation
loading story #49153820
loading story #49154129
loading story #49154867
loading story #49157057
loading story #49155912
loading story #49158862
loading story #49154201
loading story #49157927
loading story #49158641
loading story #49154324
loading story #49154104
loading story #49154370
loading story #49154070
loading story #49154295
loading story #49158077
loading story #49157390
loading story #49153925
loading story #49154118
loading story #49155701
loading story #49154722
loading story #49157242
loading story #49160001
loading story #49154622
loading story #49154066
loading story #49157894
loading story #49154081
loading story #49154351
loading story #49154068
loading story #49156544
loading story #49153924
loading story #49157369
loading story #49153899
loading story #49154097
loading story #49156604
loading story #49156313
Nice workflow! I'll give it a try. I'm struggling with building mental model of AI-generated code. And code review fatigue is real. This may be the way.
loading story #49153868
loading story #49157703
loading story #49155005
If you copy/paste code from a teaching book, you will probably not learn as well as if you type it.

Typing itself is irrelevant, it is the timing spent, even if only seconds, pondering at what each word or syntactic element is and why use it.

Being slower does not automatically make you learn better, focus on the learning is what makes the difference.

If you don't have the opportunity to learn, the time to actually think, then a faster tool is not helping.

TL;DR: what matters is why you are doing something, is it solely to get the task done or is it primary to learn, or both?

loading story #49154586
loading story #49158556
loading story #49159265
loading story #49154592
loading story #49154054
loading story #49154488
loading story #49156857
But this way you move way slowly even on personal projects, like you will not even get the basic UI for the app done in a few days? Is that OK for you?
loading story #49153763
loading story #49153749
{"deleted":true,"id":49153703,"parent":49153374,"time":1785752046,"type":"comment"}
loading story #49154746
loading story #49157623
loading story #49157432
loading story #49154020
loading story #49156994
loading story #49156588
loading story #49155515
loading story #49154101
loading story #49155491
loading story #49154107
loading story #49154309
loading story #49154077
This method doesn't seem bad.

Realistically, LLMs write code much better than most people. In my domain, there are areas where I still write better code than an LLM, especially when it comes to physical constraints it might not understand, but there are far more domains where the LLM writes much better code than I do. In that sense, writing code with an LLM and keeping track of it feels more helpful than I expected.

Practicing solo coding for an hour a day often ends up being mechanical and not very useful. This might actually be more helpful.

loading story #49157071
loading story #49156654
{"deleted":true,"id":49153748,"parent":49153374,"time":1785752383,"type":"comment"}
In my current workflow, I've settled into a three tier system when coding:

1. HIGH-VALUE CODE:

I write it all myself. I will occasionally use AI for mostly mechanical changes, like cleaning up variable names or mass-changes when a function signature has changed. Either way, every line is read carefully. Sometimes this means isolating my high-value code as a library in a separate repo. Usually it's just a note in AGENTS.md, or even a well-written comment at the top of certain files. I'm not obsessive about it, though, as it can't hide from git. And learning what it's trying to change is sometimes a useful insight.

That doesn't stop me from using AI as a consultant. This is the one time I'll use a beast like Fable. Ask it to write a technical/security analysis on a section of code and damn it can pull out some impressive insights. It can't write new code particularly well, but it can inspect code like a boss. But that all stays in the chat window. (And despite being so infrequent, they ends up costing significantly more than all my other AI costs combined!)

2. BOILERPLATE/PROCEDURAL CODE:

I'll write the first draft, but once I've set the tone, I'll allow AI to build and maintain it. I keep on top of things like a senior manager, just to make sure it's not doing stupid things. Every few days I tell it to mow its own grass: AI is good at recognising its own stupidity, you just need to give it an opportunity to look.

3. TEST/HARNESS CODE:

Bring on the slop. If I get nothing else from the AI revolution, it's not having to write another stupid test unit. Nothing makes me happier than setting the AI to work writing every permutation of test I can think of. I will slop this code all day, and I won't read a single line of it. Why should I? If I ever doubt whether a particular test is correct, I'll test the test by breaking the code, not by reading the test. But I almost never catch it out. In my experience, AI is especially good at writing tests. Perhaps more than anything else.

Tests don't just take the form of a few mocks and props in a test harness. In one recent case, my project involved writing a library for the API of an obscure commercial microcontroller-powered device. I took the API documentation and made AI build me a complete simulator. I then made it write a full suite of tests using my client library within the test code. I then got it to run that test suite against real hardware and identify any inconsistencies. From there it could recursively modify the simulator until it became unreasonably good at mimicking the real hardware. I haven't read a single line of its code. But it's now core to the library's CI.

loading story #49156213
loading story #49157802
loading story #49154262
loading story #49157461
loading story #49155765
loading story #49155330
loading story #49154732
loading story #49155640
loading story #49154730
loading story #49155001
loading story #49153883