Automatic programming… well, almost
Test-driven development seems like a great idea, but when it comes to actually spending the time to write the tests, it seems like a drag. Of course, it’s not something that can be easily automated - tests should essentially be tightly-defined, programmatic versions of the design, and until computers get really great at natural language comprehension (and, in many situations, telepathy), they’re never going to do a good job of building what you want.
But armed with an executable definition of your goals, surely the computer could at least have a stab at implementing them? It could simply try running your tests against code libraries such as chunks of existing Open Source software - or, more usefully, try piecing together parts from several different sources in the hope of creating something executable that meets your tests’ assertions. A useful starting point would be to search unit-tested software to find sections of code that satisfy similar unit tests.
It would still require a lot of trial-and-error and hence be quite computationally inefficient, but patterns should begin to emerge quite quickly - which combinations of code satisfy the compiler and which sections of code are most likely to satisfy a given assertion. Of course, it would probably still take a lot of computer-juice, but computers are cheap - you can rent 500 powerful-ish PCs on-demand from Amazon EC2 for as much as the average developer. So if an army of 500 dumb PCs can write half the code, you break even - not to mention the morale benefits of taking all the drudgery out of coding and just leaving the challenging bits for the human to fill in.
I envisage it working something like this:
- design what you want to achieve this iteration, in collaboration with your customer and colleagues
- write the tests and interfaces, preferably with one of your colleagues doing some sanity-checking
- have a nice lunch, whilst your tests and interfaces are sent to the on-demand compute cluster
- come back to find that half the project has been magically coded already
- fill in the blanks, which are likely to be the parts specific to your project or particularly challenging
- whilst you code, the computer could display changes or blocks of code that you can easily include that satisfy the compiler and some of your test suite (although the User Interface obviously needs some thought - we don’t want the programming equivalent of the Office Paperclip!)
This would essentially give a new way of programming - half-way between declarative languages where you only specify the goal and imperative languages where you must specify every step. By specifying the goal and then guiding the computer in creating a solution, we create a hybrid that has the elegance of the former with the power and flexibility of the latter.
Comments(2)