Languages Features Calendar About Lists Add Language
GitHub icon



OCaml is a programming language created in 1996 by Xavier Leroy.

OCaml ( oh-KAM-əl), originally named Objective Caml, is the main implementation of the programming language Caml, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy, Ascánder Suárez and others in 1996. A member of the ML language family, OCaml extends the core Caml language with object-oriented programming constructs. OCaml's toolset includes an interactive top-level interpreter, a bytecode compiler, a reversible debugger, a package manager (OPAM), and an optimizing native code compiler. Read more on Wikipedia...

Try now: Riju · TIO

#46on PLDB 26Years Old 3.3kUsers

Example code from Riju:

;; print_string "Hello, world!\n"

Example code from hello-world:

print_string "Hello World\n"

Example code from the Hello World Collection:

(* Hello World in OCaml *) print_string "Hello World!\n";;

Example code from Linguist:

(* * Copyright (c) 2013 Jeremy Yallop. * * This file is distributed under the terms of the MIT License. * See the file LICENSE for details. *) let string_of format v = let buf = Buffer.create 100 in let fmt = Format.formatter_of_buffer buf in begin format fmt v; Format.pp_print_flush fmt (); Buffer.contents buf end

Example code from Wikipedia:

fun x_1 -> (x_1 * let y_3 = let y_2 = (x_1 * 1) in (y_2 * y_2) in (y_3 * y_3))

Keywords in OCaml

as assert begin class constraint do done downto else end exception external false for fun function functor if in include inherit initializer lazy let match method module mutable new object of open private raise rec sig struct then to true try type value val virtual when while with

Language features

Feature Supported Example Token
Binary Literals
While Loops
Booleans true false
Print() Debugging print_string
MultiLine Comments
(* A comment
(* *)
Module Pattern
(* In OCaml, every piece of code is wrapped into a module. *)
(* *)
let hello () = print_endline "Hello"
(* *)
Amodule.hello ()
Multiple Inheritance
(* This is a single-line comment. *)
(* This is a
 * multi-line
 * comment.
Semantic Indentation ϴ
Line Comments ϴ

Trending OCaml repos on GitHub

repo stars description
coq 2275 "Coq is a formal proof management system. It provides a formal language to write mathematical definitions executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs."
pyre-check 2985 Performant type-checking for python.
ocaml 2473 "The core OCaml system: compilers runtime system base libraries"
flow 19958 Adds static typing to JavaScript to improve developer productivity and code quality.
infer 10169 "A static analyzer for Java C C++ and Objective-C"

Books about OCaml on goodreads

title author year reviews ratings rating
Real World OCaml: Functional programming for the masses Yaron Minsky 2013 7 88 4.28
Unix System Programming in OCaml Xavier Leroy 1994 0 1 4.00
Apprendre à programmer avec OCaml Sylvain Conchon 2014 0 1 4.00
Using, Understanding, and Unraveling The OCaml Language: From Practice to Theory and vice versa Didier Rémy 0 1 5.00
Apprendre à programmer avec OCaml: Algorithmes et structures de données (Noire) Jean-Christophe Filliatre 0 0 0.0

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub