Bill Venners on Code Generation


Blogs: Bill Venners on Code Generation

  1. Bill Venners on Code Generation (1 messages)

    In his blog, Bill Venners talks about Bruce Tate’s latest article on Ruby on Rails Active Records. Bill suggests that the real benefit of RoR is not a question of wrapping vs. mapping but rather it’s about the real benefits of code generation.

    Bill never questions the benefits of Bruce’s wrapping argument. Instead he bolsters Bruce’s position by providing examples of where wrapping a code generation in a standard API has proved invaluable.
    twice a year I found myself editing the SQL schema file that created the tables and also editing that C file that served as the layer. It dawned on me that all the information needed to generate the C file was contained in the SQL schema file, so I wrote a Yacc/Lex program that parsed the SQL schema file and generated the C file (i.e., it generated the database layer for our application)

    Bill provides us with a nice description of the differences between static and dynamic code generation. The technique used by Bill and the one that we typically use in Java is known as static code generation. On the other hand, RoR uses dynamic code generation. This dynamic mechanism gives the appearance of being very light-weight.
    To me the important lesson for the Java community to take away from Rails is that you should consider using code generation where appropriate.

    Bill also recognized the weakness of code generators in that they often are not able to completely generate all the code needed. Thus is it up the developers to finish the task. Once tinkered with, you often cannot regenerate the code without risk of losing the changes. This has been one of the biggest knocks against GUI generators.

    In the end Bill is very positive about how Ruby and Python push developers into creating code generators. However he is equally positive about the ability to achieve the same thing using tools such as JavaCC and Antlr. You can read the entire post and Bill’s references at his blog.
  2. IMHO, it's funny to claim that Java community, that produced Hibernate, has something to learn form Active Records.

    As far as the dynamic code generation goes, I don't see what exactly Java needs to learn there, either. It was always possible in Java but was sometimes avoided due to serious concerns, some of which include but are not limited to:
    1) Performance problems
    2) Problems maintaining, documenting and understanding the part of the code that is automatically generated.

    Seeing so much buzz about RoR is really annoying. All it is based on - is several unjustified claims of productivity. There are many ways to be very productive in Java, too. It's just that - not necessarily Sun/JCP/JSR way is the productive one :)

    The only thing valuable in RoR, IMHO, is naming conventions and getting rid of bloated XML configurations. That's a good thing but I don't need Ruby to do that.