r/learnprogramming • u/Maleficent-Ladder184 • 13h ago
Question about AI and code
Hello, I’ve got a question. How can you tell if a piece of code was written with the help of AI?
That’s because someone’s had a go at my code, but it doesn’t look the same as it usually does. I’m not sure if I’m making myself clear
1
Upvotes
14
u/lfdfq 13h ago
You're not really making yourself clear, no.
In general, you cannot tell if an AI wrote it, or an AI told a human who typed it manually, or a human wrote it. Even the style might not tell you, since it was trained on code written by humans it writes code that looks like it could have been written by a human. The best way is to ask the person who supposedly wrote it how they wrote it and what it does.
5
u/Beginning-Seat5221 13h ago edited 13h ago
AI tends to write more code, use more complex pattern, and add more guards for edge cases. It's sometimes over clever compared to humans that try to keep code simple and readable - but humans vary a lot so some people surely write AI-like code. There's also variance between AI models and prompting can change their output.
2
u/pixel293 13h ago
It could be written by AI, it could be that they ran a code beautifier on it, so the indentation, spacing, and what not was consistent in the the way they like it, it could have been edited with an editor that used tabs instead of spaces or spaces instead of tabs. There is really no way to tell if AI was involved or not.
1
u/betarage 13h ago
They use too many comments and very generic names for functions and text.
1
u/jam_pod_ 13h ago
It's a vibe thing. Overly complex design patterns; lots and lots of highly descriptive comments; putting anything that might change into constants at the top instead of inline; there's no one "tell" but you get to recognize it
1
u/xsrvmy 11h ago
People need to stop accusing people are using AI. The only reliable signs of AI use (other than "watermarks") is when a work has apparently high quality but makes basic errors that cannot be explained by careless error (eg. garbled text on images, a response that answers a question that was not asked, etc.)
1
u/oplukana 10h ago
You have to be very familiar with the common pitfalls of AI, and if the person has an intense harness that really subjugates teh AI's style it gets harder.
If you know a person over a long period of time, and ahve access to their git history, its much easier. people tend to be creatures of habit, they have preferences and styles, and a drastic shift in style is very noticeable.
1
u/Cobweb_Games 9h ago
There's no reliable way to tell just by looking at the code. AI-assisted code can look different in structure or style, but that doesn't prove anything.