Metaprogramming (The one true editor?)

Metaprogramming, is in some circles a lost art. When I started programming one of the first thing I was asked to do, was to make a program, that would modify it’s own code base dynamically, depending on a set of rules (the rules could change over time, and the program should be smart enough to conform) I don’t have to tell you this was a very hard problem, so my boss gave me the first major advice I have ever received: “Use the right tool for the problem”, at that time the right tool was Lisp –not because it’s the best language, but because it had the resources needed to solve the problem in a fast and painless fashion.

Forward to 2007, and very few software engineers, have written metaprograms, and even less know about metaprogramming. The truth is that most of the code I write for work “Simulators” have the ability to modify thy self, on command. Why in the world you ask? Simply because we have a very stupid chain of command, and usually what they say they want, it’s not what they really want, so given, that I am a lazy bastard, I use metaprogramming to my advantage.

Now, I can’t tell you how many times, I’ve seen some of my co-workers, curse our (bosses|users|clients), when they realize, they just wrote x lines of code that it’s not needed, and they have to write (* x x) in minutes. I feel for them, I really do.

What does all this have to do with editors? Well one of the main tools of a programmer (the main tool actually) is it’s editor. Today we have editors or IDE’s that specialize in certain languages, or technologies related to a language, and you see how some developers jump from one to the other clumsily, this reminds me of something my dad always told me when I was growing up (and religiously tell his grandchildren still) “Johannes factotum” That translates to “John does all”, or more colloquially “Jack of all trades, master of none, though ofttimes better than master of one”, another of his favorite quotes is “A chisel and hammer in the wrong hands, destroys in the right hands with get David“.

It does not matter what your tools are, if you can solve the problems at hand with them. In my particular case my programming editor, because of today’s demands needs to be a “Johannes factotum”.

I’m not saying specialised IDE’s are bad, I for example think eclipse is a very good IDE, and they are working to become a “Johannes factotum” tool. In my opinion a good editor or IDE should be able too:

  • Metaprogramming friendly, meaning you can change or add features or trigger certain logic, in a programmatic form.
  • Source code management tools, to make your life easier.
  • Addition of new language syntax, should be easy to add or modify (by & for) the user specific need.
  • Re-factoring easy and painless
  • provide the ability be it programmatic or by built in feature of code snippets, and templates.
  • Do not get in the way of writing code.

If you look closely an editor that posses a powerful configuration language you can do all of the above, even if it’s not a default feature on the editor, making it extensible by you. There are other features that are important to most users, I find them distracting, some are built in, into my editor of choice, others can be added with a few lines of elisp code, some of those features are:

  • Code completion.
  • Error detection.
  • Automatic syntax correction, or the code clippy as I call it.
  • Wizards

You might be thinking, you are contradicting yourself, you said: “use the right tool for the right job” how can one editor be the right tool for all languages or jobs? Well one editor can be the right tool, if it’s flexible enough, that you can add the features necessary for the work at hand. I prefer one editor, because It let’s me concentrate on the problem at hand, I don’t have to be going back to the help menu, to find out how to activate this or that, or have to learn different key schemes, I make my own, that are comfortable to my hand and easy for my brain to remember.

I’m not saying: “X” is better than “Y” that’s for each individual to decide on their own, my goal here is to make you think a little about your choice, and why it is your choice.

Is it because everyone is using it? or maybe because it looks cool? or maybe it’s the standard in your work place? or I don’t care about extensibility I am an X programmer and I want an X editor? or maybe I prefer to use specialized editors for the language?

If you feel comfortable and productive using the tools you are using, that’s good, but if you find a tool that makes you more productive, and comfortable, don’t set it aside just because everyone uses “X” and you will be mocked if you use “Y”.

I’m mocked mostly every day for my choice, and frankly I don’t care, It helps me get the job done, and that’s because it does not get in my way.

This not meant to bring a flame war, this is not a “Y” is better than “X” post, it’s about I like “Y” because of this and that. Don’t tell me what you don’t like or what you don’t use or why you don’t use it.

That said. What are your tools of choice and why? Do you metaprogram?

Advertisements

About this entry