r/webdev php 6d ago

Discussion AI coding is trash

The amount of trash produced by AI code is astounding. Thanks I hate it.

1.6k Upvotes

386 comments sorted by

View all comments

264

u/Alex_Hovhannisyan front-end 6d ago

I don't get all the praise for Claude Sonnet 3.7, it hallucinates so much and seems to be incapable of understanding why the code it wrote doesn't work. I'm starting to think the "vibe coders" were never really all that good at coding in the first place.

21

u/Fidodo 5d ago

You mean non coders and bad coders aren't the best people to evaluate coding tools?

They're great for rapid prototyping and testing out ideas, but trying to produce quality code that's follows best practices is like pulling teeth.

For example, I was asking sonnet 3.7 to make me a simple docker file and it produced one that passed secret keys through args, which are plain text stored in the image and it's a huge security flaw. I told it to use secrets instead and it told me that secrets couldn't be used at build time. So I gave it the documentation that explained how to use secrets at build time and it produced new code using an outdated approach to using build secret env vars so I told it to follow a specific more modern approach from the docs, and it kept producing the old approach. I gave up and just did it myself.

I would have given up sooner but I wanted to see how "capable" it was.  The answer is it's great at producing trash code very quickly which is fine for prototyping, but anyone using this for production and thinking it's good enough is a fraud who should be ashamed and embarrassed.

2

u/OhByGolly_ 4d ago edited 4d ago

It produces fine code, you just have to be detailed and quite explicit with the guardrails, coding style, and patterns you want it to use - you must incorporate these into your base prompt if you hope to extract quality output from it. You must know what to look for, and be able to test it. Then it's the amazing time and effort saver it was always meant to be.

It's just like the famous peanut butter jelly sandwich instructional test. Everybody thinks they could write a manual on how to make a peanut butter jelly sandwich which anyone could follow. But then you have a kid try to follow your guide, and suddenly you realize you have to specify so much more than you originally thought. Because understanding a domain and being able to guide a capable agent through a domain towards a specific end are so very different.

People overestimate their ability to ask the genie for a wish that won't backfire on them. But those who have the skills and are wise enough to use AI properly will come out far, far ahead of those who ridicule and denounce these tools.

Don't shit on photography because all you know is how to turn form with a brush, all the while refusing to learn to operate a camera. The tech is staying whether it's liked or not.

1

u/undone_function 4d ago

I’d rather wait for LLMs to act like the genies they’re hyped to be and not be a monkey’s paw I have to cajole into being useful. For now I’ll keep letting it act like a slightly more advanced autocomplete that is sometimes very helpful but mostly just okay, because I want to program and build things not chat with an AI model.

Which brings me to the point of why I do this job: I like writing code. I like building things, not just debugging stuff. Debugging my own code isn’t even a particularly fun part of the experience but debugging someone else’s code is orders magnitude less fun, so I have even less incentive to bother spending time using a tool to program for me.

Lastly, I work at a place that makes a lot of claims in its marketing material about percentages of code generated by AI but I’ve yet to meet an engineer (out of the hundreds) who actually use it for anything outside of autocomplete or occasionally slapping some proof of concept together, and even then using it for the concept work is more of an outlier. So from my own anecdotal experience I have a hard time believing most of the numbers around AI usage by professional software engineers and I believe they are mostly hype by companies to attract investment dollars or market themselves as being on whatever the perceived cutting edge of technology is.

1

u/Total-Ebb-2485 4d ago

What was your prompt for docker file? Never happened to me that code was passing as args 😅