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

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.




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

Search: