Monday, February 28, 2005

Programming by copying

Recently, I've seen a demo on programming by copying. It takes just few minutes to see it and it's really worth to do that. Although it might be seen as a funny plaything first, a much deeper idea is hidden behind that. Not many programmers would admit that programming by copying is a good idea. Nor do I. On the other hand, say frankly, how many times did you program by copying? I did many times. What's wrong on that? It shows a bad concept of your program. What's good on that? It's fast and accurate; the copy becomes an original piece of code immediately and you can adjust the copied code instantly without worrying about side-effects at another parts of your program. Shortly, copying is good when jotting down a prototype of your idea and you don't really bother about misconceptions – you know your program will need refactoring in the productize version, but all theory, dear friend, is gray, but the golden tree of life springs ever green (as a great German writer once said). We don't always have time to refactor it, do we? In such a case programs made by copying get to products. So, what's the hidden idea? Here it is – program is not only a piece of text and programming is not just typing of it. It shows that text editors are still a weak substitute of real program editors. If an editor tracked all changes made on the program and remembered which parts of the program were made by copies of another parts, the editor could refactor the program without programmer's help. Moreover, the editor would refactor program without making mistakes, it wouldn't forget any possible side-effects. The demo shows one way to do that in not real textual editor and in not really common way. Similar idea can be implemented into more sophisticated and common editor. Much in programming has been changed since time of Turing but not the way we program. It's like making cars with hammer and sickle only! I'm not saying – using primitive tools for making cutting edge technologies is impossible, I'm saying – let's do something with it!