Penguin

ML is a family of StaticallyTyped functional ProgrammingLanguages with StrictEvaluation, PolymorphicTypes, HigherOrderFunctions, a higher-order module system. ML can be used interactively for learning, experimentation and testing, or it can be compiled. The two major dialects of ML are OCaml and SML. SML is a standardised language with several implementations. OCaml has a single OpenSource implementation, it extends ML with an OOP system. Both major dialects have compilers that produce native code that rival the speed of C++, and extensive standard and third-party libraries.

Why YOU want to program in ML gives you a tour of the features of ML that make it a good general-purpose programming language. It talks about SML, but what it says applies to OCaml as well.

An example of ML code:

fun interpret_functionally (program : opcode list) : unit =
  (* Interprets a parsed Brainf*ck program using integers
     on a strip of TuringMachine tape as the memory. *)
  let
    val fresh_tape = Tape.make(0)
    fun step (tape, op) =
      let byte = Tape.read(tape) in
        case op of
          Inc_ptr n => times(n, Tape.forward, tape)
        | Dec_ptr n => times(n, Tape.back, tape)
        | Inc_byte n => Tape.write(byte + n, tape)
        | Dec_byte n => Tape.write(byte - n, tape)
        | Putchar => ( putchar(byte) ; tape )
        | Getchar => Tape.write(getchar(), tape)
        | Loop body =>
            if byte = 0 then tape
            else step (step_sequence (tape, body), op)
      end
    fun step_sequence (tape, oplist) =
      List.foldl(step, tape, oplist)
  in
    ignore (step_sequence(fresh_tape, program))
  end

(This is in SML.)


CategoryProgrammingLanguages, CategoryFunctionalProgrammingLanguages