Code Generation
Creating programs to create programs
Higher Performance
Often, there is a choice between writing higher performance code or easier to maintain code. Using techniques like reflection can dramatically improve program simplicity as well as readability. For some applications this is acceptable, but what happens when you need to perform millions of operations? The heavy cost of reflection starts to creep in.
Code generation, either as a preprocessor or simply as a development tool, can help bridge that gap. Instead of using reflection, simply generate the required code. For simple operations like storing data, real world performance improvements of 1,000,000X speedups have been achieved.*
Maintainability
Code Generation can also dramatically improve code maintainability.
For instance, a workflow where a programmer must generate a SQL query or stored procedure, then create C# code to store that data, and finally create a visualization from that stored data.
Through code generation this entire workflow can be simplified to the creation of the SQL query. If you ever need to change the graph, simply change the SQL query. Not only does this improve development time, but it reduces the possibility of errors occurring, and simplifies fixing those errors.
* Performance improvements measured in wallclock time, achieved at Sagitec Solutions.