Live data from Hacker News

Study finds AI assistants help developers produce code likely to be buggy

theregister.com

101–110 of 153 posts

Re: Study finds AI assistants help developers produce code likely to be buggy

#101
I teach Python and Data Science for a living. I just ran through my fundamentals of Python course project with ChatGPT this morning. I was able to create a modern Python project layout, unit tests, documentation, comments, types, and a command line interface by copying and pasting code.

And the code was decent. It did have some problems coming up with the correct assertions for some of the unit tests.

For folks with an understanding of coding, this will be a huge boon to productivity and quality. However, this is not a tool that newbies (currently) will be able to use without any understanding of code.

I view it like a very powerful spell checker or grammar checker for a word processor right now. You need to have a direction you want to go, and if so this will get you there much faster with a better end product.

Re: Study finds AI assistants help developers produce code likely to be buggy

#102
post #21

Surprising. If only there were a way that we could have foreseen that an AI trained to write code in part by looking at people who, self-admittedly, don’t know how to write code, and people who write code for others with minimal context (Stack Overflow), would produce buggy code. It is a case of GIGO. Most developers do not learn much from Stack Overflow. Why do we expect AI to fare better? In my experience, one in t…

AI can learn to do code review, there is plenty of data on Github. It could also write tests and suggest possible bugs on its own. Overall, using it might be better than doing it by hand.

If you are using the AI just to write snippets of code, then it is suboptimal. What it needs is to monitor execution errors and fix its code over a few iterations, just like humans do.

Re: Study finds AI assistants help developers produce code likely to be buggy

#103
Something interesting that I don't see in the comments here are comments Dijkstra has made about using natural language for telling machines to do things[0]

> Instead of regarding the obligation to use formal symbols as a burden, we should regard the convenience of using them as a privilege: thanks to them, school children can learn to do what in earlier days only genius could achieve. (This was evidently not understood by the author that wrote —in 1977— in the preface of a technical report that "even the standard symbols used for logical connectives have been avoided for the sake of clarity". The occurrence of that sentence suggests that the author's misunderstanding is not confined to him alone.) When all is said and told, the "naturalness" with which we use our native tongues boils down to the ease with which we can use them for making statements the nonsense of which is not obvious.

I wonder what the long term consequences of LLMs will be. I can't see them abstracting away programming languages for the reasons that Dijkstra provides (namely the inherent ambiguity of natural language), but maybe they could be a good summarizer of APIs and generator for starter code.

My prediction is that they'll provide a similar utility to stackoverflow and save time in developing software

[0] https://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/E...

Re: Study finds AI assistants help developers produce code likely to be buggy

#104
post #72

Earlier quoted context omitted.

If I had a little robot riding in the passenger seat that could tell me whether to go left, straight, or right, and it was correct 90% of the time, I'd think that was pretty great. I'd get where I needed to be, even with a couple mishaps. ML code suggestions are the same thing to me. If I don't know where I am going, I can just ask it for suggestions. And it's probably going to be what I want. In both cases, I am ann…

The problem with ML is that it's pattern recognition, it's an approximation. Code is absolute, it's logic that is interpreted very literally and very exactly. This is what makes it so dangerous for coding; it creates code that's convincing to humans but with deviations that allow for all sorts of bugs. And the worst part is, since you didn't write the code, you may not have the skills (or time) to figure out if those…

Expand your view. AI can write tests, read error messages, find bugs in your code, we just need to give this task.

Let's think about tests. You write a function, the AI writes a few tests for you. maybe you need to add a few more. But it's better to have tests, and you might have missed one of them.

Error messages - we rely on error messages to make this leap from "code parrots" to "bug free". Most of our codes fail the first time we run them. We're just fancy pattern matchers too, but we have a runtime. So the AI could also fix its bugs all alone, given the opportunity.

Finding bugs - we can train AI to spot bugs. It can become an excellent tool to check not just AI code, but also human code. Having a bug detector running in the background would be great, even if is not perfect.

Re: Study finds AI assistants help developers produce code likely to be buggy

#105
post #83
post #21

Surprising. If only there were a way that we could have foreseen that an AI trained to write code in part by looking at people who, self-admittedly, don’t know how to write code, and people who write code for others with minimal context (Stack Overflow), would produce buggy code. It is a case of GIGO. Most developers do not learn much from Stack Overflow. Why do we expect AI to fare better? In my experience, one in t…

> If only there were a way that we could have foreseen that an AI trained to write code in part by looking at people who, self-admittedly, don’t know how to write code, and people who write code for others with minimal context (Stack Overflow), would produce buggy code. It is a case of GIGO. So, I'll claim the real issue is just that this generation of AI isn't able to "learn", it merely "trains": if I were alone in…

> With a human, garbage in can lead to something fully legitimate out!

Because we get to see the error messages, fix and try again. You can try this on chatGPT - give it a task, run the code, probably fails, copy the error back, and let it fix is errors. After a few rounds it gets the result with much higher probability than when you allow it one single shot.

A language model can write programs, and then we can run the programs to check if they pass tests, then the language model has a special signal - execution feedback. If you retrain the model with this new data, it will learn to code better and better. It is reinforcement learning, not language modelling.

AlphaGo was able to generate its own data and beat humans at Go by doing this exact thing. It's an evolutionary method as well, because you are cultivating populations of problems and solutions through generate + execute + validate.

Re: Study finds AI assistants help developers produce code likely to be buggy

#106

Looking at the demographics of the study, they only had 47 total participants, 15% of which were professionals and 62% reporting less than 5 years experience coding (which I would imagine is an underestimate assuming some people exaggerated their actual experience level). So that means they only had 6-7 participants who worked in industry and generously 18 people with more than 5 years experience. They also don’t rep…

My concern is that students/novices are going to be using this, without the ability to double-check the output of the tool. It inspires overconfidence, looks okay at the surface level, and bugs go unnoticed. The younger generation using this as a crutch, treating their own creations as a black box, will not have an adequate feedback mechanism to learn from their mistakes. Code quality and performance will deteriorate over time. You, an expert, learned without this crutch. Your use-case is frankly uninteresting.

Amusingly, without careful curation, I'd predict that buggy code will tend to self-replicate and these tools that indiscriminately slurp public code will enter a death spiral because the novices outnumber the experts. It's only a matter of time before viruses are written to propagate through this garbage stream. http://www.underhanded-c.org/

Re: Study finds AI assistants help developers produce code likely to be buggy

#107
post #74

The anti-singularity, where an AI produces decreasingly correct versions of itself.

The next AIs will be trained on vast swathes of low-quality AI-generated outputs, if they are trained on public data again. Presumably people will have to come up with ways to work around that or the AI will be training to produce outputs like a low quality AI. By low quality I just mean the state of the outputs today, which are incredible for what they are, but are definitely not the pinnacle of what is in theory po…

You let the AI execute code, then it can learn. For now it is well read but lacks experience.

Re: Study finds AI assistants help developers produce code likely to be buggy

#108
post #87
post #82

Earlier quoted context omitted.

Anybody that uses these ai assistants know that the human is still by far the main architect and driver of the code base. Increasingly advanced AI just means more back/forth between coder and AI, both increasing each other's velocity. AI won't just be trained on other AI-generated code, but more like "cyborg" code. Code that was made by both AI and human together. Code that the human probably wouldn't have been able…

How will they be able to keep purely AI-generated outputs from being fed back in as inputs? That seems hard to separate out once it’s published and not attributed. The ability of AI to generate lots of output means it might swamp human or cyborg outputs when looking at the corpus of publicly searchable code (or blog posts, or whatever the training data is for the case in question). Maybe a GAN to detect and filter ou…

Execute the code to see if it passes the tests. Then you can use it with confidence. Lots of human code is crap too, it needs to be removed. You can use GPT-3 to administer tests and read the results.

Re: Study finds AI assistants help developers produce code likely to be buggy

#110
This is a really nice study! It is very cool that they were able to get professional programmers to participate, this is something that is really hard to set up as an academic team. And yes, 47 participants is a small number, but apparently sufficient in this case to detect the effect (as evidenced by the p-values). It also lines up nicely with work we did last year, which looked at the security of Copilot's completions without any humans in the loop [1] and found that something like 40% of its completions in security sensitive scenarios were vulnerable.

One thing I'm not sure of is how well the setup reflects how people actually use IDE-integrated tools like Copilot. In the experiment, users had to explicitly ask the assistant for answers rather than getting them as inline completions (see Figure 7(b) in the appendix). I don't know if this would change the results; I could see it going either way (inline completions appear automatically so might be accepted automatically, but on the other hand programmers are also used to inline completions being incorrect and might be more likely to reject or repair them). It also means that it was up to the individual user to figure out how to prompt the AI, so the results will depend a lot on how users chose to phrase their prompt and how much context they provided.

As full disclosure, I'm one of the authors on a very similar study [2] that didn't find any large effects on security :) The main differences were:

- We only looked at C, rather than multiple languages. C is notoriously hard to write secure code in, so the base rate of vulnerabilities is likely to be higher. It's worth noting that the Stanford study also didn't find a statistically significant difference in security for C.

- Our study environment was designed to mimic Copilot much more closely – so we had participants use VSCode with a plugin providing inline completions from OpenAI's Codex API. This is also why we used the Cushman rather than the DaVinci model: Cushman's latency is much lower, which is important for realtime use; it looks like GitHub made the same decision, since reverse engineering of the Copilot plugin indicates it also uses Cushman [3].

- We had participants try to code up a full library with 11 different functions, rather than doing a bunch of smaller independent tasks. This means that the AI model had more context to work with, and may have affected how users approached the problem.

- We unfortunately only managed to get undergraduate and graduate students as participants, so the base and experience skill level of our user population may have been lower.

Overall I think it's clear that these models are prone to spitting out insecure code right now, and this is an important problem to fix (and one we're working on)! But it's still not clear to me what effect this actually has on the security of code written by programmers using tools like Copilot, and more research is needed to figure that out.

[1] https://arxiv.org/abs/2108.09293

[2] https://arxiv.org/abs/2208.09727

[3] https://thakkarparth007.github.io/copilot-explorer/posts/cop...

Post reply on HN