30 points · by mathematically · 5y ago · 54 comments
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?
Edit: At least for me it isn't obvious at all that those snippets are correct.
Brilliantly articulated - thank you. I wonder if this is a generic pattern (like fallacies)?
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.
Whose code did it copy and how is that code licensed?
And this is before GitHub will start charging for it.
But from a QA perspective close isn't enough.
# Writing a good docstring
This is an example of writing a really good docstring that follows a best practice for the given language. Attention is paid to detailing things like
* parameter and return types (if applicable)
* any errors that might be raised or returned, depending on the language
I received the following code:
```{{{language}}}
{{{snippet}}}
```
The code with a really good docstring added is below:
```{{{language}}}
If you wanted a docstring in a particular format, you could add some specific examples as context to your prompt to get even better results.What would be an immense multiplier of software eng productivity is an intelligent auto-fixer tool: a compiler gives you an error, you know how to fix it, but it's a tedious work that wastes most of your time. Think of fixing build deps, rewriting method signatures to match the parent class, properly adding a library to your project. You'd write "include ssl.h; encrypt(message)" and the tool would add all the plumbing around it, in line with project guidelines.
Analyzing, debugging, and fixing code is what we do all day.
It reminds me of people strongly against autocomplete for variable/function names.
What you're mentioning will happen, some developers will use the tool the right way. I just don't think that will be the prevailing pattern.
When the AI/ML programs can actually create lines of code without references and do it with quality that’s when there’s a real story that isn’t playing tricks on tech authors for stock gains.
Tricks like this are why everyone always thinks big innovation is 5 years away when no one is really working on the things that’s make it 5 years away.
AI isn't magic, it can't solve problems you don't give it. When doing alpha go they gave the AI all the rules for GO and told it to optimize for those rules. That works fine. But if you want it to make a web-app, what rules would you give it to optimise for? Do you have a web-app evaluator lying around somewhere we can use? If not I don't see it happening.
The current code helper solved that by telling the AI to solve the problem "write code that looks like this bunch of human written code". The AI can do that just fine, but code that looks like human written code isn't terribly useful since the AI doesn't understand what makes the code good, all it knows is that the code looks similar to what a human once wrote. This is cool, but as you can see this is very different from the real deal where the AI solves the real coding problem rather than "write something that looks like code" problem.
Basically, you write a test, let the algorithm find the program that passes it. Hopefully, at one point you reach GPT-3 level performances where it is able to imagine programs for tests it never saw.
I'm terrified of the day when the answer to that is, "a better AI".
AI currently does not understand language well enough, it recognises patterns but does not understand what its doing and why.
this will reduce the amount of "possibilities" w.r.t. code by orders of magnitude and therefore make it easier to both read, write, and development tools to automate code.
of course this will necessarily reduce innovation, but at the expense of higher quality code, easier to maintain code and skills that are more transferrable.
It's also decent at doing tasks that would be easy for a beginner programmer but perhaps tedious. Like you can give it a function for generating random colors and a task like "expand the variable names in this function to be better", and it will change variable names like `r`, `g` and `b` to `red`, `green` and `blue`. Hardly amazing, and the latency of the API means it's not actually that useful in practice (yet), but with the right prompt it can do some impressive things, and I expect it to get much better in the near future. Pulling magic strings out of functions into constants and adding typehints to Python functions are other simple tasks I've found it OK for.
Programming is ironically one of the worst use cases of AI, because often predictable failure is better than unexpected success.
"Fix the null pointer exception" is less expensive (time, money and mental energy) than "figure out why the code spits out garbage even though the test cases pass".
https://www.damninteresting.com/on-the-origin-of-circuits/
> Dr. Thompson peered inside his perfect offspring to gain insight into its methods, but what he found inside was baffling. The plucky chip was utilizing only thirty-seven of its one hundred logic gates, and most of them were arranged in a curious collection of feedback loops. Five individual logic cells were functionally disconnected from the rest — with no pathways that would allow them to influence the output — yet when the researcher disabled any one of them the chip lost its ability to discriminate the tones. Furthermore, the final program did not work reliably when it was loaded onto other FPGAs of the same type.