Re: What are the relative advantages of Python and Tcl?

Mon, 4 Apr 1994 01:45:43 GMT

In article <> (Ty Sarna) writes:
Ignoring Tk, Tcl has two features that Python and Perl can't compete
- Tcl is *incredibly* easy to embed and extend. This after all is
Tcl's main goal in life. Neither Perl nor Python could be made to
embed this easily, since they're richer languages and demand a more
complex interface to their internals.

I just want to add another fly in the ointment. Have you looked at S-Lang? I
claim that it is easier than TCL to embed into a C program. Here is a
description of S-Lang and details about where to get it:

The latest version of my C-like interpreter S-Lang is available. UNIKE
FEE OR ROYALTY. Details on where to ftp S-Lang from is presented below.

What is S-Lang? S-Lang is a very powerful stack based embedded interpreter
with a C-like language interface. This means that you can embed S-Lang into
your C program to give it a powerful scripting language with a friendly syntax
that resembles C. For example, here is a S-Lang function that computes that
the of a matrix:

define matrix_trace (a, n)
variable i, sum = 0;

if (n <= 0) error ("matrix_trace: n is less than 0");

for (i = 0; i < n; i++) sum += a[i, i];
return sum;

Unlike alot of embedded interpreters currently freely available, S-Lang has a
familiar syntax for C programmers. It supports integer, string, and floating
point variable types. There is no need to worry about malloc/free or garbage
collection; S-Lang takes care of all of that, e.g.,

define three_string_cat (s1, s2, s3)
return strcat (s1, strcat (s2, s3));

print (three_string_cat ("Hello", "World", "!!!"));

Since S-Lang has builtin support for integer and floating point numbers, it is
much faster at doing arithemetic operations than interpreters which represent
everything in terms of strings (e.g., TCL).

S-Lang also supports automatic function loading. Consider the following
example from the JED editor which embedds S-Lang as its extension language.
JED has an info program written entirely in S-Lang which is roughly about 1000
lines long and is kept in a file called `'. JED's info mode is rarely
used and it does not make any sense to load it everytime the editor is used.
Instead, JED simply includes the line:

autoload ("info_mode", "");

in its main startup script. This tells the interpreter that if any function
tries to execute `info_mode', it must first be loaded from the file `'.

Since S-Lang was conceived from the start to be embedded into a C program, it
is very easy to incorporate S-Lang into your C program. In fact, independent
one review of various freely available interpreters posted on comp.lang.misc
mentioned that S-Lang was the easiest to embed (the review compared perl,
elisp, python. tcl, and S-Lang).

You can get S-Lang via anonymous ftp from in pub/slang.
Alternatively, S-Lang comes bundled as part of the JED editor distribution
which is in pub/jed. If you intend to incorporate S-Lang into your programs,
I encourage you to get the JED distribution since it is the largest program
available to embed S-Lang, including nearly 10,000 lines of S-Lang code, and
it makes a nice environment for developing S-Lang applications.

#___/John E. Davis\_________________________________________________________
# internet:
#   bitnet: davis@ohstpy
#   office: 617-735-6746