News for hackers. Stuff that matters.
Re:Writing code that writes code – Hack Codegen by fizx on Thursday August 20, 2015 @06:33PM (#10095028)
There's sort of a survivorship bias in play here, where you only noticed the brittle codegen being brittle.
Re:Writing code that writes code – Hack Codegen by Ologn on Thursday August 20, 2015 @07:02PM (#10095122)
Also, codegen exists on a solution continuum. Codegen is a superior solution to manually pumping out lots of boilerplate code with slight variations.

A solution that does not need lots of boilerplate code would be even better, but codegen is still better than the makeshift code that it originally replaced.

Re:Writing code that writes code – Hack Codegen by ArkyBeagle on Thursday August 20, 2015 @11:08PM (#10095790)
There's an intermediate approach - use a generator to spew out tables of data that an engine-type thing uses to adapt to boilerplate style variations.

This is totally a 'C' hacker's approach but it's not bad for some things - especially serialization and the like. But it will need some generic reference mechanism - as void * is used in 'C' - to work.

Re:Writing code that writes code – Hack Codegen by fapjacks on Thursday August 20, 2015 @06:55PM (#10095098)
At the risk of sounding obtuse, then, where is the robust codegen code?
Re:Writing code that writes code – Hack Codegen by nostrademons on Thursday August 20, 2015 @07:12PM (#10095164)
On a continuum from "so robust you don't even consider it codegen" to "well, some people use it": microcode, compilers, virtualization, visual interface builders like XCode and Android Studio, dynamic HTML pages, ORMs, protobufs & other schema definition languages, autoconf & friends, compile-to-C languages like early versions of C++ and Go, ES6 transpilers like Traceur and Babel, compile-to-JS languages like CoffeeScript. Probably others I've forgotten or don't know about.

When it works, you forget that the only thing that computers understand is their native instruction set, and everything on top of that is built on some form of codegen. When it doesn't, you curse out the programmer who left you a pile of buggy scripts to maintain.

Re:Writing code that writes code – Hack Codegen by kazinator on Thursday August 20, 2015 @08:49PM (#10095423)
Nice easter egg: "autoconf & friends" buried in the middle of a paragraph that appears to be about robust code generation.
Re:Writing code that writes code – Hack Codegen by nostrademons on Thursday August 20, 2015 @08:57PM (#10095437)
"Well, some people use it." Particularly toward the end of the list, there'll be more and more examples where people hate the code generation aspect (for example, I've personally had bad experiences with any JS technology that requires a build step). That doesn't change the fact that they're widely used; autoconf, for example, was mandated for all Google-owned open-source C/C++ libraries, because despite its kludginess, it will build on virtually everything.
Re:Writing code that writes code – Hack Codegen by _asummers on Thursday August 20, 2015 @08:48PM (#10095418)
Java annotations have been used pretty successfully for several versions. Not all of them are code generating, but many (from e.g. Spring, or something smaller like Retrofit) generate tons of code for you.
Re:Writing code that writes code – Hack Codegen by bartonfink on Thursday August 20, 2015 @07:05PM (#10095144)
Compilers, for start.
Re:Writing code that writes code – Hack Codegen by fapjacks on Saturday August 22, 2015 @08:13PM (#10104286)
Hah! Touche!