News for hackers. Stuff that matters.
Re:I love coding in C by 1996 on Thursday December 26, 2019 @09:54AM (#21884181)
Funny I do that in perl, and some people freak out about having code in an unfashionable language generating code in another language.

It's just equivalent to a preprocessor.

Re:I love coding in C by lizmat on Monday January 06, 2020 @02:27PM (#21972230)
In the mid-90's, before mod_perl, I used to generate PHP in minutely cron job using a Perl script from a constantly changing database. That came close to the best of both worlds at the time: the flexibility of Perl, fed from a database, and no CGI overhead when serving.
Re:I love coding in C by saagarjha on Thursday December 26, 2019 @11:06AM (#21884696)
Code generation usually doesn’t get you any support from standard tooling. My autocomplete can see through macros, but it has no idea what C is if I was working with Perl.
Re:I love coding in C by marcosdumay on Thursday December 26, 2019 @10:38AM (#21884494)
Code generation usually sucks.

A small one-off run under your control is an exception. But people learn to fear the thing, and apply that fear everywhere.

Re:I love coding in C by vageli on Thursday December 26, 2019 @11:20AM (#21884809)
> Code generation usually sucks.

> A small one-off run under your control is an exception. But people learn to fear the thing, and apply that fear everywhere.

Why does it usually suck? Writing code that writes code seems like an optimization that would bolster productivity.

Re:I love coding in C by marcosdumay on Thursday December 26, 2019 @06:58PM (#21887914)
> Why does it usually suck?

One large factor is that when somebody really dislike the result of a code generator, they most commonly cope by editing the generated code by hand. With other metaprogramming techniques people can't do the same, so they fix the issues.

The end result is that code generators are usually a set of mostly-functioning tools that create bad code that is almost, but not exactly impossible to understand but that you will be required to change at some point.

Re:I love coding in C by karatinversion on Thursday December 26, 2019 @02:13PM (#21885950)
Most of the code generation code I’ve seen is itself opaque and generates opaque code. This makes refactoring, extending and bug fixing hard.