40% of the code GitHub Copilot users check-in is AI generated and unmodified
microsoft.com
microsoft.com
Because it seems over the past couple years on HN everybody is making great use of Copilot and constantly talking about it, while honestly scaffolding boilerplate is the least of my problems, while thinking, designing and abstracting novel ideas into code is the hard part where AI would fall short and just waste my time.
I still do not get if I'm behind the times or just experienced enough (I've been programming for two decades) that I don't feel the need to use Copilot. It's a bit disconcerting because I feel I need to get out of pure programming work ASAP as everybody else is competing with me with Copilot and GPT and I am feeling an existential risk to my craft and livelihood.
For example you expect: x[i]
But copilot suggests: x[i+1]
…and you think, and you think, and then one of two things happens. Either you satisfy yourself that the answer is indeed x[i], or you accept x[i+1] and sheepishly thank Copilot for catching a bug today.
You could have copilot on in the background and never accept a suggestion, and it’s still a productivity enhancement.
Also in the situation where it suggests x[i+1] and it's wrong, doesn't that annoy you?
In both cases I'm sure this is just temporary while LLMs get better. But my experience was they were _just_ a little too annoying last time I used them.
yes
However, it introduced a very subtle bug where it used a loop counter `i` where it should have been indexing into an array like `arr[i]`, but it still typechecked and happened not to cause insane errors. Took a lot of time to track down later, and it's a bug I never would have written in myself.
I'm in the same boat but I must admit the temptation is increasing.
It's just another tool. So I guess the good old "will never stop using emacs" kind of attitude applies here too?
Relying on code-completion for coding or relying on google maps for navigation dims your ability to do these things. Given that copilot is a remote service that I do not control, I will not voluntarily tie my ability to write software to it.
Coilot is a conditional, unreliable, untrustworthy, ability-as-a-service. No thank you.
How can you be sure of that?
I know scientists who use ChatGPT to rewrite their text to be clearer. They've also used it to pose novel interesting questions about a situation.
On my side, I've found ChatGPT very helpful to explore/compare which library to use to solve my problem and show examples how that library is used.
It's also been very helpful lining up Haskell types and translating GHC error messages into English. Sure, those are non-creative tasks, but it's surprisingly good at them.
It can’t really reason - it’s just very good at guessing the right answer if there are a lot of examples.
It also lies somewhat frequently.
If we have to double check its output, it kind of defeats the purpose - at least part of it - as the “cognitive burden” is still on us.
P.S. Not sure what you mean by “lining up” Haskell types … but don’t LSPs already give us clear information about the inferred types and do so with nigh zero chance of errors.
Yes of course.
Libraries: I look at the libraries it suggests, see if they have documentation or GitHub activity.
Lining up types: say you have a `List (Maybe a)` and require a `Maybe (List a)`. This is a simple example, of course real life is much more complicated. ChatGPT tells you. Can you trust it? Well did it make the compile error go away?
(Sure, I can think of three ways to turn a `List (Maybe a)` into `Maybe (List a)`. Only one will be what I want, but it's easy to tell whether ChatGPT gave me the one I wanted.)
Although might as well just use Google directly which will send you either to Stack Overflow or Reddit where there are comments discussing the issue with back and forth fleshing it out or to a bunch of tutorial sites where you can source opinions from each site.
edit: nevermind the attempt at your puzzle, my solution doesn't work.
You wouldn’t actually have an intern do this because the delegation takes more time than doing it yourself. With GenerativeAI, it’s snappy.
I don't mean type inference but turning the present type a into the required type b. LSP don't do that.
So don't use it there :) But I'm curious what kind of coding you do that you never have to do any scaffolding, refactoring, or come across any element of repetitiveness.
That is where it shines imo. I find during those boring tasks it quite often just gets my intent, and I can say "yes actually that's exactly what I wanted".
Which allows me to get back to the business of "thinking, designing and abstracting novel ideas" quicker.
Perhaps it's because I've always been a lone wolf engineer, but I'd rather do it myself than giving quite an important task to someone less experienced than me, whether I'm writing something new (where I need to be at my best) or refactoring (where I still need to be sharp to understand why it was done a certain way to know how to improve)
AI would help with extracting code into a function, or writing yet another algorithm implementation, or wiring bog standard libraries (say, cURL), but that's like foreplay and lower effort work I enjoy doing as a break from the hard stuff.
And to clarify my comment about AI being an engineer with less experience than me, I'd rather be paired with an actual junior engineer, so at least I can mentor them and help them grow, than just having a machine do something that in some cases might be utterly inane, so I still have to waste time double checking its work, but totally powerless to teach and improve it.
If I start "enum { North", I will gladly accept the ", East, South, West }" autocomplete from Copilot, and this kind of thing, in aggregate, saves hours of your time.
It sounds like you’ve been at this for a while, are set in your ways, and are trying to justify it. We all get set in our ways, but stop trying to pass this off as something it’s not.
I’d respect using Copilot and deciding that it didn’t provide value, but all this umming and ahhing is not that.
You have almost 20 years of professional experience on your resume and likely were coding before that; it is difficult for me to believe sometimes, but most programmers have nowhere near that level of experience as the field is constantly increasing in size and scope: when I was in college, Computer Science was one small major people could enter that had only momentarily become popular due to the Internet... now it makes up a third of all students at major institutions that I would have assumed should be doing more interesting research work :(.
Regardless, you (and I) look at this AI as an engineer that is much less experienced than we are, and which is mostly able to code in repetitive ways with a ton of boilerplate that it sometimes gets wrong anyway; but, I think, for a remarkable number of people--even ones on this forum, where I often want to assume everyone should be an expert but in fact a lot of people just got into doing this work last week--that AI actually already has more experience than they do (and, now that they are using it so heavily to do their job, maybe ever will) and thereby makes fewer mistakes.
I don't know what that feels like, but it is certainly a very different experience than we are having. Maybe in another year or two, we'll have that experience also: if the AI gets good enough to become your peer, maybe we will find it interesting to use (or maybe we will become so demoralized, having not been in the position of having to work in a team of people better than us for so long--and these AIs wouldn't even be people!!--that we give up on the art entirely). I mean, imagine for a moment what it would be like if you found yourself in awe of the AI and were learning from it... I think it explains a lot of the confusing excitement about this technology.
I recently had a ticket that required refactoring some code that used net::http from Ruby’s stdlib over to using the HTTP gem. The rewrite was pretty easy to do by hand, but we had a bunch of test cases and rewriting them proved to be a bit painful because the mocks required were quite different.
So I spent half an hour rewriting the first test case with the new shape of mocks. Then I commented out the remaining tests and the AI recognized what I was doing and rewrote the remaining test cases with the new mock structure in seconds.
I treat AI like a junior programmer. I don’t trust it to do the hard stuff, but it’s great for scenarios where I have already established the pattern and I just need someone with basic coding proficiency to apply that pattern to a large chunk of code. It’s amazing at doing the grunt work.
If you can’t find your drive to look at new things enough to even see if they’re worth digging more into, which you seemingly haven’t, then I think this speaks poorly of you as a developer.
It is possible to disagree without being rude and insulting.
Personal insults are particularly destructive to civilized discourse.
The actual act of writing code "faster" baffles me. Without tools like intellisense, etc.[0], I am perfectly able to write code as fast as I can type.
There's absolutely zero need for me to write faster.
[0]Intellisense, etc. tend to get in my way, so I turn it off.
You are not alone.
I have not yet grown curious enough about Copilot to try it out; it seems to solve a problem I don't really have, since my productivity is never limited by typing speed. As you say, thinking and designing is the hard part.
I look forward on the future of AI assisted coding tools, it could make us more productive on generating part of codes that we don't care much about, while leaving us time to deal with code that we do, manually.
But no one can read my mind! If I have to get increasingly specific in what I am telling the AI, and have to formulate my writing style in a way that keeps things very precise, I am essentially programming in another language. Albeit one where the output is uncertain and I have to check everything.
It is possible that someday it reads in an entire codebase (say, millions of lines of code), and I can describe a new API I need and it implements the entire thing. This would be quite useful.
You can get this today by switching to being a product manager/owner! Dream up an idea, describe it to a bunch of fuzzy intelligences, go through a few cycles of refinement, and voila: A software.
If there was a metric for how much net new application business logic was written by copilot, that would be far more interesting to study.
So overall I'm honestly pleasantly surprised with it. It feels similar to when I got a car with adaptive cruise control - suddenly I'm not thinking about maintaining the correct speed and following distance on the highway, which makes driving for a while require far less mental effort.
I know I probably could have accomplished something similar by setting up snippets or whatever, but I installed it and it immediately started doing what I wanted without having to ask.
Nifty.
For languages I do not know well however I use it for everything. But I wonder if it keeps me from learning tbh.
The shorter the prediction the higher probability of it being correct.
The longer, and more complex the prediction the less likely it’s all correct. But, with a close review you can spot the errors and correct it.
I’ve found most useful to get ideas on the page fast.
It’s also absolutely insane to be writing a parser, and have it suggest unit tests and code where it clearly has developed an understanding of the language before the parser is complete.
Copilot is great at writing tests.
I don't know anyone who uses it for this; specifically tests are really bad if they're subtly wrong.
Maybe to scaffold the test function, but the actual test if completely useless if you don't trust it.
So like... generate code and have robust tests, or write robust code... but, it's really really daft to generate tests that might hallucinate some random crap (and copilot really does sometimes).
Other people have said this, but copilot is auto complete.
You use it every time you press tab.
Do you accept an auto-complete suggestion 40% of the time? ...mmmm, yes, well, guess why 40% of code is generated by copilot.
It's not because people are generating tests with it.
Being able to churn out the boilerplate for tests, which can make DRY a non-concern, is great. I just hope that if I do this, I never get sloppy, and I always review the tests.
Why not replace it with a function call?
Go, Java I’ve experienced are noisier than others.
And honestly, I was extremely impressed. With a bit of context, it was able to generate almost correct test data for a fairly complex binary data format.
I've also leverage it heavily to:
* generate doxygen comments
* get usage examples of libs I never used
* create a whole bunch of utils functions.
And honestly for all these tedious tasks, it has done a far better job than I would ever had.
Comments were consistent in styling, the base examples were fairly good, and the utils functions were well made, specially the error handling (which I would probably have semi-consciously skipped tbh).
In fairness, I modified most of this code slightly to make it fit my project structure, or tweaked it a bit what the IA didn't quite get it right.
(it never fully understood some offset fields in the file format, but got pretty close to at times. And in fairness my naming for these offset fields was a bit questionable).
Heck, as a test, I even threw at it an RFC-like spec of the file format, and asked him to generate a python parser. The result was not 100% correct, but definitely a good start to iterate on.
In the end, this side project took me 2 weeks to implement with chatgpt probably saving around 1 week of dev. It also greatly helped improving the quality of the project (better doc, better tests).
that would be surprising - it does a fantastic job of producing e.g. dumb unit tests. for instance, Copilot + a Go table testing template means you can churn out the simple "make a request to this url with this data, ensure I get a 200 and the response contains 'id' and not 'error'" extremely quickly. the code is trivial but tedious, so you can quickly inspect for sanity and run to ensure they pass, then commit and have them checking future changes.
> it's really really daft to generate tests that might hallucinate some random crap (and copilot really does sometimes).
variations on this comment are all over these threads, which is bizarre. hallucinating means you waste a few seconds reading the code it produced, not that you commit incorrect code.
this isn't like ChatGPT advising people to drink bleach, Copilot is a dumb tool offering an expert (you) suggested solutions for your expert consideration
The obsession with code generation instead of creating proper abstractions is a scourge of today's programming. It's a regression in software engineering.
Intelligent unit test creation (if it is indeed intelligent) is also a good use-case. Not to relieve the programmer from thinking, but to save typing and to point out potentially useful tests that you might not have thought of.
I don't see where "AI" is required for stuff like this.
The fact that defining the same task in natural language to an AI is easier than writing it in formal language, means the formal language lacks expressiveness [0], vocabulary, or more likely, both.
But if they are both at same level of expressiveness and vocabulary, formal language wins, because it can spot and prevent ambiguity.
The question is how scalable it is to implement such vocabulary into formal language.
[0] - The line is often blury. How many languages allow to straightforwardly express `clamp m between 1.0 and 2.0`? You can argue this is vocabulary, or this is expressiveness.
And I think it would be a great place for AI in programming - automated refactoring. For example, it would see a code that clamps the value and could be replaced with a library function call clamp(m,1,2). (And it would also, presumably, made sure that the code is indeed the same.) So it could help you understand the vocabulary.
Or, if it sees you are doing this frequently, and it's not in the standard library, it would create the function.
But instead, this AI (more like artificial stupidity) will just suggest you the same thing you wrote because you don't know any better in your code base. That's not helping.
Why not? Isn't it easier to learn new syntax than to figure out a correct prompting for AI? (Although actually, Haskell syntax would be something I would prefer to write in.)
this is a bizarre claim to make and just completely ignores reality.
people ARE trying to make better compilers and libraries, and have been for decades. we are we are now after person-millennia of effort, and that still means the optima we're at requires writing some repetitive web template rendering code in JSX or whatever, which Copilot can automate. why didn't some homomorphic-monoid-transformer-auto-renderer win instead?
The auto-renderers did actually win. There were GUI building tools at the end of 90s (like Visual Basic) that still put most web frameworks to shame. But, for various business reasons (mostly pricing, really) they were replaced with "web technology" - something open source but worse.
(And I am not dissing OSS, either. For example, Qt/KDE had some great abstractions that could serve as a basis for building applications. But the urge to reinvent the wheel has won.)
I've used ChatGPT to find libraries and to help me line up types. It was very helpful.
It was a particularly tedious, ugly, and cludgy bit of work that needed doing. Pulling in a data from several very broken sources with horrible naming conventions, patching holes and generally trying to make a sane dataset out of nonsense.
I'm convinced Copilot made the whole process ten times harder than it needed to be. It was constantly pre-empting me with plausible-sounding variable names and merges which led me off down the wrong path a few times.
I flick between having it on and off, and recently I've found I'm much happier with it off. Great for docstrings, boilerplate, and stuff like "recursively traverse this json for [key] and return [value]", but for day to day stuff it's a pain in the arse.
Maybe I should have lowered expectations and thought of it as improved code complete. I got spoiled by copy/pasting from ChatGPT. As it stands now I'd rather pay for a subscription to have the latest ChatGPT than for Copilot.
Maybe it's just me.
B. AI can slightly manipulate existing code according to your prose. But I have also seen it fail hilariously to follow basic instructions. Eg: without `All argument constructor` in - but it still generates the all argument constructor. Another day it writes regex but fails to escape some characters properly.
(are (excessively funny) (serialized (of (parse tree) structures)) though) ;; this limits direct Lisp adoption. Python and JS / TS took its place now.
I’d be more interested to see the other stats..
How much code is AI generated and then modified.
How much modification is typically needed.
How often suggestions are not used/abandoned/deleted.
On the other side you have devs who have AI in their head. They often use tools to optimise their flow. Ive always used resharper as a developer and think autocomplete is certainly a developer efficiency improver. 99% of the suggestions resharper makes, i checkin. Thats why i use it, it has less fuzz because it doesnt try to be everything.
Pressing alt+tab and scrolling through some search results isnt something that adds overhead to my flow - after 30yrs im pretty good filtering content.
I do alot of PoCs though, so if i wanted to write in a language i didnt understand, i think copilot can improve my flow somewhat to get me to serach terms that will benifit me quicker.
Overall im still a few years away from relying on AI to help me code. Its going to be great for retirement though, if i had a family and kids it would allow me to checkout of self-paced learning while still maintaining my edge.
I have been able to write fairly decent programs using chatgpt, am starting learn and build full stack apps etc. I am not able to use copilot. Maybe I do not know the tricks.
That question generated this code: [I did not write anything beyond this point]
Here's an example function that searches for a lead in Salesforce using jsforce and updates an activity record with the duration of the call:
``` exports.handler = async (event, context) => { const jsforce = require('jsforce');
// Create a connection to Salesforce using the access token and instance URL
const conn = new jsforce.Connection({
instanceUrl: event.salesforce.instanceUrl,
accessToken: event.salesforce.token
});
// Search for a lead with the given caller number
const lead = await conn.sobject('Lead').findOne({ Phone: event.activity.caller_number });
if (lead) {
// If a lead is found, update the activity record with the duration of the call
const duration = 10; // Replace with actual duration of the call
await context.ctm.update({
activity: {
id: event.activity.id,
duration: duration
}
});
} else {
console.log('Lead not found');
}
};
```Note that this function assumes that the caller number is stored in the Phone field of the Lead object in Salesforce. You may need to modify the code to match your specific use case. Also, the duration of the call is hardcoded to 10 seconds in this example, but you should replace it with the actual duration of the call.
For more custom stuff, I mostly just ignore the suggestions since they are mostly useless.
> there is no way that stat is true
> I'd say closer to 40%
What?
The first would be very impressive, the last not so much.
1. Security vulnerabilities from unaudited code.
2. Copyright violation risk, since a lot of CoPilot examples show clear excerpts from open source repositories.
Well done Micro$hit.