Updated 2014-04-27 21:10:41 by SEH

The ML family of programming languages are statically-typed (with type-inference), strict, impure functional programming languages. Typically these languages are good at symbol manipulation (e.g., they make great languages for implementing compilers etc) and general algorithmic work. ML dates back to the 1970's when it was created as the Meta-Language for the Edinburgh LCF theorem-prover. It can run with similar performance to C in some situations, but includes many higher level features such as garbage collection, type inference (i.e., the compiler will deduce what types terms should have rather than you having to explicitly annotate them), and pattern matching. See [1] for a brief summary of Standard ML features. There are various dialects of ML in addition to Standard ML, such as OCaml which adds OO capabilities, and Alice ML [2] which adds support for (declarative) concurrency and type-safe distributed programming.

An example SML program (here defining a complex number type) is:
 structure Complex =
 struct
     type t        = real * real;
     val  zero     = (0.0, 0.0);
     val  i        = (0.0, 1.0);
     fun  sum   ((x, y), (x', y')) = (x+x', y+y') : t;
     fun  diff  ((x, y), (x', y')) = (x-x', y-y') : t;
     fun  prod  ((x, y), (x', y')) = (x*x' - y*y', x*y' + x'*y) : t;
     fun  recip ((x, y), (x', y')) = let val t = x*x' + y*y'
                                     in  (x/t, ~y/t) end;
     fun quo    (z, z')            = prod(z, recip z');
 end;
 val a = (0.3, 0.0);
 val b = Complex.sum(a, Complex.i);
 val c = Complex.sum(b, (0.7, 0.0));
 val d = Complex.prod(c, c);

sml_tk is a Standard ML package providing a portable, typed and abstract interface to the user interface description and command language Tcl/Tk. It allows the implementation of graphical user interfaces in a structured and reusable way, supported by the powerful module system of Standard ML.