Why Java will not get Macros

by Charles Miller on December 10, 2002

There have been calls from some quarters for a fully fledged macro system in Java. I think the chance of this escaping academic study and getting into mainstream Java is somewhere close to zero.

One of the design goals of Java, like it or not, was to avoid dangerous or confusing features. Macros are, by definition, dangerous and confusing. They change the way the language works, in such a way that it becomes impossible to look at a piece of code and guess what it does. They're difficult to write correctly, and difficult to use safely.

I'm not saying I disapprove of macros. I don't disapprove of pointers either. I even believe that goto has its place in the world. But none of these things have a place in Java, because they run counter to the design goals of the language.

Previously: SOAPy Madness

Next: Why Hibernate Rocks