26 August 2003
This weekend I've been writing a program that generates last wills and testaments for a new client. After a bit of research, I chose to use Microsoft Word's VBA. It turned out to be perfect for the job. Furthermore, I've found VBA to be the easiest programming environment I've ever seen. Don't get me wrong, it's horribly buggy, the VB language is unbelievably weak, there's no security, it crashes regularly, and generally behaves like what we've grown to expect from Microsoft. But there are two features of VBA which outweigh the Microsoftyness of it:
The first is that VBA is grafted onto the side of Word (and the Office suite, and the Corel suite and lord knows what else). With the ability to manipulate these applications, even a toy language like VB suddenly becomes monstrously powerful. This isn't news; everyone knows the advantage of using an environment which has large libraries or capable interfaces.
What's really caught my attention is the second feature, the macro recorder. Normally programmers who are new to an environment have to 'go larval'[?] until they've acquired an understanding of the basics. VBA has found a way to drop this step. To code an action in VBA one doesn't have to remember Microsoft's Byzantine API, one just starts a macro recording, performs the action manually inside the application using the normal human UI, then stops the recording. The code that was generated for the macro can be examined, imported into your program, then tweaked to make it dynamic (replacing fixed strings with variable names, adding loops and other control statements, etc).
So for example, if you want to find all instances of "oldText" and replace them with "newText" in red, just do so using the normal Edit|Replace menu option, then inspect the resulting macro code. There's nothing magic about that code; it is just a bunch of calls to Word's complex API. You could have gone larval, inhaled the docs, then written it without the macro recorder. The point is you didn't have to. Everyone has already learned the API designed for humans (menus and buttons), why force them to learn a new API?
Players on the Moo learn simple commands to get around. Builders extend this vocabulary of commands. Programmers throw away everything they've learned so far, and start from scratch. For example, a builder uses
Microsoft's approach to VBA wipes out the larval stage. Mozilla and the Moo are both infinitely more solid environments than Office. How can we get the best of both worlds? Food for thought.