| ![]() | |||||||||
use the shorter name ML," which may refer either to Standard ML in particular or to the generic family of ML languages according to the context.
2 Why Standard ML Works
Here is an enumeration of some of the major strengths of Standard ML from the view of a user of the language. Not surprisingly, many of these points parallel those mentioned in Appel's critique ([3]).
A high-level programming model. A high-level model makes programming more efficient and more reliable by automating and suppressing many low level details such as memory management and data formating. Standard ML's programming model is based on the functional programming paradigm, which derives from the lambda calculus.
Safety. ML's type system, memory management system, and exception facilities combine to guarantee that even buggy ML programs do not crash" (i.e., fail catastrophically due to some corruption of the computational state or inappropriate manipulation of data). It is possible for a program to fail because an ML exception is raised and never handled. In the interactive system this returns one to top-level, but in a stand-alone program it terminates the program abnormally. It is, of course, also possible for an ML program to produce the wrong result because of a bug, or to fail to terminate.
Security and robustness. Static type checking detects many errors at compile time. Error detection is enhanced by the use of pattern matching, which helps ensure coverage of all cases because the compiler can statically detect and report incomplete matches, and by the exception mechanism, which provides a type-secure, disciplined way to deal with potential runtime exceptions. The result is that unexpected runtime errors can be largely avoided or dealt with appropriately.
Expressiveness and conciseness. The ability to treat functions as first-class values, the use of higher-order functions to express a wide range of control structures, the use of pattern matching for concise analysis of data, and the availability of imperative constructs provide great expressive power within a simple and uniform conceptual framework. The combination of state and higher-order functions is very powerful, but can cause difficulties in specifying and reasoning about programs (as in object-oriented programming).
Flexible strong typing. The ML type system is simple, uniform,1 flexible, and sound. The flexibility is achieved through the use of parametric polymorphism. New types can be defined to match precisely the requirements of a problem, and data abstraction (i.e., hiding of data representations) is well supported. Automatic inference of most general type schemes streamlines interactive programming. Type checking provides security by detecting statically a large fraction of common mistakes. But perhaps the most valuable aspect of the type system is that it provides a language for designing and expressing data representations and program interfaces and then automatically enforces their proper use through type checking.
1 Any type constructor can be applied to any types without restriction { all types are treated equally. Also, user-defined types are treated the same as primitive types.