What's better about Ruby than Python?

Roy Smith roy at panix.com
Mon Aug 18 16:09:47 EDT 2003


Alex Martelli <aleaxit at yahoo.com> wrote:
> I do hope that Python never gets such a powerful macro system

I'm with Alex on this.  Macros suck.  What you usually end up with is 
essentially two different languages, with different syntaxes, and which 
don't interract very well.  If nothing else, this really screws up emacs 
auto-indenting :-(

One of the few things I like about C++ is that between const, templates, 
and inline, the need for the macro preprocessor has been almost 
eliminated.  Still, you see a lot of code which goes out of its way to 
do fancy things with macros, almost always with bad effect.

I don't even want to talk about the various systems which make use of 
things like m4.

Why do you need macros?  There's a few things people do with them:

1) Define constants.  In Python, you just define symbols in your module, 
and get over the fact that there really is no such thing as a constant 
in Python.

2) Define efficient pseudo-functions.  In Python, you just define a 
function (or method) and get over the fact that it's not as efficient as 
a macro.  If I cared about microseconds, I wouldn't be writing in Python.

3) File inclusion.  In Python, you don't include files, you import 
modules.

4) Conditional compilation.  In Python, you can conditionally define 
anything you want at import time.

5) Inventing your own language constructs.  In Python, you just don't do 
this.




More information about the Python-list mailing list