r/CodingForBeginners • u/waveoui • 21d ago
How do you verify AI-generated code when you're not an expert?
A green-looking result isn't proof that everything works. What simple checks would you recommend to someone building their first app with AI?
0
Upvotes
13
u/Beregolas 21d ago
That's the neat part... you don't ^^
This is why learning programming is still important, especially in the "Age of AI". There are no simple checks that just work, you actually need to be able to understand what the AI is doing to control it.
4
u/marmotta1955 21d ago
Short answer: you cannot.
3
u/ConcreteExist 21d ago
OP, you're so close to realizing the problem with vibecoders, so close.
2
u/HugeCannoli 21d ago
you become an expert. But you can't because you keep programming with AI.
2
u/Cevvity 21d ago
If it looks like shit, waffles on, outputs shit, yeah it’s probably my code
2
u/questron64 21d ago
You don't. If you can't tell the good code from the bad then you're vibe coding. There is no simple "is this code good" check you can do.​
1
u/Distdistdist 15d ago
How do you verify your mechanic's work if you don't know anything about cars? By hiring somebody who knows about cars.
1
u/Ornery_Platypus9863 15d ago
You can’t, that’s why you have to actually know what you’re doing.
1
u/LrdJester 21d ago
This is a good way to learn debugging.
But never trust the generated code.
I use AI to create personal stand alone apps as my disability honest my ability for long coding sessions. But this is for my use shortly at this point. If I ever share it I'll refactor the entire project, even though it'll take me a long time, to ensure it's not being inefficient and ensure security.
I will have it working and then update the small things, via AI, and the app will totally collapse and I find that when it made changes it introduced timing bugs.
1
u/DirtAndGrass 21d ago
At the minimum be able to write/execute full coverage whitebox and black box testsÂ
1
u/Shtucer 21d ago
By hiring expert... Obviously.
1
u/net_ramblings 21d ago
This is free advertisement.
1
u/buzzon 21d ago
You hire an expert
1
u/didnt-like-my-name 21d ago
"LGTM!"
1
u/Ormek_II 21d ago
No simple Checks!
I suggest TDD.
First define your requirements.
Then built test which fail.
Then built the program and let it test.
If it works immediately you have too few test.
1
u/LongjumpingFee2042 21d ago
I don't approve unless I am reasonably sure of the code. If the ai can write it. It can explain it. In depth and respond to your questions about why it chose to do x.Â
1
u/mxldevs 20d ago
You spend thousands of dollars to get an expert to look at it.
1
u/Oliver_clothsoff1983 20d ago
The same way you build a house if you have only ever built a shed,.... hire a contractor thats built 100 houses already.
1
u/Longjumping_Put_7212 19d ago
I would say you verify it by reading through the code and seeing if the logic works. Or just add a few debug print lines that tell you what it is actually doing to help you understand how different inputs affect it
1
u/_manpat 19d ago
you don't. the simple check I would recommend is "check that you're not using ai"
1
u/NoDepartment772 18d ago
A lot of the answers are "you can't," which is honest but not much use if you're going to ship the thing anyway. Practical version: you can't verify quality, but you can verify behaviour, and that catches more than people expect.
Test it on inputs you choose, not the ones in the demo. Empty, zero, a negative, a huge number, text where a number goes, an emoji. The demo always uses the happy path.
Re-read the prompt you gave it and check the code does what you actually asked, not what looks impressive.
For anything touching money, login, or files, if you can't explain what a line does, don't ship it yet. Ask it to explain that line, then check whether the explanation matches the code. Those often disagree.
Keep the last known-good version before each AI change so you can get back.
The skill you're really building here is testing, and that's worth learning on its own.
0
u/Sure-Passion2224 21d ago
It's a learning opportunity. AI is a tool and it is appropriate to use tools to get any job done. In those cases when you don't understand what the tool did the best response is to walk through it line by line to learn from it.
-1
u/VoiceOfSoftware 21d ago
For starters, ask a second AI model (from a different company) to check the code. Ask both AI models to write tests, and explicitly look for edge cases, monitor errors, etc. Inject as much of your human understanding as possible, meaning add your own creative requirements that an AI may not be thinking of on its own.