What's better about Ruby than Python?

Doug Tolton dtolton at yahoo.com
Mon Aug 18 18:14:31 EDT 2003


On Mon, 18 Aug 2003 16:09:47 -0400, Roy Smith <roy at panix.com> wrote:

>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.


I don't agree at all.  Yes when you are defining a macro you are in
essence defining a new mini-language.  This is perhaps one of the most
powerful features of Lisp.  Programming closer to the application
domain, *greatly* enhances both the readability and the reusability of
code.

Good Lisp programmers use Macros all the time.  They are incredibly
useful and powerful.  The reason you don't do this in python is
because the feature isn't available.  That doesn't mean it *shouldn't*
be available.  Python is Open Source, how would someone writing a
Macro lock you in?  Just don't use the macro.

Just like anything else, Macro's can be over used and abused.  However
I maintain that if you don't see the usefulness of macros, you don't
really understand them.  Essentially using Python over Machine
language is just using one big ass macro language.  They are there to
allow you to create higher level abstractions, and tools that are more
specifically useful to your application domain than a general purpose
tool.

Python is a Macro Language of Machine Language.  Why don't you just
program everything in Machine Language?  Macros are to Python as
Python is to C as C is to Machine Language.

Python is great, as the trend shows, working at higher levels of
abstraction though is the ultimate goal.



Doug Tolton
(format t "~a@~a~a.~a" "dtolton" "ya" "hoo" "com")




More information about the Python-list mailing list