News for hackers. Stuff that matters.
Re:GitHub Copilot Generated Insecure Code in 40% of Circumst... by fendy3002 on Friday September 03, 2021 @08:25AM (#28403218)
Not without trade-off though, I've been on both spectrum. Template generated code allows you to modify things if you know how, while generation on the flies will need a bunch of options, hooks, and worse string-based evaluation call to make it modifiable.

So it's better for code with little to no modification, while boilerplate / template are better for things that will be modified.

Re:GitHub Copilot Generated Insecure Code in 40% of Circumst... by marcosdumay on Friday September 03, 2021 @11:15AM (#28405305)
> Template generated code allows you to modify things if you know how

That's exactly the problem. and because templates allow you to modify the code, the template creators do no work on generalizing it so it covers all the use cases. So, on practice, templates usually require that you modify it.

And now you have a huge codebase, mostly with the default text, but with some changes at random, and one of those changes is breaking it. Good luck finding it.

Re:GitHub Copilot Generated Insecure Code in 40% of Circumst... by lmilcin on Friday September 03, 2021 @08:35AM (#28403300)
Or you can use Lisp, call your boilerplate generator a macro and get rid of any boilerplate and never again have any problems with modifying any duplicate pieces of code.

Sigh... every time I see people generating any code (say through external tool or through IDE) I am always thinking how this could be a simple macro in any Lisp language.

Re:GitHub Copilot Generated Insecure Code in 40% of Circumst... by andix on Friday September 03, 2021 @08:48AM (#28403427)
Templates are a fancy way of copy&paste programming.

So if you need a lot of template code, then your design or your framework is not well suited for the task.

In software development the goal is usually to move commonly used functions or patterns into a library or a framework, instead of copy&pasting them with slight modifications.