r/learnprogramming • • 18m 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

2 comments sorted by

•

u/lfdfq 11m 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 8m 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 - 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.