0. Introduction


An introduction to Lush and its capabilities and features is presented in this section.



0.0. Lush Revealed


Lush is an object-oriented programming language with features designed to please researchers, experimenters, and engineers interested in large-scale numerical and graphical applications. It is designed to be used in situations where one wants to combine the flexibility of a high-level, loosely-typed interpreted language, with the efficiency of a strongly-typed, natively-compiled language, and easy integration with code written in C, C++, or other languages.

The advantages of Lush are especially significant on projects where a combination of an interpreted language (e.g.Python, Perl, Matlab, S+, or even [gasp!] BASIC) and a compiled language (e.g. C) would otherwise be used. With Lush the best of both the interpreted and compiled programming worlds are obtained by wrapping three languages into one:

It sounds complicated, but it is not. In fact, Lush is designed to be very simple to learn and to use.

The main features of Lush include:

This combination of flexibility, efficiency, and extensive libraries makes Lush an ideal platform for research and development in artificial intelligence, bio-informatics, computer vision, data mining, image processing, machine learning, signal processing, and statistics, Its speed and extensive libraries allow it to be applied to areas such as real-time audio, image, and video processing. Many users put Lush to work as a general purpose scripting language or as their main language for application development. Some users are known to have used Lush to develop 2D and 3D games. A few have even used Lush to develop commercial software for embedded processors.

In comparison to Matlab, Lush is a "real" object-oriented programming language with data structures, typed matrices, simple syntax, and a native compiler. Compared to Python, Lush has an efficient native compiler (compiled numerical code is as fast as C) and provides a functional programming paradigm. The ability in Lush to easily call C libraries and freely mix C and Lisp together is unique.

If at any time you have:

then Lush is for you!

Many software projects, particularly research projects, require two languages: an efficient compiled language, such as C or C++, for implementing the low-level or computationally expensive functions, and a flexible (possibly interpreted) language for high-level control, scripting, experimentation, and tinkering. Popular research-oriented interpreters like Matlab are somewhat inefficient, have little or no support for complex data structures, do not provide the power of a full-fledged object-oriented programming language, and lack simple interfacing functionality to C and other compiled languages.

The syntax of Lush is a simple form of Lisp. If the word "Lisp" sends shivers down your spine, be advised that the dialect of Lisp that Lush implements is extremely simple to learn, with one of the simplest syntaxes possibly available. Most scientists, engineers, and software developers who learn Lush become proficient with it in just a few short days, even if they have had no prior exposure to Lisp. It's very simple. Really. In fact, Lush has been used to teach programming to kids!

The Lush compiler has several interesting properties (and a few limitations). Its main advantage is that it generates very efficient C code that is compiled with the best available C compiler for the machine under consideration.

Lush currently runs on various Unix platforms including: Linux/x86, Solaris, and SGI/Irix. It can also be run on Mac OS X and Windows (under Cygwin).



0.1. Features


Lush is built around a compact, portable, and intentionally simple Lisp interpreter written in C. It features all the usual functionality and constructs found in every decent object-oriented programming language such as conditional statements, loops, local variables, functions, macros, objects, classes, methods, and inheritance. In addition it also provides a large number of functions for manipulating lists, strings (including regular expression matching and substitutions), vectors, matrices, and tensors.

The Lush interpreter is quite similar to some lisps of the mid 1980's like Le_Lisp and UCI-Lisp. It is significantly simpler than Common Lisp and very different than Scheme.

Some unusual features of Lush are its compiler to C, dynamic loader, and the ease with which interfacing to existing C functions and libraries can be accomplished. A particularily unusual feature is the language facility it provides to intermix Lisp and C source code within a single function.

The vector and matrix manipulation engine is quite powerful and efficient. This makes Lush ideal for computationally demanding numerical applications and signal and image processing. Functions are included to create, resize, and convert vectors, matrices, and tensors with up to eight dimensions. Basic matrix operations such as scalar operations (on all elements of a matrix), dot products, outer products, transpositions, highly optimized 1D and 2D convolutions are, of course, included. A set of iterators is also provided to access any matrix element without requiring costly bounds checking.

As an object-oriented language, Lush provides the ability to define and compile classes with slots and methods, and for derived classes to inherit the slots and methods of their parent class (similar to C++ semantics).

All the functions familiar to Lisp enthusiasts are included in Lush. These include: list functions, list iterators, physical list manipulators, macros, splicing macros, symbol manipulators, and so on. Most casual users will probably prefer to stay away from some of the more complicated of these.

A set of simple-to-use graphics functions are supplied to draw lines, polygons, rectangles, pictures, and text in color, with automatic refresh and double-buffering capability (for simple animations). Graphics can be drawn in an X Windows system window (on Unix) or sent to a PostScript file. The low-level portable graphics functions provided are used to build high-level functionalities, such as function plotting.

There is also a very compact and easy-to-use object-oriented graphical user interface (GUI) generator called Ogre that comes with Lush. Ogre is entirely written in Lisp on top of the low-level graphics functions mentioned above. It contains predefined classes for buttons, sliders, radio buttons, menus, string editors, and so forth. Ogre includes an automatic mechanism for placing objects in a window, thereby greatly simplifying the design and implementation of GUIs. Simple GUIs can be written in extremely short times and are very compact.

Lush provides two models for input and output. One is a set of Lisp-oriented functions that allows easy input and output of ASCII data, lisp expressions, lisp objects, and matrices. It includes goodies such as pipes and sockets. The other model essentially provides access to the standard C I/O library, including fopen, popen, fprintf, fscanf, fgetc, fputc, fgets, and various functions for reading and writing matrices. With these functions large matrices can be mapped into the virtual addressing space, instead of being explicitely loaded into memory. This allows efficient access of very large datasets.



0.2. Libraries


A huge collection of libraries and utilities are available to the user in Lush. Some of these are written in Lisp, some in C and interfaced to Lush, while others are pre-existing libraries that have been interfaced to Lush.

For our numerically enclined friends, Lush has a full interface to the GNU Scientific Library (GSL), and LAPACK and BLAS Linear Algebra libraries. This gives access to an extensive set of numerical and statistical functions (several thousand in fact).

A full interface to the industry-standard OpenGL library that enables the creation of 3D graphics and animations is provided. This interface itself includes an interface to GLUT, OpenGLU, and OpenRM (scene graph rendering engine). This feature makes Lush an excellent platform to write interactive VR applications and computer games in.

Another popular library interfaced to Lush is the Simple Directmedia Layer (SDL) video game API. This is enhanced by a high-level library that allows easy manipulation of sprites and movable screen objects with pixel-accurate collision detection. The library, combined with Lush's simple syntax, is ideal for developing simple video games and teaching programming to children.

An image processing library with functions to load, save, resize and resample, warp, filter, and analyze images is also at the users disposal. Mathematical morphology operations such as connected component analysis, distance transform, erosion, and dilation, are also available for bitonal images. Classes and functions for easily grabbing video using the Video4Linux API is included also.

Another included library provides graph functionality that allows grammar and finite state machine construction, graph transduction and composition, and viterbi search algorithm.

Lush includes an extensive library for gradient-based machine learning, including neural networks, radial basis functions, support vector machines, and many others. This library is based on an innovative object-oriented design that facilitates the construction of large learning machines from multiple learning modules and cooperative learning machine training. Commercially used optical recognition systems have been built with this library.

In addition, Lush provides various interfaces to multimedia libraries, including Video4Linux (video grabbing) and ALSA (audio recording/playing).



0.3. Application Areas


Lush is a good tool for a variety of applications. It was originally developed as an environment for experimentation and development of machine learning, neural nets, and pattern recognition applications, but over the years it has grown into a full-fledged language and rapid development environment.

Here are examples of situations in which Lush (or its predecessor SN) have been used:

Here is a small subset of the research projects that have been carried out with Lush:

A few full-fledged commercial applications have also been built with Lush, including:



0.4. Implementation


The Lush programming language has been implemented as a variation of Lisp.

In some segments of the software industry Lisp is sometimes perceived as an oddity of essentially academic interest. Its theoretical computer science heritage also causes common misconceptions about Lisp, such as it being inefficient and difficult to learn. So why choose Lisp? We chose Lisp because, contrary to the common prejudice, it is extremely easy to learn, in addition to being flexible, efficient, and compact. Lisp has such a simple, clean, and flexible syntax that it is probably the easiest language to learn (in contrast, Perl is found at the other extreme). Our experience with teaching C developers to use Lush is that they become proficient with it in a few days. Script language designers often make the mistake of not only designing their own language functionalities, but also of designing their own syntax. Examples of this include MatLab, Mathematica, S+, and many others. Why invent a new syntax when a good one such as Lisp already exists? Lush is just such a language, it is an object-oriented dialect of Lisp that puts the emphasis on ease of use, efficiency for numerical operations (unlike many traditional Lisp implementations), and close to effortless interfacing with existing code written in C.

Another unique advantage of Lisp is that it is a programable programing language. In Lisp, a program is just a data structure that can be created and manipulated just like any other data structure. In other words, Lisp programs can create other Lisp programs. This allows users (and not just language designers) to extend the language themselves without limit. This feature also makes it easy to write such things as syntax transformers, self-optimizing programs, compilers, automatic differentiators, etcetera. Most users will probably stay away from writing such things, but they will profit from the work of others in these areas (e.g. the CLush compiler).



0.5. History


Lush is the direct descendent of the SN system, originally developed by Leon Bottou and Yann LeCun, that was the front-end of a neural network simulator. Various incarnations of SN have been developed continuously since 1987, some of which were sold commercially by Neuristique S.A. in France, and eventually grew into a full-fledged prototyping and development environment.

Versions developed at AT&T Bell Labs, and then at AT&T Labs and at the NEC Research Institute were used to build many succesful technologies and products. The most notable ones are:

SN was primarily used internally at AT&T Bell Labs for many research projects in machine learning, pattern recognition, and image processing. But its various incarnations were used at AT&T Labs, Lucent, the Salk Institute, the University of Toronto, Universite de Montreal, UC Berkeley, and many other research institutions. The commercial versions of SN were used in several large companies as a prototyping tool: Thomson-CSF, ONERA,....

Contributors include: Leon Bottou, Yann LeCun, Jie Huang Fu, Patrice Simard, Yoshua Bengio, Jean Bourrelly, Patrick Haffner, Pascal Vincent, Sergey Ioffe, and many others.

In 2001, AT&T and Neuristique released their respective versions under the GPL, allowing the development and distribution of Lush. Turning SN into Lush was done by Yann LeCun, Leon Bottou and Jie Huang-Fu at the NEC Research Institute.

Here is a family tree of the various incarnations of SN and Lush:


SN(1987) neural network simulator for AmigaOS (Leon Bottou, Yann LeCun)
 |
SN1(1988) ported to SunOS. Added shared-weight neural nets and graphics (LeCun)
 |   \
 |   SN1.3(1989) commercial version for Unix (Neuristique)
 |   /
SN2(1990) new lisp interpreter and graphic functions (Bottou)
   |   \
   |   SN2.2(1991) commercial version (Neuristique)
   |    |
   |   SN2.5(1991) ogre GUI toolkit (Neuristique)
   |   / \
    \ /  SN2.8(1993+) enhanced version (Neuristique)
     |     \
     |   TL3(1993+) lisp interpreter for Unix and Win32 (Neuristique)
     |      [GPL]
     |        \_______________________________________________
     |                                                        |
   SN27ATT(1991) custom AT&T version                          |
     |        (LeCun, Bottou, Simard, AT&T Labs)              |
     |                                                        |
   SN3(1992) IDX matrix engine, Lisp->C compiler/loader and   |
     |       gradient-based learning library                  |
     |       (Bottou, LeCun, AT&T)                            |
     |                                                        |
   SN3.1(1995) redesigned compiler, added OpenGL and SGI VL   |
     |         support (Bottou, LeCun, Simard, AT&T Labs)     |
     |                                                        |
   SN3.2(2000) hardened/cleanup SN3.x code,                   |
     |         added SDL support (LeCun)                      |
     | _______________________________________________________|
     |/
     |
   ATTLUSH(2001) merging of TL3 interpreter + SN3.2 compiler
   [GPL]         and libraries (Bottou, LeCun, AT&T Labs).
     |
   LUSH(2002) rewrote the compiler/loader (Bottou, NEC Research Institute)
   [GPL]
     |
   LUSH(2002) rewrote library, documentation, and interfaced packages
   [GPL]      (LeCun, Huang-Fu, NEC) 
     |