Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [code-generation]

The tag has no usage guidance.

1
vote
0answers
85 views

Why use code bootstrapping tools?

It seems pretty common knowledge that code is read far more than it is written. Does this mean that if a tool produces code that's checked in, then it's a net negative (saves the author some time in ...
-2
votes
1answer
153 views

generate code or write generic code [closed]

I am writing drivers for different devices to work with my embedded system. Currently I write any new driver manually but for the future I would like to automate this using a settings file. I figure I ...
1
vote
1answer
76 views

Integration of code generators in CI / CD pipeline

In my company, I'm currently working on a project with some (REST) web services involved. The development is based on the OpenAPI specification and the Swagger tooling. The target platform is an ...
-1
votes
1answer
380 views

How to make compiler portable?

I am writing a simple compiler. I have written lexer and parser and it now generates assembly code from given code. Now I need to write an assembler which generates machine code. But the problem is ...
4
votes
3answers
309 views

When to use code generation over flexible programming

where I currently work, there is a team that uses code-generation to generate slight variations of a program. I find this a little bit awkward. I can imagine using code generators that produce complex ...
117
votes
27answers
24k 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, ...
0
votes
1answer
229 views

In Qt or C++, is there a good means for creating a switch with dynamically generated cases, or should I just use a for loop (or something else)?

Presume this situation: Max Number of 256 key slots. Key slots are defined by a struct, and a variable for each (256) has to exist. User defines which keys slots are active at initiation (in my ...
4
votes
4answers
1k 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 ...
1
vote
3answers
334 views

How to version generated code without checking them into VC?

I have written a code generator for my company, that basically has the following workflow: entity xml definition | v gets ...
5
votes
3answers
545 views

General architecture of “game makers” (without coding)?

How do game makers/engines like Buildbox, GameSalad, Construct, GameMaker, etc work in principle? I am not interested in getting a list of technologies (programming languages, APIs, etc), but how - ...
4
votes
3answers
360 views

Is SSA form worth it if code generating to a high level language?

I'm writing a compiler that compiles to C. This means that most of the time I piggyback on top of C for optimisations and generating code for multiple platforms. Right now I can think of a few ...
3
votes
1answer
345 views

Workflow when using generated code

I'm working with Swagger to generate the API of my application. Swagger is an API specification language that can be used by a code generator to generate code stubs for your application. Obviously you ...
2
votes
3answers
1k views

How exactly is bytecode “parsed”?

How is Bytecode "parsed"? It is my understand that Bytecode is a binary, intermediate representation of the syntax of a given programming language. Certain programming languages convert their source ...
5
votes
1answer
4k 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 ...
4
votes
1answer
127 views

Implementing a construct like Rusts `match` in C?

I'm writing a compiler that compiles to C, one thing I'm attempting to do is implement a construct like Rust's match: // { some function let mut foo = 32; match foo { 3 => return "...
0
votes
1answer
748 views

Entity framework code first for another project

I am recently developing multi-tents cloud application that can help to generate classes and dbcontext dynamically for other ASP MVC projects. How can I do this task from my application to another ...
0
votes
2answers
110 views

Modernize a compiler, late switch of generation-paradigm

Have been hired to modernize an old binary compiler that has been forgotten since a few years by people who have died already. The compiler has a parser, an objectmodel and a generator of ...
4
votes
2answers
5k views

How to generate C++ code? (probably WITH (not FROM) Python) [closed]

For a scientific simulation I need to write some computations in C++. Since this became extremely tedious, I built myself a small code generator: In a scripting language (Python) you put together a ...
10
votes
5answers
2k 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 ...
2
votes
1answer
52 views

How to integrate modified generated code into the build process?

I'm using a code generator which has the following workflow: Configure stuff Generate code Modify generated code with user code at specifically annotated positions. If changes are required to the ...
2
votes
1answer
227 views

Low cost exceptions implementation using metaprogramming [closed]

(preface - boring stuff, feel free to skip down to the implementation details) I need to provide exception handling to a language I am working on. It "compiles" to a subset of C, and since I don't ...
1
vote
1answer
105 views

Algorithm for optimized variable generation without collisions?

I'm looking for an algorithm that can generate optimized syntactically valid variable names (for javascript in this case) without collisions. So as general rule I would want something that generated ...
1
vote
0answers
137 views

Are facilities that generate HTML for you, considered harmful? [closed]

I will approach this from two directions (+ raw HTML itself being de-facto third) Proprietary HTML-generating code Code generating facilities provided by a popular library Proprietary HTML-...
5
votes
2answers
234 views

Is there a benefit to unit testing code whose sole purpose is to generate non-human-readable code in another language?

A significant portion of the application I work on every day consists of Javascript that outputs a lot of (what might as well be) Excel spreadsheet formulas. Yes, Excel is barely a Turing-complete ...
32
votes
6answers
8k 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 }; ...
7
votes
1answer
1k views

Creating New Scripts Dynamically in Lua

Right now this is just a crazy idea that I had, but I was able to implement the code and get it working properly. I am not entirely sure of what the use cases would be just yet. What this code does ...
1
vote
2answers
200 views

Handling stylesheet from a real programming language

Lately I've been playing with CSS (and other web technologies). I'm a non-web programmer, and probably this is influencing way too much my approach. I found CSS syntax very limited, thus gave a shot ...
7
votes
2answers
2k views

Should Maven generate JAXB java code or just use Java code from source control?

We're trying to plan how to mash together a build server for our shiny new Java backend. We use a lot of JAXB XSD code generation and I was getting into a heated argument with whoever cared that the ...
15
votes
4answers
32k 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....
14
votes
2answers
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 ...
6
votes
4answers
2k views

What would the general design for an XSD to C# class converter look like?

I am looking to create a simple code generator to convert XSD definitions to C# classes. This is partly as a learning exercise, but I would also like to get some practical use out of it eventually. ...
10
votes
3answers
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 ...
2
votes
4answers
1k views

Unit Test code generation

We have a project that was written over a period of 2 years, but has a poorly designed architecture and not unit tests. The software works well, but we're at the point where we want to refactor some ...
37
votes
5answers
6k 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 ...
6
votes
4answers
745 views

Why do code generators always use fully-qualified identifiers?

When you look at the code for the Winforms Designer, you see things like this: this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", ... etc. instead of using System.Drawing; label1....
6
votes
2answers
2k views

Formatting SQL Based on an AST

I am working on my .NET open source project for generating SQL... Initially, I wrote the project so it spit out exactly one SQL format... ugly. I started using this project in the real world and ...
2
votes
2answers
309 views

Software licensing and code generation

I'm developing a tool that generates code from some various data. The tool itself will be licensed with the MIT license, which strikes a good balance for me in terms of allowing the freedom to use and ...
5
votes
3answers
4k views

Best practices / Design patterns for code generation [closed]

I'm working on a ground up code generator project, but I feel I might be reinventing the wheel. Does anyone know where I can find some best practices guidelines or design patterns for code generation?...
6
votes
1answer
5k views

Caching strategies for entities and collections

We currently have an application framework in which we automatically cache both entities and collections of entities at the business layer (using .NET cache). So the method GetWidget(int id) checks ...
1
vote
1answer
151 views

Right approach to convert a word document that contains forms in a web app

I would know if someone can suggest a good approach to convert a word document that contains forms in a web app, specifically in an application built with WaveMaker.(but I'm curious also with a ...
3
votes
5answers
541 views

Is it a good idea to generate code with the help of your IDE? [duplicate]

Possible Duplicate: Should newbies use IDE autocomplete (Intellisense)? Since I moved on to actual IDEs for C++, Java and Python, I noticed they automatically try to complete my code. For example ...
104
votes
22answers
111k 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 ...
11
votes
2answers
565 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 ...
13
votes
6answers
19k 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 ...
4
votes
4answers
1k views

What are the arguments for/against Code Generation?

I'm in a position where we've got some brittle code that constructs SQL-like queries via text concatenation with parameters for inputs. The data source that it queries is fast and scalable but lacking ...
6
votes
7answers
921 views

Design Code Outside of an IDE?

Does anyone design code outside of an IDE? I think that code design is great and all but the only place I find myself actually design code (besides in my head) is in the IDE itself. I generally ...
6
votes
8answers
625 views

Are today's general purpose languages at the right level of abstraction?

Today Uncle Bob Martin, a genuine hero, showed this video In this video Bob Martin claims that our programming languages are at the right level for our problems at this time. One of the reasons I get ...
2
votes
11answers
867 views

IDE Generated Code

Many IDEs have the ability to spit out automatically written pieces of code. For example, it might generate a getter/setter pair for you. I wonder whether it isn't an attempt to work around some flaws ...
6
votes
4answers
1k views

Why are parser generators used?

I saw some projects require BISON to generate C++ code. What is the advantage of having BISON/Yacc etc. generate C/C++ code instead of writing it yourself?
13
votes
4answers
3k 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 ...