Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

12
  • 15
    A term associated with the generation of code is metaprogramming Commented Dec 1, 2017 at 15:23
  • 5
    en.wikipedia.org/wiki/Code_as_data , Lisp, FP, scripting, metaprogramming, Von Neumann/modified Harvard architecture etc. It's been covered ad nauseam. tl;dr the distinction "source code" vs "output code", "code" vs "data" etc. are meant to simplify things. They should never be dogmatic. Commented Dec 1, 2017 at 16:44
  • 14
    @Utku, the better reasons to do code generation often relate to wanting to provide a higher-level description than your current language can express. Whether the compiler can or can't create efficient code doesn't really have anything to do with it. Consider parser generators -- a lexer generated by flex or a parser generated by bison will almost certainly be more predictable, more correct, and often faster to execute than equivalents hand-written in C; and built from far less code (thus also being less work to maintain). Commented Dec 2, 2017 at 1:04
  • 1
    ...whether your high-level language is transformed into a low-level language and then into an IL in your compiler and then from there into assembler and from there to machine language, or goes via pretty much the same pipeline but without the lower-level language (HLL -> IL -> assembly -> opcodes)... why is this a difference that even matters to you? You still have the same end result of high-level-language going in -> machine code coming out. Commented Dec 2, 2017 at 1:11
  • 1
    Maybe you come from a language which doesn't have many functional elements, but in many languages functions are first class -- you can pass them around, so in those types of languages code is data, and you can treat it just like that. Commented Dec 3, 2017 at 9:04