0. Introduction to Lush




0.0. What is Lush


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

Lush can be used advantageously for projects where one would otherwise a combination of an interpreted language like Python , Perl , Matlab , S+ , or even (gasp!) BASIC , and a compiled language like C. Lush brings the best of both worlds by wrapping three languages into one: (1) a loosely-typed , garbage-collected , dynamically scoped , interpreted language with a simple Lisp-like syntax , (2) a strongly-typed , lexically-scoped compiled language that uses the same Lisp-like syntax , and (3) the C language , which can be freely mixed with Lush code within a single program , even within a single function. It sounds complicated , but it is not. In fact , Lush is designed to be very simple to learn and easy to use.

Lush's main features are as follows:

This combination of flexibility , efficiency , and extensive libraries makes Lush an ideal platform for research and development in signal processing , image processing , machine learning , computer vision , bio-informatics , data mining , statistics , and artificial intelligence. Its speed and extensive libraries allow such things as real-time sound , image , and video processing. Many use Lush as a general purpose script language , or as a general language for application development. Some have been known to use Lush to develop 2D and 3D games. A few have even used Lush to develop commercial software for embedded processors.

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

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 function , and a flexible , possibly interpreted language for high-level control , scripting , experimentation , and tinkering. Popular research-oriented interpreters such as Matlab are somewhat inefficient , lack support for complex data structures , lack the power of a full-fledged object-oriented programming language , and lack simple interfacing to C and other compiled languages.

Lush uses a very simple Lisp syntax. 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 possibly one the simplest syntax around. Most scientists , engineers , and software developers who have learned Lush have become proficient at it in a few days , even if they 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 generate very efficient C code which is then compiled with the best available C compiler for the machine considered.

Lush Currently runs on various Unix platforms including Linux/x86 , Solaris , and SGI/Irix.



0.1. A tour of the features


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

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

An unusual feature of Lush is its compiler to C , its dynamic loader , and the ease with which one can interface existing C functions and libraries. En even more unusual feature is the ability to intermix Lisp and C source code within a single function.

The vector and matrix manipulation engine is quite powerful and efficient , making Lush ideal for heavy numerical applications and applications such as signal and image processing. It includes functions to create , resize , and convert vectors , matrices , and tensors with up to eight dimensions. It includes basic matrix operations such as scalar operations on all elements of a matrix , dot products , outer products , transposition , highly optimized 1D and 2D convolutions. A set of iterators is also provided to access all matrix elements without requiring costly bound checking.

Lush is an object-oriented language. Classes with slots and methods can be defined and compiled. Derived classes inherit the slots and methods of their parent class (similar to the C++ semantics).

Lush includes all the functions familiar to Lisp aficionados , such as list functions , list iterators , physical list manipulation , macros , splicing macros , symbol manipulation , etc , but most casual users will probably prefer to stay away from those.

Lush provides a set of simple-to-use graphic functions 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 window (on Unix) , or sent to a PostScript file. Those low-level portable graphic functions are used to build high-level functionalities , such as function plotting.

Lush also contains a very compact and easy-to-use object-oriented graphical user interface generator called ``Ogre''. Ogre is entirely written in Lisp on top of the low-level graphic functions mentioned above. It contains predefined classes for buttons , sliders , radio buttons , menus , string editors , etc... Ogre includes an automatic mechanism for placing objects in the 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/Output. One is a set of ``Lispy'' I/O functions that allow easy input and output of ASCII data , lisp expressions , lisp objects , and matrices. It includes such goodies 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. Large matrices can be mapped in the virtual addressing space , instead of explicitely loaded in memory. This allows to access very large datasets efficiently.



0.2. A tour of the Lush Libraries


Lush has a huge collection of libraries and utilities available to the user. Some are written in Lisp , some are written in C and interfaced to Lush , 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 to the LAPACK and BLAS Linear Algebra libraries. This gives access to an extensive set of numerical and statistical functions (several thousand in fact).

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

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

Lush contains a library of image processing functions to load , save , resize and resample , warp , filter , and analyze images. Mathematical morphology operations such as connected component analysis , distance transform , erosion , and dilation , are also available for bitonal images. It also includes classes and functions for easily grabbing video using the Video4Linux API.

Lush includes a graph library 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 allows to build large learning machines out of multiple learning modules and to train them cooperatively. 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. Why 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 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 (at the other extreme , you will find Perl). Our experience with teaching C developers to use Lush is that they become proficient at it in a few days. Script language designers often make the mistake of not only designing their own language functionalities , but also 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 an object-oriented dialect of Lisp that puts the emphasis on ease of use , efficiency for numerical operations (unlike many traditional Lisp implementations) , and easy 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 ad infinitum. This feature also makes it easy to write such things as syntax transformers , programs that optimize themselves , compilers , automatic differentiators , etc. Most users will probably stay away from writing such things , but they will profit from the work of others in these areas (the CLush compiler is an example).



0.5. History of Lush


Lush is the direct descendent of the SN system which was originally developed by Leon Bottou and Yann LeCun as 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.

The 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 of 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) 
     |



0.6. What is Lush good for?


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 done with Lush:

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