Code Generators And Automatic Gear Cars

The other day at work, I don’t know what re-opened the whole code generation tools discussion.

Personally, I have a strong conviction that no code generator, no matter how advanced or good it is, can match the quality of code well written by a good developer, full stop.
I’ve believed in that for years and years, and will believe in it for years to come. And I’m not talking theoretically, I’ve been in the field long enough to see the results of different code generation tools, varying from the disastrous to the quite good and pretty clean.

But the thing is that it’s a code generator after all, so it’s pretty much generic, which could be good enough if you’re just working on some simple form that won’t do much more than insert some contact info into a database or something of the sorts, but once you get a bit deeper, its generic solutions just aren’t enough, you need someone good to work out the logic and to optimize the code, …etc etc etc.

One thing to keep in mind though is the importance of having a good developer who can write good code.

Anyway, this morning while driving to work, the issue popped up in my head again, with a rather interesting analogy that I think really explains the difference between generated code and human written code.
The analogy is with cars; human written code is pretty much a stick shift car, and generated code is an automatic.

If you were to enter a race, you’d actually have more control over the car with a stick shift, over when you change gears, how much power it gives you and when, thereby giving you an edge that would help you win the race.
Automatic gear doesn’t give you all that flexibility, it just lets you drive, with different levels of control, according to how advanced the automatic gear is, but never equaling that of a manual gear.

The driver and how good he is is also a factor here, because it takes a good one to know how to control a car well and get the most out of it to win the race.

To me, this analogy perfectly illustrates the difference between developer-written code and generated code, and shows why the first is superior to the latter; it all lies in the results: quality, flexibility, optimization and robustness.

Published by

Mohamed Marwen Meddah

Mohamed Marwen Meddah is a Tunisian-Canadian, web aficionado, software engineering leader, blogger, and amateur photographer.

3 thoughts on “Code Generators And Automatic Gear Cars”

  1. I do not share your opinion. I have been working in code generation stuff for 4 years and we are doing quiet complicated things with it. As an example we generate simlation platform for complex system such as settop boxes and the input document are framemaker documents written by hands. This kind of methodology reduces hugely the amount of bug detected at verification time. I admit that the amount of work to meet such level of automation is quiet big (more than three year of work) but in our case it is a vital thing to automate verification environment.

    May be my experience could give you more confidence in ambitious ideas.

  2. We use a code generator too at my company (but I am not involved in development as I am a performance tester). Code generation (from UML) can be very useful, time saving and a way to build things upon a certain framework. We also use build tools and automated tests. I though think that all this stuff couldn’t help much if you don’t have skilled developers and if you don’t round up the whole tests with manual tests etc. Of course it all depends on the piece of software you are implementing.

  3. All alone I once had to manually read and analyze 500,000 lines of automatically generated code in order to reverse-engineer a frightfully–and in the main, needlessly complex application. I still suffer nightmares from it and have been in therapy ever since.

Comments are closed.