About code generators / generating code
James Avery blogs about an article written by a person who calls himself 'Angry Coder' (I thought people called me that ;)) and that article ventilates the opinion that code generators are not useful, to say it in a politically correct way. I agree with James Avery that the article misses the advantages of code generation and how it can benefit you in your daily life. I'd say: the article is totally wrong. Here's why.
In 1993, a professor of the CS department I was a student of held a lecture about code generators. In short it came down to the fact that typing code statements is time consuming, boring and error prone, and has nothing to do with programming, which is defining algorithms, data-structures and functionality specifications, in a language independent way. If you can transform the actual logic, the functionality you want to implement, from a higher abstract level to code which can be compiled by a compiler into executable format without having to type it in, it would be a real time saver plus would give you (almost) error-free software.
Code generators do that. They let you define functionality on a higher abstract level and do the typing for you. LLBLGen v1.x (the open source, free version) f.e. generates code to do the CRUD operations on an SqlServer catalog (C#/VB.NET/t-sql) and some more. You then do not have to type in that code, you can be sure it works and you can go on with what's really important: writing Business Logic (BL).
Even in that area, the days of typing code are numbered, at least for the majority of applications. Look at BizTalk server. It lets you design your BL with standard code blocks. In other words: it generates the glue between default blocks that can be reused. If you want an extra piece of functionality that is not there, you can add it or buy it. Adding it can force you to type some code, but not much. "People who do not understand that code generation is the future will be the first who will not be able to keep up with the rest who do", I said in the comments on James' blog. Print it out on a piece of paper and glue it on your monitor. Code generation is the future, simply because it saves time, is less error prone and it saves the programmer from boring coding sessions, sessions which will result in more bugs than interesting coding sessions.
I really feel sorry for those people who do not understand what power code generation really has. They are doomed to do boring work which can be done by computers in a fraction of the time without any error. Or does the author of that visionary article think he can program a DAL + BL facade tier-set for an application which has 100-s of tables, without errors? It did cost me 2 months to do it for my upcoming LLBLGen Pro application, to develop the framework and the code which is used in the templates. The generator can do it now in 2 seconds. Without 1 error. I definitely know what I'd do if I had to choose between the two :).
Code generators are tools, like a compiler, editor or debugger. Good tools help the user, so a good generator will help the user of that generator. It should be: which generator will I use?, and not: shall I use a generator or not?, like it is already natural to choose a higher order language or a sophisticated editor over their lamer equivalents. If you, as a developer, be aware of the fact that developing software has nothing to do with typing code but has everything to do with choosing which algorithms, which patterns, which OO structure, which database model, which sets of functionality to implement and so forth, you also be aware of the fact that the fastest and most clever way to realize all that is to specify what you want to develop in a tool which will then the best way how to implement what you want to develop. Code generators help you to reach that ultimate goal. We're not there yet, but I'm sure one day we'll. Until that time, code generators are the closed things we got to get near that ultimate goal. Don't stay behind.