by gamegoblin · 4y ago · 0 comments
up = foo.north()
right =
and then it will correctly suggest up = foo.north()
right = foo.east()
down = foo.south()
left = foo.west()
This requires a kind of linguistic understanding that is beyond basic intellisense. If you are just wanting it for basic intellisense autocomplete, it's not much better than JetBrains stuff. But for things that require linguistic comprehension, it's incredibly useful.For example, if I have a `Point` object with `x` and `y` fields, and I make a function called `lowest_point`, it knows I want to the point with the minimum `y` value. Because it knows the name `y` is most typically used for vertical direction, and the word `lowest` also implies vertical direction. This is kind of a linguistic/semantic knowledge that is not found in just the type system.
1. The surrounding code
2. The type/intellisense information of all the identifiers in the surrounding code
3. The class/function definition of any identifiers in the surrounding code
I think #3 will be huge. There is a huge difference in Copilot's performance when dealing with types defined right above where you are writing code, and types defined in some far-away module or library. Right now if you use a class you defined in another file or adjacent project, Copilot can't see it. But your IDE has jump-to-definition functionality that could trivially be wired in to something like Copilot.
The team behind Stable Diffusion (the image synthesis model that's been all over HN recently) have said they are working on stuff like Copilot as well, so I expect we will see a huge transformation in this space in the next year or two.
It feels like something that is obvious and should go in the copilot plugin rather than copilot itself.
Given N suggestions, validate the code + snippet on them using normal error checking.
Promote suggestions with no errors.
The intellij plugin, for example, will often suggest 'default' suggestions that are entirely wrong. Given that `foo.bar.foobar()` exists, it'll suggestion `foo.something.SomethingClever()` when those functions don't exist, or exist on types other than foo.
However, if you look at all the suggestions on the side panel, you'll see several of them are actually valid. It's just that the default completion isn't.
It feels like magic because it really does get some things right.
But I find that in most cases, because it's often wrong, you have to deal with wrong suggestions, and be very careful about what you accept.
I feel that for most coding scenarios, it doesn't actually, in most cases, do that much but save a few strokes.
I suggest that if there is 'high boilerplate' - then maybe there's upside.
But for most things, it really doesn't help, despite how in some cases it's really magical.
I turned it off and don't miss it.
What I would however prefer is merely 'much better autocomplete'.
Somewhere between 'ok autocomplete' and 'code suggestions' is the sweet spot for dev. that's not boilerplate.
At a worst it provides a great starting point to jump off from, at best it writes it for me just like I would have (matching style/variable naming/etc).
/*
<http request here>
The well-type class representation of this is:
*/
And then it spits out a totally sane and reasonable class. In this file I already have 10+ classes already defined and manually touched up by me to rename some things, remove some fields, etc. So every time I add a new one, Copilot takes into account the previous examples and each addition requires less or no manual tweaking.It's not like it's a ton of work to do that myself but normally the way I would accomplish it is to copy an existing function, change the return type, change the url, change the Vuex store it puts the data into but with CoPilot it handles that perfectly for me the vast majority of the time. And if I'm doing CRUD endpoint I don't even have to write the other function names, it will autocomplete the "RUD" part after I write the "C" (and by write I mean I put `createItem(payload: ICreateItemDTO)` or similar and it writes the body of the first function as well).
For me it's the perfect blend of "generated code" and "human tending" to get exactly what I need without having to do the repetitive/boring parts. It's been a joy to work with.
Unless, as in many systems, y=0 is the top and y increases downward.
For example, I just gave Copilot:
# The screen is inverted, so bigger y values are lower
def lowest_point(points):
and it completed: # The screen is inverted, so bigger y values are lower
def lowest_point(points):
lowest = points[0]
for point in points:
if point.y > lowest.y:
lowest = point
return lowest
Even if you write some code that implies that bigger y is lower, Copilot will pick up on it.Naturally, this makes it easier for other programmers to understand the code.
Are you sure? If you would look at the statistics what comes after
up = foo.north()
right =
I bet most of the time it's up = foo.north()
right = foo.east()
down = foo.south()
left = foo.west()But it does a really good job, and it's not just matching code it's seen before. You can use any variable name. You can do this in a weird programming language which uses weird symbols for assignment and calls. copilot will probably see though it and give you a good prediction.
You can probably even swap west for not_east in code elsewhere in the file, and it will manage to predict that you also want not_east here. And I guaranteed nobody has written code like that before.
hn_example_up = foo.north_garbage_jlakd()
hn_example_right =
it correctly spits out hn_example_up = foo.north_garbage_jlakd()
hn_example_right = foo.east_garbage_jlakd()
hn_example_down = foo.south_garbage_jlakd()
hn_example_left = foo.west_garbage_jlakd()
Even though those identifiers including random letters are certainly not in the training data. It can do surprisingly good basic reasoning.Here is another example. I give it:
hn_example_up = foo.x_0_y_1()
hn_example_left = foo.x_neg_1_y_0()
So my function names are like referring to unit distances on the x/y axes. Copilot correctly figures out what I'm doing and completes: hn_example_up = foo.x_0_y_1()
hn_example_left = foo.x_neg_1_y_0()
hn_example_down = foo.x_0_y_neg_1()
hn_example_right = foo.x_1_y_0()
A few weeks ago I coded a rubik's cube solver that involved some very nuanced and weird spatial reasoning and was blown away by Copilot's ability demonstrate it "understood" concepts such as turning the right side down is identical to turning the left side up when viewed from the back of the cube, or stuff like that. up = foo.north()
right = foo.east()
down = foo.south()
And you won't notice?As with everything I always do visual sanity checks.
Personally, I don't even rely on normal autocomplete very much when I code because I feel like if I don't know what I'm trying to call, then I don't know the language or library well enough, and it's best to go look at the documentation.