r/learnprogramming • u/Maleficent-Ladder184 • 43m 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
2
Upvotes
•
u/lfdfq 35m 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.
•
u/Beginning-Seat5221 32m ago edited 4m 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.
•
u/betarage 23m ago
They use too many comments and very generic names for functions and text.
•
u/pixel293 16m 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.