S-Lang (http://www.jedsoft.org/slang/) is a multi-platform programmer's library designed to allow a developer to create robust multi-platform software. It provides facilities required by interactive applications such as display/screen management, keyboard input, keymaps, and so on. The most exciting feature of the library is the slang interpreter that may be easily embedded into a program to make it extensible. While the emphasis has always been on the embedded nature of the interpreter, it may also be used in a stand-alone fashion through the use of slsh, which is part of the S-Lang distribution.
Unlike many interpreters, the S-Lang interpreter supports all of the native C integer types (signed and unsigned versions of char, short, int, long, and long long), and both single and double precision types, as well as a double precision complex type. Other data types supported by the interpreter include strings, lists, associative arrays (hashes), user-defined structures, and multi-dimensional arrays of any data-type.
The S-Lang interpreter has very strong support for array-based operations making it ideal for numerical applications. For example,
i = where (hypot(X,Y) <= 1);
X = X;
Y = Y;
is a filtering operation that removes all points from a pair of (X,Y) arrays that fall outside the unit circle. Moreover, the native support for array-based operations mean that such code will execute at the speed of compiled code even though the code is executed by the interpreter.
What's the speed like?
%
% Tested with S-Lang 1.4.9 on Slackware 10 --- http://www.s-lang.org/
%
% Feb 26, 2005 - PvE.
% Revised for GTK-server 2.0.6 at december 17, 2005
% Tested with S-Lang 2.1.4 and GTK-server 2.3.1 at december 17, 2008.
%
%--------------------------------------------------------------------
define gtk(str)
{
variable fp, buf;
fp = fopen ("/tmp/demo.sl", "a");
() = fputs (str, fp);
() = fclose (fp);
fp = fopen ("/tmp/demo.sl", "r");
() = fgets (&buf, fp);
() = fclose (fp);
return buf;
}
% Declare variables
variable WIN, TBL, BUT, LAB, EVENT;
% Start GTK-server and wait for initialization
() = system ("gtk-server -fifo=/tmp/demo.sl -detach");
% Build GUI
() = gtk ("gtk_init NULL NULL");
WIN = gtk ("gtk_window_new 0");
() = gtk ("gtk_widget_set_usize " + WIN + " 300 100");
() = gtk ("gtk_window_set_title " + WIN + " \"S-Lang with GTK\"");
() = gtk ("gtk_window_set_position " + WIN + " 1");
TBL = gtk ("gtk_table_new 20 20 1");
() = gtk ("gtk_container_add " + WIN + " " + TBL);
BUT = gtk ("gtk_button_new_with_label \"Click to Quit\"");
() = gtk ("gtk_table_attach_defaults " + TBL + " " + BUT + " 12 19 12 19");
LAB = gtk ("gtk_label_new \"S-Lang uses GTK now!!\"");
() = gtk ("gtk_table_attach_defaults " + TBL + " " + LAB + " 1 15 1 10");
() = gtk ("gtk_widget_show_all " + WIN);
% Mainloop
do {
EVENT = gtk("gtk_server_callback wait");
} while (EVENT != BUT and EVENT != WIN);
% Exit GTK-server
() = gtk ("gtk_server_exit");
% Exit
exit (0);