[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Emacs Lisp for script writing

From: Tim X
Subject: Re: Using Emacs Lisp for script writing
Date: Tue, 22 Dec 2009 10:06:12 +1100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (gnu/linux)

Cecil Westerhof <address@hidden> writes:

> Sam Steingold <address@hidden> writes:
>>> I already use 'emacs -batch' for scripting where no user input is used,
>>> but I would like to use it also for interactive scripting. Until now I
>>> did not find any usable information about this. Anybody using Emacs for
>>> interactive scripts?
>> I use clisp for all scripting, interactive and not.
>> Common Lisp is more powerful than Emacs Lisp and clisp is faster than
>> emacs.
> I have been experimenting with clisp. But I think that Emacs Lisp does a
> pretty good job. I translated a script I wrote in Emacs Lisp to CL. The
> Emacs Lisp version needed 51 seconds on a certain data set. When using
> clisp with the converted code, clisp needs 79 seconds. That is more as
> 50% longer.

Hi cecil,

your comparisons of speed are not really justified. Clisp is a general
purpose implementation of CL while emacs lisp is a specialised dialect
for text processing. This means that you will likely get pretty good
performance from elisp compared to clisp when using it at a novice
level.  However, as your understanding of CL and your familiarity with
clisp improve, you will get faster and faster results from clisp. 

Clisp (and most modern CL implementations) have lots of optimisation
which can be applied. In general, you don't do this until it is
necessary and until you have the algorithms worked out. There are also
many basic lisp idioms you have yet to learn that will improve both your
code readability and its performance. The good news is that it will
likely help in both your elisp and your CL (and scheme and any other
lispy language you might try). 

The performance differences you are geting now really say more about
your level of expertise with the language. It does show that with a
specialised dialect, such as elisp, the novice will likely do better
than with a general dialect, such as CL. However, depending on the
scripts and what you are doing, you will likely run into situations
where you cannot easily do with elisp what you want and you ahve to
start jumping through lots of hoops that would be much easier using a
more general dialect, such as CL. 

A possible example is prompting for user input in an elisp script. While
this is no problem when running in an interactive mode (i.e. from within
emacs), it is more difficult when running non-interactively via a batch
mode. This isn't a problem with clisp. Using emacs for scripting can
also have much longer load times, especially if your not using emacs in
server mode, compared to a natively compiled clisp program. 

At this point in your learning curve, any comparisons of performance are
very much meaningless as they are not really comparing the tehcnologies,
but rather the programmer. While you may find elisp faster and easier at
this point, you will find CL a more useful general purpose tool in the
long term. I suspect that in the end, both tools will be valuable. Which
one you use for a task will depend on the type of task. Some scripts
will be more suited for elisp and others will be more suited to CL. 

tcross (at) rapttech dot com dot au

reply via email to

[Prev in Thread] Current Thread [Next in Thread]