Ask HN: How to deal with shipping AI-written code you don't understand?
I'm retired, so the only person I answer to about progress is myself. I'm stubborn about choosing quality over speed, but I still like progress. This morning I got preliminary results from a 'C' front-end to my compiler that uses clang to compile to LLVM IR, then translates to our IR and feeds it into the autovectoriser. For the exact same source code, I'm seeing speedups from 2.1× to 1,312× over clang -O2 on benchmarks like saxpy, Mandelbrot, nbody, perlin, and mandel_deep, with checksums matching. Hacker News isn't interested—any post I make linking to the webpages is immediately blocked/dead—so I'll wait until the C++ front-end is ready next week and announce it somewhere else. A compiler that takes standard C/C++ code and speeds it up by automatically finding data-parallel areas and scheduling them on the GPU with no programming overhead is pretty rare, and it also manages the local network so you can run xcd on machines on your LAN or via the TB4/5 bridge between Macs.
Those are some pretty fine speedups, from naive C, with no alterations from the standard "C" code - it automatically finds places that can be made data-parallel, tracks the data-hazards to make sure its safe to "GPU" and writes all the kernels, boilerplate and data-stream-management if necessary.
Obviously the checksums have to match, so I know it did the work correctly too :)
Oh, and it manages the local network as well, so you can run xcd on machines on your lan, or via the TB4/5 bridge between Macs and it'll schedule on other GPUs, just like it manages multiple GPUs on the local machine. It characterises both latency and compute-time to figure out which devices are worth scheduling on.
- bitwizeshift
I’m surprised I haven’t see anyone say this yet, but I don’t let the LLM design the code at all, I let it implement a design I have created.
By that I mean that, rather than let the LLM do the entire structure, I take the time to create the full hierarchy of abstractions and actors that I want my code to do. I decide, at the UML level, how abstractions will sit and interact — and then I make the LLM implement those gaps.
The key thing here is that, by doing this, I DO know how the code works. I may not know how each unit is implemented, but I know each unit’s responsibilities and how they interact with one another. I’ve found that LLMs are HORRIBLE at writing decent abstractions, regardless of how much prompting and skills I’ve given it. It will always get the job done, but it will often be unmaintainable and require bigger and heavier refactors as I introduce more and more requirement changes.
But by flexing my basic design skills, I don’t have those issues. Future refactoring fit into easy abstractions that I’ve designed. And by documenting it up front, I also have what becomes a living document on how this work will turn out.
It takes a few hours up front to plan ahead, but it makes the LLMs job easier and use less tokens, and it makes the code better long term. I don’t care if one unit is suboptimal, as long as the abstraction is right — because at worst I can change an implementation for a better one later.
- jedberg
I've been a Principal Engineer for a while, so this is how I've worked for a while. Sometimes when you're a PE, you either design something and then junior engineers implement the details, or you're dropped into a project that was already designed and built by more junior engineers, and you have to quickly understand the design an as many details as you can.
With AI, everyone now gets to act like a PE. Your job is to design, the AI builds like the junior engineers. Then you review their work. You may never understand the details, and that's ok, as long as you know the main ideas and where to ask for the details (in this case the LLM instead of a human).
- unsloppable
I remember less than 1% of the code I ever wrote. AI hasn't changed anything for me.
- bob1029
The closer the code gets to the user's eyeballs the less I care about anything specific.
HTML/JS/CSS is basically entirely vibe coded. I won't even try to reorg the 4000 line ui.js file. I can just redo the whole thing from a new prompt in a few minutes.
For things like the SQL schema I am still doing things entirely by hand. The consequences of getting this part wrong tend to be far more catastrophic than something in the UI layer.
- tptacek
These threads kind of rule. Lots of different answers!
For my part: I've put some of my tooling energy into code comprehension tools. You can get remarkably far quickly by just replacing the Github PR viewer! I started with a (native SwiftUI) read-only front end for tree-sitter and SCIP (the code-indexing standard). Then: as I reviewed PRs, I tried to catch myself doing annoying repetitive things and just building out additional features, like "show me all the knowable call chains for this function", or "show me every implementation of this trait".
You can get a fair ways just by thinking of things to hide in a PR viewer, just to clear space for the things you need to comprehend.
- ChrisMarshallNY
Testing.
Lots and lots of testing. I usually interactively test with the LLM. Now that I'm spending less time, coding, I get to spend more time, testing.
In my experience, I test more, with an LLM, than I did, with my own code. I don't find coding errors, but I do find implementation errors.
On another note: I ran an LLM on a bunch of really mature code that I wrote, and could swear was "perfect," and it found a number of issues.
Nobody's perfect. Trust; but verify.
- joaquieneCnix
> if we're going to spend our time checking each line of code, it's going to take forever.
How many more lines of code are Meta engineers shipping that they don't have the time to check the ones they _didn't_ write?
This makes no sense to me. So I spend vibe coding some app. I barely know code. It's 40 000 lines without comments. Say it's my job, and pays the bill at the end of the month. Say the LLM and I would have done the vibe coding within a week. I'd need one more week to check every line and understand everything. I'm a noob, this dude's a pro, so complexity is irrelevant. What the hell are they doing the rest of their time? Shipping more code?
And if that's true, and again, I'm a noob: shouldn't their "instincts" tell them to write tools to increase comprehension speed? Better interfaces? I hate everyone single one out there and designed a better one. Now I have to port to Rust/Actix/GPUI and some vibe coded redis because that thing is laggy as hell ... but I HAVE TO UNDERSTAND HOW it works because otherwise I cannot improve/customize the stuff/frameworks already out there and that people build with ...
What are they doing with their time? There are all these posts out there of programmers and systems people not doing anything 90% of their time? If it's already shipped, don't you try to understand the details afterwards?
- spacedcowboy
I’m slowly coming around to the idea that if it works, I’m good with that. I never used to personally check all my colleagues work, either, I just trusted that they’d done a good job.
That’s not to say I blindly trust an LLM - my project is an autovectorising compiler. I have it write a bazillion tests, and I have real, non-trivial programs that it compiled. I have it run a ‘gate’ before releases that takes literally hours on 5 different architectures. To say this code is tested is … masterful understatement.
I think what helps is a long planning session, going into details, working out corner cases, designing test-cases, you know work and effort. Once that’s done it’s easier to let it work through the night and do a major production feature.
I still review the code, but hand on heart I couldn’t say I’d reviewed everything, sometimes I miss something in a complicated check-in. I try to keep checkins small and contained, but sometimes that’s not easy to manage alongside the “don’t break stuff” rule as well.
So it comes down to: I’ve been working on this for 6 months or so, and so far this has worked out for me. You know, kind of like getting used to a colleague’s idiosyncrasies over a period of time.
I will say that in my experience the code quality is fairly high. Maybe that’s down to the effort put in ahead of time in the planning stages, I don’t know, but I don’t seem to suffer from the ‘slop’ that people complain of. YMMV.
- leowoo91
[delayed]
- browningstreet
If you work at Meta you should ask at Meta.
For my own projects I’ve limited my exposure points by picking which projects and what scope I ship. I have to iOS apps in the App Store and I simply removed high exposure surfaces - right now neither use accounts because I don’t want to manage account systems, and Apple prefers it anyway. I downrisked my projects from what I could ship and I’m perfectly happy with my production projects.
Most of my other AI written projects are internal apps and systems. I have another project going public soon where I ship the output of LLM written code, without running the code in any user accessible area.
And tests, of course.
In time things will mature, tooling will be better, and we’ll have a different risk quotient.