merits of Lisp vs Python

hankhero henrik.hjelte at gmail.com
Sat Dec 9 03:26:10 EST 2006


I was the one mentioning triple-quotes because it was one of the few
Python features i could think of that was better than Lisps.

> For me python is 'strong OOP' scripting language in first place.
> Inheritance, generalization and every kind of abstractions togeteher
> with clean and simple syntax make python perfect language for medium
> size "scripting" projects (ie just explore the code and add your
> features, no messing with compilers).
The Common-Lisp object systems has all and more OO-features, some which
you never probably have thought of before. Here's one:
Inheritance lets you specialise a method so a rectangle and a circle
can have a different Draw method. If you wouldn't have OO you would
need a function with if statements to dispatch on thing, if
thing=rectange then drawRectangle if thing=circle then drawCircle.
What if you want a draw method that takes a thing and a backend, then
you need if statements again, draw(self,backend): if backend ==
postscript do one thing else do another.
Maybe you can solve this with multiple inheritance, creating
RectangePostscript and CirclePostscript objects. Lisp supports multiple
inheritance too, but also multimethods which allow a looser coupling
between objects and dispatching on all parameters, not only the first
parameter (self in python speak). Just define one method
draw(rectange,postscript) and another draw(rectangle, pdf)

>  Exceptions, finally/except blocks,
Lisp has a unique exception system. Say ReadHtmlTag throws an exception
deep down in your system, UnexpectedChar. In Lisp you can define
recovery strategies all over your system. the IgnoreAttribute recovery
strategy can be in the same method as ReadHtmlTag. You can have another
ways to recover, IgnoreFile, or ReparseFile higher up in your program.
When you catch the error at the highest point in you main function, you
can choose which recovery you want to use. Either IgnoreAttribute and
continue in the ReadHtmlTag method or ReparseFile in the ParseFile
method. The stack and variables will be there right as when the error
occurred. If I write a library I don't have to guess if the users of my
library wan't me to show a nice GUI error message, ignore the error or
whatever. I provide all options and let they choose.

> automatic reference counts and destructors make it easy to
> write "robust" code.
No, Lisp doesn't have anything like that. There is a thing called the
garbage collector however, I think it exists in other languages.




More information about the Python-list mailing list