3 ms·
One thing I am confused about is using ai for boiler plate code . Shouldn’t that be a macro or code generated, or even an aspect ? Having large snippets of ai g
by pylua 3y ago
One thing I am confused about is using ai for boiler plate code . Shouldn’t that be a macro or code generated, or even an aspect ? Having large snippets of ai generated code outside of a macro or code generation tool does not make any sense .
- james-revisoai 3y agoIts helpful to do boilerplate in languages or legacy code you touch less often, e.g. React class components. But also, it can reasonably set types for the inputs of say a React component, just based on an example (made up) usage of some props you give it. And you can even, if you are very uncouth, simply generate the sensible props for a certain kind of object given a description by say the user. It can do things like generate controlled form state management etc, which was quite error-prone to do with macros when things get complicated. It can summarize commits for documented code accurately too, especially if you comment what you've done for some reason or another. This saves a good 2-3 minutes an hour I didn't know I could save, for the average of say 1-2 commits I'd do usually per hour. Notably GPT-4 is needed to do these consistently well.
- jwestbury 3y agoI mentioned this elsewhere yesterday, but I've used it to do things like stub out an API -- I tell it what I'm making, what endpoints I think I need, and ask if there's anything obvious I'm missing. Sometimes it gives me some ideas for additional endpoints. Then it implements stubs for every endpoints and all the associated code and I'm ready to start adding actual logic. There are sometimes tools available for this, but the nice thing about ChatGPT is that it's effectively a single tool that can be used for any reasonably well-known API framework in any language.
- pylua 3y agoStubbing out endpoints is not usually a task that takes a long time and usually the code is auto generated from a mechanism like openapi. I could see it generating out an openapi file but there are already so many templates out there to start from it does not make sense to use ai for this, in my opinion.
- andersa 3y agoSometimes you have some boilerplate-ish code with complicated but repeating patterns, but it's only like 3 or 4 sections, so figuring out how to combine it isn't really worth the effort compared to spending 10 seconds for copilot to write the other 3 instances and checking the result. Another example could be that you would really like to use macros/templates for something, but you can't due to external requirements, like Unreal Header Tool being unable to parse those if you want to export your classes to the engine. So you get to write the same code multiple times for different types. Amazing!
- brtkdotse 3y agoYou still have to write the code for the macro. With ChatGPT you can just say “write a mapper between these two object in C# 11, make the target members uppercase and skip X, Y and Z”
- pylua 3y agoAt least in java there are open source libraries that do this that are pretty standard. For instance, Mapstruct. It, for the most part is already automagic. Doing it for a mapping feels like a deficiency in the code unless chatgpt is putting thoughts behind the variable names and reasoning about what mapping makes the most sense.
- joshuanapoli 3y agoProbably yes… but making and maintaining good templates is hard. It doesn’t get done because probably the person who needs to make the template is different than the user of it. So the AI gets the benefit of having a template without the trouble of getting someone to make and maintain each one.
- pylua 3y agoHaving a bunch of different one off templates sounds like much more of a maintenance problem over a long enough period. Would be better to ask ai to generate the templating library.