What's better about Ruby than Python?

Harry George harry.g.george at boeing.com
Mon Aug 18 21:27:09 CEST 2003

Alexander Schmolck <a.schmolck at gmx.net> writes:

> Alex Martelli <aleaxit at yahoo.com> writes:
> > (I do hope that Python never gets such a powerful macro system, no matter
> > the allure of "letting people define their own domain-specific little
> > languages embedded in the language itself" -- it would, IMHO, impair
> > Python's wonderful usefulness for application programming, by presenting an
> > "attractive nuisance" to the would-be tinkerer who lurks in every
> > programmer's heart...).
> I don't think a powerful but potentially dangerous feature poses much of a
> problem as long as there is little danger of inadvertently using it and little
> incentive to inappropriately use it (e.g. you could do all sorts of stupid
> things in python, like redefining __builtins__.len, but generally there isn't
> much of an incentive to do so, so many of the reasons why e.g. Java
> programmers might think python an unsuitable language for larger projects
> don't really apply in practice. My feeling is this *not* true to the same
> extent for ruby, where similar things are both encouraged and, if I don't
> misremember, can happen inadvertently).
> Would you still have a problem with macros in python if utilizing them
> required some obvious and explicit mechanism (say a 'use_custom_syntax'
> statement right at the beginning of a module that wants to use macros), so
> that their use could easily be controlled by e.g. project managers?
> 'as

Yes, it is a problem under any circumstances.   

"The first step in writing a macro is to recognize that every time you
write one, you are defining a new language".  P. Norvig, "Paradigms of
Artificial Intelligence Programming", c 1992, pg 66.

In the Lisp world, you use the hundreds of macros in CL becuase they
*are* the language.  But home-grown (or vendor supplied) macros are
basically a lockin mechanism.  New syntax, new behavior to learn, and
very little improvement in readability or efficiency of expresison
(the commmon rationales for macros).

The python language is just fine as is.  If you really, really need
something like a macro, consider a template body which is filled in
and exec'd or eval'd at run time.

harry.g.george at boeing.com
6-6M31 Knowledge Management
Phone: (425) 342-5601

More information about the Python-list mailing list