Questions tagged [code-generation]
The code-generation tag has no summary.
66 questions
138
votes
27
answers
33k
views
Is source code generation an anti-pattern?
If something can be generated, then that thing is data, not code.
Given that, isn't this whole idea of source code generation a misunderstanding? That is, if there is a code generator for something, ...
112
votes
22
answers
134k
views
Automatic programming: write code that writes code [closed]
After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code".
I tried searching over the net for some more explanations or articles ...
51
votes
5
answers
15k
views
Do I check generated code in to source control or not? [duplicate]
I'm developing a .Net application that uses google protocol buffers. Historically the application used the approach, advocated by the protobuf-net team, of decorating the classes with attributes ...
33
votes
6
answers
10k
views
Why do programs use call stacks, if nested function calls can be inlined?
Why not have the compiler take a program like this:
function a(b) { return b^2 };
function c(b) { return a(b) + 5 };
and convert it into a program like this:
function c(b) { return b^2 + 5 };
...
23
votes
8
answers
6k
views
Detect manual changes to an autogenerated C header [closed]
I have a C header that is generated from a CSV file and a Python script. The C header mainly contains a list of #define constants.
I want to be able to detect manual changes to this header during ...
22
votes
4
answers
71k
views
How do we go from assembly to machine code(code generation)
Is there an easy way to visualize the step between assembling code to machine code?
For example if you open about a binary file in notepad you see a textually formatted representation of machine code....
13
votes
4
answers
4k
views
Automatic code generators [closed]
One of my colleagues likes to use automatic code generators, which create large amounts of code that is poorly documented and very hard to maintain.
Is the cost of using a code generator worth the ...
13
votes
6
answers
20k
views
Automatic source code generation -- good idea or potential nightmare? [duplicate]
In response to my question regarding Java source code generation, I received this answer warning me about potential maintenance problems:
mixing auto-generated code always pose a risk of someone ...
12
votes
2
answers
1k
views
Design decision - why generate <p> without </p>?
tl;dr
Some widely used programs, which generate html, will only generate opening paragraph tags, and not closing ones, assuming that the browser will properly close paragraphs.
On the face of it, it ...
11
votes
1
answer
10k
views
Way for generating C# classes from existing C# class
I have simple POCO classes, like this:
public class Book
{
public string BookId { get; set; }
public string Name { get; set; }
//etc...
}
I want to get all those classes and generate ...
11
votes
2
answers
667
views
How easy should a language development framework be to use?
This is part of a series of questions which focuses on a project called the Abstraction Project, which aims to abstract the concepts used in language design in the form of a framework.
Another ...
10
votes
4
answers
2k
views
Writing a Compiler Compiler - Insight on Use and Features
This is part of a series of questions which focuses on the sister project to the Abstraction Project, which aims to abstract the concepts used in language design in the form of a framework. The ...
10
votes
5
answers
4k
views
Generating Java Classes with Compile-time Value Parameters
Consider a situation where a class implements the same basic behavior, methods, et cetera, but multiple different versions of that class could exist for different uses. In my particular case, I have a ...
8
votes
3
answers
2k
views
code generation - would C be a good compiler backend?
In this and this stack overflow questions, the answers state that C as a compiler backend is a bad idea.
But why?
C has many compilers that can heavily optimize it. Every platform has a compiler ...
8
votes
4
answers
4k
views
Should one test generated code?
My team doesn't write tests for generated code (e.g. some POJOs). An engineer that I greatly respect recently wrote this on the subject:
Research over the past 10 years has revealed that generated ...