From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: Using Emacs Lisp for script writing Date: Tue, 22 Dec 2009 10:06:12 +1100 Organization: Rapt Technologies Message-ID: <878wcw53mj.fsf@lion.rapttech.com.au> References: <87hbrrrl3c.fsf@Traian.DecebalComp> <87vdg09ls9.fsf@Traian.DecebalComp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1261438915 2840 80.91.229.12 (21 Dec 2009 23:41:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Dec 2009 23:41:55 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 22 00:41:48 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NMrsp-0000b6-Gf for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Dec 2009 00:41:47 +0100 Original-Received: from localhost ([127.0.0.1]:53271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMrsp-0001qi-Nh for geh-help-gnu-emacs@m.gmane.org; Mon, 21 Dec 2009 18:41:47 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.kjsl.com!news.alt.net!news.astraweb.com!border2.newsrouter.astraweb.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (gnu/linux) Cancel-Lock: sha1:gbPm1+83sKTKEGdj7JbGhE1Msyo= Original-Lines: 64 Original-NNTP-Posting-Host: 731d825b.news.astraweb.com Original-X-Trace: DXC=0_K2ZkQD^:Cm=FFS; n7SGML?0kYOcDh@Jc3O Original-Xref: news.stanford.edu gnu.emacs.help:175712 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70787 Archived-At: Cecil Westerhof writes: > Sam Steingold 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. Tim -- tcross (at) rapttech dot com dot au