The S-Lang programming library is a
software library
In computing, a library is a collection of resources that can be leveraged during software development to implement a computer program. Commonly, a library consists of executable code such as compiled functions and classes, or a library can ...
for
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
,
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
,
VMS,
OS/2
OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
, and
Mac OS X
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
. It provides routines for embedding an
interpreter
Interpreting is translation from a spoken or signed language into another language, usually in real time to facilitate live communication. It is distinguished from the translation of a written text, which can be more deliberative and make use o ...
for the S-Lang
scripting language
In computing, a script is a relatively short and simple set of instructions that typically automation, automate an otherwise manual process. The act of writing a script is called scripting. A scripting language or script language is a programming ...
, and components to facilitate the creation of
text-based
In computing, text-based user interfaces (TUI) (alternately terminal user interfaces, to reflect a dependence upon the properties of computer terminals and not just text), is a retronym describing a type of user interface (UI) common as an ear ...
applications. The latter class of functions include routines for constructing and manipulating keymaps, an interactive line-editing facility, and both low- and high-level screen/terminal management functions. It is distributed under the terms of the
GNU General Public License
The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
.
Brief history
The S-Lang programming library was started in 1992 by John E. Davis, considering that functions he wrote for a text editor might be useful in other programs. The earliest version of the library contained input/output routines for interacting with computer terminals and an implementation of a simple stack-based interpreter with a
PostScript
PostScript (PS) is a page description language and dynamically typed, stack-based programming language. It is most commonly used in the electronic publishing and desktop publishing realm, but as a Turing complete programming language, it c ...
-like syntax that he developed for use in a scientific plotting program. The
JED text editor was the first program to both embed the interpreter and use the terminal I/O components of the library.
Interpreter
The interpreter makes up most of the S-Lang library, and is also where most of the development takes place. Although the original syntax supported by the interpreter resembled PostScript, the syntax has evolved to be much more C-like, with additional support for object-oriented style constructs. As a reflection of Davis's background in physics and professional interest in scientific computing, the language natively supports many vectorized array-based operations similar to
MATLAB
MATLAB (an abbreviation of "MATrix LABoratory") is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementat ...
and
IDL.
Until version 2.0, the interpreter was not a standalone program. Instead, Davis advocated embedding it into applications to make them extensible. Using the interpreter meant either embedding it in a C program, or using it in the context of another application (e.g., the
JED editor). The S-Lang shell, slsh, was a demonstration program capable of little more than running scripts. Version 2.0, released in 2005, made slsh interactive, and it has evolved into an application in its own right, with a number of external modules for use by it. As such, it has become the S-Lang interpreter.
Screen management
In the mid-1990s while porting the
sc spreadsheet to the S-Lang library, Davis developed the library's screen management facility. This component was designed to optimize screen output (by minimizing the number of characters sent to the terminal), and provide a simple way to support a variety of terminals through an extra layer of abstraction between the application code and the terminal. The
slrn
slrn is a Console application, console-based news client for multiple operating systems, developed by John E. Davis and others. It was originally developed in 1994 for Unix-like operating systems and OpenVMS, VMS, and now also supports Microsoft ...
newsreader was the first application to make full use of this interface. Since then, a number of other programs (e.g.,
Mutt) have taken advantage of this feature of the library, and it has become arguably the most used aspect of the library, as this component is considered to be an alternative to
curses
A curse (also called an imprecation, malediction, execration, malison, anathema, or commination) is any expressed wish that some form of adversity or misfortune will befall or attach to one or more persons, a place, or an object. In particular ...
.
[''Linux application development'', by Michael K. Johnson and Erik W. Troan, Addison-Wesley, 2005, , p513] Since version 2.0, the screen management routines have had transparent support for
UTF-8
UTF-8 is a character encoding standard used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode Transformation Format 8-bit''. Almost every webpage is transmitted as UTF-8.
UTF-8 supports all 1,112,0 ...
.
Example source code
#! /usr/bin/env slsh
% The program below solves the following problem:
% Sort an input file that consists of lines like this
%
% var1=23 other=14 ditto=23 fred=2
private variable Keys, Values;
private define sort_fun (i, j)
define slsh_main ()
See also
*
ncurses
References
External links
S-Lang Library Information Page by John E. Davis
S-Lang Releases
{{DEFAULTSORT:S-Lang (Programming Library)
S-Lang
Text user interface libraries
Unix programming tools