Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How does it do if I need to change one small thing in every copy of the code I generated?

(Edit: This is a serious question; I recently semi-seriously commented that maybe solutions like Copilot are particularly well suited to solve this problem with Go, so I'm curious how well it works in practice.)



I think we're talking about different kinds of code generation.

I'm mostly talking about boilerplate like writing `if err != nil` with a nice wrapping message every other line. Copilot will just write 2-3 lines at a time. That's imo the kind of boilerplate that might often be annoying to write.

I'm not talking about generating multiple copies of the same function nor anything like that. That would be better suited to deterministic generation or copy+paste. Copilot doesn't help you here.


Ok that makes sense. You don't need something as powerful as Copilot for that kind of boilerplate though, there have been "snippets" / macro things for that for forever.

My bigger annoyance is when I want to write non-trivial functionality that works for different data types.


> You don't need something as powerful as Copilot for that kind of boilerplate though, there have been "snippets" / macro things for that for forever.

I'm not aware of anything else that writes good wrapping error messages automatically though.

Your use-case is precisely what you'd be using generics / standard codegen for.


Interesting, it's the error messages themselves that it's good for, rather than the boilerplate; I assumed you just meant the boilerplate around the error message. That kind of surprises me, but I guess I shouldn't be shocked that people are handling the same errors with the same messages over and over again without any way to encapsulate the pattern. Not shocked I guess, but that is disappointing.


That's the point, it's not the same messages.

Each error wrap has a situation-dependent wrapping message, different for each wrapped error in the function.

Copilot is great at writing the whole `if err != nil`, including context-specific wrapping messages. It's also great at writing your code in many other situations where the intent is clear and simple, but it just takes a few lines to write in Go.

I'm not sure if you've ever used Copilot yourself, but it's basically autocomplete on steroids.


Yes, the point I was trying to make is that it works because the error messages are formulaic. In which case I think it's too bad the whole pattern can't be abstracted.


It should always be regenerated as a compilation target, never maintained by developers made of meat.


What should? Are we talking about the same thing? My understanding of the Copilot workflow is that you use it as a programmer to "write" code by accepting suggestions and then checking the suggested code in as if you had written it the normal way.


I mean when a language requires as much repetitive boilerplate as this one, replacing the suggestion with some kind of markup to generate it will pay off almost immediately.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: