Questions tagged [code-generation]
The code-generation tag has no summary.
66 questions
1
vote
3
answers
402
views
Code generation for multi-platform, multi-language library
I need to design a code generator system that produces serialisation/deserialisation libraries for multiple languages running on multiple platforms.
Hard Constraints
I need this to capture a pre-...
1
vote
3
answers
601
views
Autogenerate DTO classes?
Yesterday I screwed up:
One of the classes of my C# contained a property, called "DeliverdQuantity" (yep, there's a spelling mistake indeed). When I saw that, I decided to correct that, ...
0
votes
1
answer
110
views
Identify downsides: versioning auto-generated Terraform source code [closed]
HINT: the purpose of this question is to identify downsides for the scenario described. If something is a downside, then it should be quantifiable and it should clearly have a negative impact.
...
0
votes
2
answers
514
views
How to keep OpenAPI specification up-to-date and compliant without using code generators?
In our company, there is no standard for how to document APIs. Missing API documentation slows down the development process.
Therefore, we want to introduce OpenAPI.
We want to use code generators to ...
-3
votes
2
answers
409
views
How to use Github Copilot for business software evolution (if possible at all)?
Github Copilot got update yesterday (2023 St. Valentine) https://github.blog/2023-02-14-github-copilot-now-has-a-better-ai-model-and-new-capabilities/ but still no information for its use in the ...
1
vote
2
answers
527
views
C# Source Generator : which way to go for a simple GitHub Community Project
CONTEXT
My project is about implementing the "conventional method for house-energy-efficiency assessment" in France (120 pages). I want to provide a strict yet easy to use API to this method....
7
votes
2
answers
2k
views
How to generate java class files with framework boilerplate in a project?
The Java project I am working on currently has a complicated folder structure, and to add a new functionality, one needs to add many .java files in different places in order to let it work in our ...
0
votes
1
answer
237
views
Using sed/awk to bulk generate static HTML pages off of a template
Hypothetically, consider a social photo platform - each pic gets its own url, this page contains the image, text about the image, buttons for the user to click, related pics, and some user-specific ...
0
votes
2
answers
270
views
How do I distribute a C++ compiler with my application?
I'm developing a commercial closed-source application that will have a user-interface, and the back-end will be generating C++ code that needs to be compiled to produce a final end result.
When I ...
1
vote
1
answer
459
views
Common methods of generating code with code
I wish to develop an application that can generate code based on an user input.
Long story short: a user gives a formal description of a Resource (can be viewed as a REST resource) and based on this ...
0
votes
0
answers
898
views
Why does Protobuf generate outer classes for Java?
I googled this and found questions like "How to use Protobuf message as java class without a java outer class?" (https://stackoverflow.com/questions/60312156/how-to-use-protobuf-message-as-...
1
vote
3
answers
369
views
Should Source Generators be used for managing optional dependencies
Let me try to clarify my question with an example. Assume a library of some sort which has a built in logging system and it is published as Library.Core. As the maintainer you want to add a wrapper ...
-6
votes
1
answer
230
views
Why is automatically generating automated tests frowned upon?
First, the most obvious grouse someone has against this I can think of is the intricacies of an actual method. It's not enough to merely ensure no errors are thrown. Functions usually contain ...
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 ...
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 ...
3
votes
4
answers
1k
views
How can I detect autogenerated code in a project?
I am working at a medium-size semi-govermental organization managing subcontractors for software projects. One of our contractors recently turned in the "source code" for the project they had ...
1
vote
0
answers
119
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
1
answer
238
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 ...
3
votes
1
answer
1k
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
1
answer
863
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
3
answers
875
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 ...
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, ...
0
votes
1
answer
1k
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 ...
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 ...
1
vote
3
answers
747
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
3
answers
651
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 - ...
6
votes
3
answers
872
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
1
answer
557
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 ...
4
votes
3
answers
3k
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 ...
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 ...
6
votes
1
answer
462
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
1
answer
1k
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
2
answers
126
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 ...
5
votes
2
answers
11k
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
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 ...
2
votes
1
answer
146
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
1
answer
307
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 ...
1
vote
1
answer
128
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
0
answers
152
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-generating ...
5
votes
2
answers
283
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 ...
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 };
...
7
votes
1
answer
2k
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
2
answers
222
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
2
answers
3k
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 ...
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....
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 ...
6
votes
4
answers
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
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 ...
2
votes
4
answers
2k
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 ...
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 ...