Standard ML is a high-level functional language with type inference.
Standard ML
Standard ML is a polymorphic high-level functional language with compile-time type checking and type inference. It is a strict language with immutable data types, updateable references, abstract data types and parametric modules. It has a proper module system that provides a powerful mechanism for creating, using and reusing programming abstractions, unlike Haskell who's "[...] module system serves primarily as a mechanism for namespace management [...]"(A Formal Specification of the Haskell 98 Module System). It has efficient implementations (approaching that of C) and a formal definition with a proof of soundness.
History
The first version of Standard ML was proposed in 1983 and designed in 1984-88 with the definition being published in 1990, thus also named SML '90.
A revised definition was published in 1997, which came with some simplifications and the addition of the SML Basis Library (see below).
For more information see History of Standard ML
Implementations
There are multiple implementations
Standard ML of New Jersey
- The most popular implementation
- Abbreviated SML/NJ
- Written in Standard ML (except for the runtime system, which is written in C)
- Uses Matthias Blume's Compilation Manager, CM, to greatly simplify the development of large software projects.
- A variety of general-purpose data structures, algorithms and utilities (such as finite sets and maps, regular expressions, pretty-printing) are provided by the SML/NJ library.
- Concurrent programming in SML is supported by the Concurrent ML library.
Moscow ML
- Implementation based on code from Caml Special Light
MLton
- Compiler that uses whole-program optimisation (i.e., there is no interpreter)
- Supports ML Basis Files, to compile large programs
- Their site (the homepage is one big "wiki") contains some pretty awesome insights, code and general comments on SML
PolyML
- Compiler and library written in Standard ML, runtime system written in C++
- Includes a source-level debugger
- Supports multicore hardware: ML threads and parallel GC
- Supports modern IDEs (compiler messages, inferred types, goto definitions, identifier scopes, completion etc.)
ML Kit
- Uses region analysis for memory management.
- Supports ML Basis Files, to compile large programs
- Efficient compilation of modules by using a compilation scheme called Static Interpretation, which eliminates modules entirely at compile time.
- Includes a graphical region profiler, which helps gain detailed control over memory reuse
HaMLet
HaMLet is a faithful and complete implementation of the Standard ML programming language (SML'97). It aims to be:
- an accurate reference implementation of the language specification,
- a platform for experimentation with the language semantics or extensions to it,
- a useful tool for educational purposes.
MLj
MLj is a compiler for Standard ML which produces Java bytecodes.
MLtoJs
It's a compiler from Standard ML to JavaScript, which allows programmers to enjoy the power of Standard ML static typing, higher-order functions, pattern matching, and modules for programming client-side web applications.
MLWorks
MLWorks is a Standard ML compiler and development environment.
CakeML
A verified implementation of a significant subset of Standard ML.
SML#
ML# is a new programming language in the Standard ML family being developed at RIEC (Research Institute of Electrical Communication), Tohoku University . Its design goal is to provide practically important extensions while maintaining the compatibility of the Definition of Standard ML.
Manticore
Manticore is a high-level parallel programming language aimed at general-purpose applications running on multi-core processors. Manticore supports parallelism at multiple levels: explicit concurrency and coarse-grain parallelism via CML-style constructs and fine-grain parallelism via various light-weight notations, such as parallel tuple expressions and NESL/Nepal-style parallel array comprehensions.
SML Basis Library
The SML Basis Library provides interfaces and operations for basic types, such as integers and strings, support for input and output (I/O), interfaces to basic operating system interfaces, and support for standard datatypes, such as options and lists. The Library does not attempt to define higher-level APIs, such as collection types or graphical user-interface components. These APIs are left for other libraries.
The most recent version of the Basis Library (signature) specification is available at http://www.standardml.org/Basis/. Clarifications, corrections and additions are sometimes done.
Getting started
Download one of the implementations mentioned above.
Check out these Stack Overflow questions with links to popular websites, books, and tutorials:
- Have fun, and ask questions!
Examples
Factorial:
fun factorial 0 = 1
| factorial n = n * factorial (n - 1)
Printing text
val _ = print "Hello, world!\n"
Books
- Elements of ML Programming
- ML for the Working Programmer
- Introduction to Programming Using SML
- The Little MLer
- The Definition of Standard ML
- Concurrent Programming in ML
- Purely Functional Data Structures