James Watson
Posts: 2
Nickname: banned
Registered: Sep, 2011
|
|
Re: Tools
|
Posted: Sep 9, 2011 11:03 AM
|
|
> > On a side note, while I tend to hate tools that generate > > java source code, it's good to keep in mind that compilers > > are tools that generate code. > > That is true. I think there is an argument about how > complex the generated code is. I've never heard of bugs > in an assembler, but compiler optimizations will cause > trouble once in a while.
I've been thinking about this because I realized in writing the above response that I didn't have a clear explanation for why I like (love even) compilers but loathe java source code generators.
I what it comes down to is that compilers are designed to generate code that is not fit for human consumption and produce output for machine use. I assert that few people in this day and age would argue that compilers are not a paradigm shifting technology that has fundamentally improved the speed and quality of software development.
So having established that code generation by compilers is a very good thing, why is it that what is good for the goose is not good for the gander? I think it comes down to one general issue: code generators generate code in languages intended for human consumption. The actual code that is produced is often not. A 'true' source code generator is a tool that generates code that is meant for people to work with (e.g. templates). If the code produced is not meant for people, the generator is really acting more like a compiler. I guess that's OK as long as I don't have to see that code.
The problem appears when generators start to blur the lines between source generation and compiling. You can update some parts but not others or you can't touch the source but you must interact with the generated APIs and try to figure out how they relate to the generator inputs.
I also think that some generator tools are just poorly designed or are misguided in their approach. For example, most XML schema-based code generation tools basically generate Java objects based on the structures in the XML. They don't really 'bind' anything. That work is left to the developer to do using lots of tedious coding. In other words, they don't actually provide any solution, they just move the problem into a different language.
|
|