Code Generation For Fun And Profit post
(Note, I almost forgot to post about this today as part of my November blogging challenge)
I have a serious programmer man-crush on Giles Bowkett. I don't always agree with him, but when he talks about programming he never fails to make me stop and think. Just like Amy Hoy when she talks about design. In a blog post he mentioned what he considers the best book that programmers have never read. I've taken a look at the sample chapters that are available from the publisher. I was very impressed. Then I watched the talk that Giles gave about code generation and why you should be aware of it.
I've probably had more experience with code generation than most programmers, being an early proponent and user of CakePHP's "bake" system (even writing my own test shell for it, which I'm sure was abandoned and not used by anyone else). When I tell people about what you could do with 'bake', a lot of times I got blank stares. They didn't understand why I was so excited by it. That's okay, sometimes I get excited about things that other people could care less about.
But you read things like "to generate these 1050 files by hand would take 3 man-years on the project, and we could create a generator to do it in 2 man-months", well, if that doesn't pique your interest then I think you're in programming for the money, not for the challenge of solving problems.
Which is why I think I need to set aside some time at work to examine a tool that I hope I can lean heavily on for upcoming PHP projects, Zend_Tool_Framework. If I'm right, and Zend_Tool_Framework is nice and tight and generates code that was of as high quality as "bake" did, then it will help speed up development.
Rails leans very heavily on code generation to provide it with the structure that it has, which in term allows you to get down to the job of solving the problem you are faced with, instead of creating code from scratch. A well-written code generator can save you immense amounts of time. I do not see much evidence of a culture of code generation in PHP, but the Rails people *get* it.
So, do the following:
- Watch Giles' presentation. He is smart AND funny
- Either buy "Code Generation In Action" or at least check out the sample chapters you can download
- Buy me a copy of this book. It's on my Amazon.com wishlist!