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?