Code generation vs data driven programming
11th February 2004
Via Ned Batchelder, this interview with pragmatic Dave Thomas on code generation closely reflects my own nascent thoughts on the issue:
CGN: What do think the future is for code generation?
Dave: I think that in the long term the larger code generation efforts, the “application generators,” will become a thing of the past. They are there because the underlying technologies and architectures don’t yet support programming at a high level. But I’m betting that languages such as Java and C++ will in the long term be seen as a curious branch in the evolution of computing. I’m hoping that somewhere out there some bright spark is coming up with a way of letting us write applications expressively and dynamically. Once this happens, the need for these kinds of code generators will diminish.
For example, I rarely (if ever) write a code generator that generates Ruby code: there’s just no need, as Ruby is dynamic enough to let be do what I want without leaving the language.
In the shorter term, though, I think code generators of all kinds will continue to contribute significantly to the industry. Java and C# are both such stifling languages that you need to be able to use code generators to make them effective.
We considered using code generators for our current major project at work, and picked up Jack Herrington’s book on the subject. Reading through it, it became clear that many of the problems that code generators solve can be tackled instead using data driven programming techniques made possible by dynamic languages. Since we had already settled on Python as our implementation language the need for code generation became far less apparent, and we ended up avoiding it entirely with the exception of a command line tool for passively generating basic templates for our admin interface.
If I ever have to work with a less expressive language I’ll certainly consider using a code generator (probably written in Python) to abstract away some some of the tedious repetition. As it is, Python’s rich data structures and clean support for introspection provide an excellent alternative.
More recent articles
- llm cmd undo last git commit - a new plugin for LLM - 26th March 2024
- Building and testing C extensions for SQLite with ChatGPT Code Interpreter - 23rd March 2024
- Claude and ChatGPT for ad-hoc sidequests - 22nd March 2024
- Weeknotes: the aftermath of NICAR - 16th March 2024
- The GPT-4 barrier has finally been broken - 8th March 2024
- Prompt injection and jailbreaking are not the same thing - 5th March 2024
- Interesting ideas in Observable Framework - 3rd March 2024
- Weeknotes: Getting ready for NICAR - 27th February 2024
- The killer app of Gemini Pro 1.5 is video - 21st February 2024
- Weeknotes: a Datasette release, an LLM release and a bunch of new plugins - 9th February 2024