Python vs. Lisp -- please explain

Alexander Schmolck a.schmolck at gmail.com
Mon Feb 20 20:04:38 EST 2006


"Michele Simionato" <michele.simionato at gmail.com> writes:

> Alexander Schmolck wrote:
> > As common lisp and scheme demonstrate you can have high level of dynamism (and
> > in a number of things both are more dynamic than python) and still get very
> > good performance (in some cases close to or better than C).
> 
> Just for personal enlightment, where do you think Lisp is more dynamic
> of Python?
> Can you new name a few features?

Sure (I'm assuming that by lisp you mean common lisp):

- development model

  - by default the development model is highly interactive and you can
    redefine all sorts of stuff (functions, methods, classes even the syntax)
    without having to start over from scratch (you can also save the current
    state of affairs as an image). By contrast changing modules or classes in
    interactive python sessions is rather tricky to do without screwing things
    up, and it doesn't support images, so sessions tend to be much more
    short-lived.

    Emacs+slime also offers more powerful functionality than emacs+python mode
    (autocompletion, jumping to definitions, various parallel sessions or
    remotely connecting to running applications via sockets etc.)

- hot-patching
   
  - partly as a consequence of the above, you can also arrange to hot-patch
    some running application without too much trouble (IIRC Graham claims in
    one of his essays that one of his favorite pranks was fixing a bug in the
    application whilst on the phone to the customer as she reported it and
    then telling her that everything in fact seemed to work fine and to try
    again)

- error handling:

  - by default you end up in the debugger if something goes wrong and in many
    cases you can correct it in place and just continue execution (if you've
    ever had some long numerical computation die on plotting the results
    because of a underflow as you exponentiate to plot in transformed
    coordinates, you'd appreciate being able to just return 0 and continue)

  - Apart from "usual" exception handling CL has much more powerful resumable
    exceptions that offer far more fine grained error handling possibiliies.

    For more info let me recommend the chapter from Peter Seibel's excellent
    "practical common lisp" (available in print, and also freely online):

    <http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html>

    (The whole book is a great ressource for people who want to have quick
    play with common lisp and see how it's features can be leveraged for real
    applications (such as html creation, or writing an mp3 server or id3
    parser). Peter also makes an easy to install, preconfigured "lispbox"
    bundle of Emacs+a free lisp implementation available on his web-page).

- OO: 

  - You know this already, but I'd argue that multimethods and method
    combinations give you more dynamism then class-centric OO.

  - Also, if you change the definition of a class all existing instances will
    be updated automatically. You can get a similar effect in python by
    laboriously mutating the class, provided it doesn't use __slots__ etc, but
    that is more brittle and also more limited -- for example, in CL you can specify what
    happens to instances when the class is updated.

- chameleon like nature:

  It's much easier to make CL look like something completely different (say prolog
  or some indentation based, class-centric language like python) than it would
  be with python. In particular:

  - there are no reserved keywords

  - you can e.g. implement new syntax like python style """-strings easily
    (I've done so in fact) with reader macros. Indentation based syntax should
    also be possible along the same lines, although I haven't tried.

  - you can introduce pretty much any sort of control structure you might
    fancy and you can carry out very sophisticated code transformations behind
    the scenes.

- finally, with Lispmachines there at least used to be whole operating systems
  written all the way down in lisp and according to all the testimony you
  could interactively modify quite basic system behaviour. The only extant
  systems that come even remotely close would be smalltalks, but even squeak
  which is incredibly malleable and a cross-platform mini-OS in its own right
  uses the host OS for many basic tasks.


'as



More information about the Python-list mailing list