4 ms·
Lots of people grumping about Copilot, has anyone actually used it? For a personal project writing a transpiler from an old language (LambdaMOO) to JS, I've act
by ctoth 5y ago
Lots of people grumping about Copilot, has anyone actually used it?
For a personal project writing a transpiler from an old language (LambdaMOO) to JS, I've actually found it quite helpful. I can write code like:
convertList(node: MooASTNode): List {
And then it just spits out:
const entries: ASTNode[] = node.children.map((child) => {
return this.convertNode(child);
});
return new List(entries, this.sourceLocation(node));
}
This isn't exactly difficult to write or reason about, but it did save me quite a bit of time to just dash out the code that converts the parse tree to an intermediate tree in an hour or so and then just quickly look over and make a couple corrections.
It also helped making the ASTNodes, for instance:
export class If extends ASTNode {
resulted in:
constructor(
public condition: Compare,
public then: ASTNode,
public elseDo?: ASTNode,
public override loc: SourceLocation | null = null
) {
super();
condition.parent = this;
then.parent = this;
if (elseDo) {
elseDo.parent = this;
}
}
@logCall
toEstree() {
return builders.ifStatement(
this.condition.toEstree(),
this.then.toEstree(),
this.elseDo?.toEstree()
);
}
}
Again, this code is not gonna win any prizes, but it sure did save me a good chunk of time.
Why so much hate for the tool?
- Jensson 5y agoIt is usually more work to verify that code is correct than to write correct code in the first place. Edit: At least for me it isn't obvious at all that those snippets are correct.
- ctoth 5y agoThis is an abstract response to a concrete demonstration of usefulness. Of course, if I'm writing crypto code or something where I don't understand the domain well, relying on Copilot would be foolish. But for a well-defined problem like the one I faced, juggling tree representations and a little recursion, being able to specify what I wanted and have the machine generate the code was actively useful and did actively save time. Also, don't you read your code once you write it in the first place? IF you've written it, you know what you meant, and are more likely to read something you didn't even write there, whereas if you're checking over the shoulder of your computerized coworker who has no ego to get hurt, you can be as critical as you need to.
- Jensson 5y agoIt is fine if you like it and it helps you. I am just telling you my opinion. To me that doesn't look helpful.
- fghfghfghfghfgh 5y ago> This is an abstract response to a concrete demonstration of usefulness. Brilliantly articulated - thank you. I wonder if this is a generic pattern (like fallacies)?
- dr_zoidberg 5y agoIn my case, the act of writing the code is still a moment in which I'm thinking and analyizing my code, and I might notice if there's some error in my train of thought. Obviously that is how _I_ type code, and not something that can generalize to how others work. So it's my preference to still think about my code before, and while, I write it.
- deleted 5y ago[deleted]
- klyrs 5y ago> Why so much hate for the tool? Whose code did it copy and how is that code licensed?
- ctoth 5y agoSince Codex sends your own surrounding code as context, I'm assuming, though have no way to check, that it picked up on the patterns from the other ASTNode classes. I somehow doubt someone wrote the precise same @logCall decorator and attached it to their toEstree methods on their own ASTNodes. This is one of the things I find valuable, you can give it lots of help just by deciding where you do the generation from, what code is in the context window. Also, if we're gonna start saying that simple conceptual things like AST processing are licensed, this is a scary world where very little new code will get written.
- klyrs 5y agoThe fact that you can't know where the suggestion came from is problematic. That github added q_rsqrt to the profanity filter shows that they're papering over the issue without actually addressing the problem that copilot can quote code verbatim without letting you know where it's from.