3 ms·
At the risk of sounding obtuse, then, where is the robust codegen code?
by fapjacks 11y ago
At the risk of sounding obtuse, then, where is the robust codegen code?
- bartonfink 11y agoCompilers, for start.
- fapjacks 11y agoHah! Touche!
- nostrademons 11y agoOn 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.
- kazinator 11y agoNice easter egg: "autoconf & friends" buried in the middle of a paragraph that appears to be about robust code generation.
- nostrademons 11y ago"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.
- deleted 11y ago[deleted]
- teacup50 11y agoIn addition to what peer comments already listed: - Macros and compiler plugins that operate over the language AST. - Tools that generate native bytecode. - Parser generators that don't paste arbitrary user code into the generated code. The consistent theme is: tools that understand language semantics to whatever degree is necessary to perform reliable transformations.
- _asummers 11y agoJava 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.