Survey of Emacs Lisp, Perl, Python, and Tcl

Terrence M. Brannon (brannon@jove.cs.caltech.edu)
Fri, 3 Jul 92 10:11:25 PDT

Note: this is not the Python FAQ. I am working on that next.

The purpose of this FAQ is to expose people to several languages which
can cutdown/eliminate shell programming and C programming.

All of these languages are quick interpreted languages which can do
things in a few lines which might take hundreds of lines of C/shell
code.

I tried to be objective but I have not learned Perl. I looked into Perl
but gave it up - it seemed very odd to me.

Suggestions to Terrence Brannon <brannon@jove.cs.caltech.edu>.
E-mail jbw@cs.bu.edu for details about the League for Programming Freedom.

Overview
********

Emacs Lisp
==========
Anything Emacs does is done in Lisp, so you can do it to. But you can
only do it inside of Emacs Lisp for the most part. The two work arounds
are: (1) use emacs-server.el which allows Emacs to send/receive on
sockets (2) use emacs server mode. Both are rather hairy.

Cant call from C and cant call from the shell.

Perl
====
Combines the best features of awk, sed, and shell programming. The
latest version can be embedded in C programs. It is also easy to call
from the shell.

Python
======
An object-oriented interpreted language. Callable from C as well as the
shell. Interpretation may be sidestepped through the use of the
byte-compiler on files. Python played a major role in testing Amoeba, a
distributed operating system developed at CWI.

Tcl
===
Extremely strong in X-windows. It can do a 5 page x-windows program in
*2* lines and more. Callable from C and from the shell.


File: toolkit.languages.info Node: Power, Prev: Overview, Up: Top, Next: Graphics

Power
*****

All of the systems will be evaluated in terms of their capabilities in
graphics, string handling, and process control. They will also be
evaluated in terms of their extensions.


File: toolkit.languages.info Node: Graphics, Prev: Power, Up: Top, Next: String Handling

Graphics
========

Emacs Lisp
-----------
None internally, but the ability to spawn inferior unix
processes and issue shell commands allows it to use tcl's WAFE or fire
up a Python process and control it with ease.

Perl
----
Again none interally, but it might take the same route os Emacs Lisp but
my feeling is it would be a harder task than in Emacs Lisp.

Python
------
Through the use of the STDWIN paradigm, the same source code
can do graphics in the following systems:

1. X-windows
2. Macintosh
3. Atari ST
4. DOS
5. Silicon Graphics SGI workstations

This approach allows flexibility but means that no one graphics system's
potential is maximized.

Tcl

---
Overloaded with all types of very very easy to do attractive
graphics in X-Windows only. Easy to learn, and has many nice widgets
added to it such as a photo widget for display of scanned PBM images,
a bar graph widget, an editable text widget and much more. 
Powerful tcl-based graphics systems come to mind:

1. VOGLE - 3D rendering, fonts 2. BYO Interface Builder. A snap to use. 3. WAFE . Send text string from anywhere (C language, Emacs, shell) to a server and have the graphics done for you. 4. BOS - An object oriented extension for Tcl which also has some widgets added to it.

 File: toolkit.languages.info Node: String Handling, Prev: Graphics, Up: Top, Next: Process Control

String Handling ===============

Emacs Lisp ---------- Strong. Many good string handling functions for operation on buffers as well as string. Search replace backward and forward with regexps. Many good string handling functions are found in tree-dired.el in gmhist*.el. As well as in ange-ftp.el.

Perl ---- Well, its a language optimized for this so it is good, but in some cases the lack of complex data structures is a problem. For example, even though Perl is becoming the tool of choice among system administrators, Tom Christiansen, an expert Perl programmer makes note of how the lack of complex data structures in Perl made a program to format the output of du in a tree format exceedingly difficult. This same program was done in Python in 50 lines.

Python ------ It has a string module and regexp module. It has all the string *search* capabilities of Emacs, but since strings are immutable in Python, it understandably does not have Emacs Lisp's string replace power.

Tcl

---
Everything in Tcl is a string. It is very easy to map certain
string-intensive applications to Tcl. For example, I wrote a program to
do parallel library database searches in Tcl in about two weeks. Ranking
the 4 languages in terms of how easy it would have been: Tcl, Python,
Emacs, and I cant say about Perl because I gave up on Perl quickly after
buying the book and seeing all those registers and the confusing
context-intensive syntax. 

 File: toolkit.languages.info Node: Process Control, Prev: String Handling, Up: Top, Next: Extensions

Process Control ===============

Emacs Lisp ---------- Has specialized modes for controlling Common and other lisps to facilitate debugging, execution, and programming. Has shell modes with command history. Has an excellent ftp program (ange-ftp). Can asynchronously or synchronously call the shell and store the output in a buffer or string. Can filter output from a process. However, the filtering is somewhat hairy because you cannot be sure of the packet size that the data will arrive in. In other words, it is easy to open a pipe with Perl/Python/Tcl and just read lines at a time but you have to write an accumulator function to do this in Emacs Lisp. However, the interactor mode for GNU Smalltalk has an excellent accumulator function that you could use in your own code.

Perl ---- Chat2.pl .. I dont know

Python ------ You would use pipes to do this in Python. It would be as easy as Emacs, however, so much is already written for Emacs. Python is a young language with far less supporters.

Tcl

---
Even stronger than Emacs. A package by Don Libes called Expect allows
the programmer to specify a set of expected regexps from the process and
what to do upon the receipt of the process output. Several of his papers
including Expect: Programs for Controlling Interactive Processes are
available in postscript format for anonymous ftp from durer.cme.nist.giv
in pub/expect. 

 File: toolkit.languages.info Node: Extensions, Prev: Process Control, Up: Top, Next: Documentation

Extensions ==========

An important feature of these languages is how much is already there for you to use.

Emacs Lisp ---------- Emacs is light years ahead of any of these other languages in this respect. 1. 4 mail readers (rmail, vm, mh-e, elm interface) 2. 2 Usenet news readers (gnus, rnews+) 3. Ange-FTP -- An excellent ftp utility which allows transparent file access/modification with the ease of a few keystrokes. 4. Countless interfaces for everything from Archie to MUD. 5. AUC-TeX allows you to do anything you would want to do with TeX/LaTeX from an Emacs buffer quickly and easily. 6. Calc is a poor man's Mathematica 7. VIP -- vi emulation for emacs 8. Calendar/Diary -- calendar manager within Emacs 9. Tree Dired -- better directory editor for Emacs 10. Hyperbole -- extensible hypertext management system within Emacs 11. Ispell -- spell checker in C with interface for Emacs 12. Patch -- program to apply "diffs" for updating files

Emacs' use of switchable modes allows for easy creation of new packages with their own set of keyboard macros or they can simply use a predefined mode.

Perl ---- 1. chat2pl --

Python ------ 1. ?? -- Multimedia interface. 2. ?? -- Remote Procedure Call debugger 3. texfix -- Crude convert latex to texinfo 4. throughput -- measure tcp throughput 5. dutree -- format du(1) output at a tree sorted by size 6. findlinks -- recursively find links to a given path prefix 7. lpwatch -- watch BSD line printer queues 8. suff -- sort a list of files by suffix

Tcl === 1. Basic Object System -- adds object oriented capabilities to Tcl. It is not class-based but prototype-based whatever that means. 2. CD Rom Interface 3. MXEdit -- Text editor 4. tclTCP/rawTCP -- tcp/ip for tcl remote procedure calls and connect activity 5. VOGLE -- awesome full-color 3-D rendering package with a ton of fonts, both american and foreign.

* Menu:

* Documentation:: * Top::

 File: toolkit.languages.info Node: Documentation, Prev: Extensions, Up: Top, Next: Ease of Use

Documentation *************

Emacs Lisp ========== Excellent. Both for using Emacs and programming Emacs Lisp.

Perl ==== Excellent. A book is out by Larry Wall called Programming in Perl. The 50-page man page is not bad.

Python ====== Good. Covers everything but how to extend Python through C.

Tcl === Good. The author of Tcl, John Ousterhout, will mail you the manual pages.

 File: toolkit.languages.info Node: Ease of Use, Prev: Documentation, Up: Top, Next: Extensibility

Ease of Use ***********

Emacs Lisp ========== The best. Has a debugger. Since you are in Emacs, you can immediately test whatever you are writing. Documentation on every function and variable in memory is available in 2 keypresses. The tags system allows you to jump to functions and global variable declarations without knowing which file they are in.

Perl ==== Ok. There is a Perl mode for Emacs.

Python ====== Good. You can send a buffer to a python interpreter by using Emacs.

Tcl === Ok. The language itself is straightforward. There is a tcl mode for Emacs but nothing written to allow you to send a buffer of code to the tcl interpreter. Development is still pretty fast.

 File: toolkit.languages.info Node: Extensibility, Prev: Ease of Use, Up: Top, Next: Test Suite

Extensibility *************

Emacs Lisp ========== Writing new lisp functions is only feasible by using the already-available lisp functions. To write new lisp functions in C would mean re-compiling Emacs every time.

Perl ==== Very difficult.

Python ====== Its possible in Python and C. How to do it in C is not well documented.

Tcl === Its possible in Tcl and well-docuemented and has been down well by many people in C.

 File: toolkit.languages.info Node: Test Suite, Prev: Top, Up: Top, Next: Top

Test Suite **********

Emacs Lisp ========== Well, if you compile Emacs then Emacs Lisp will run. This is irrelevant criteria for Emacs Lisp.

Perl ==== Assorted programs here and there.

Python ====== Exhaustive test suite

Tcl === Exhaustive test suite