Languages Features Creators CSV Resources Challenges Add Language
GitHub icon

OCaml

OCaml - Programming language

< >

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

#69on PLDB 27Years Old 3.3kUsers
11Books 14Papers 27kRepos

Try now: Riju · TIO

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...


Example from Compiler Explorer:
let square x = x * x
Example from Riju:
;; print_string "Hello, world!\n"
Example from hello-world:
print_string "Hello World\n"
(* Hello World in OCaml *) print_string "Hello World!\n";;
Example 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 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 Token Example
Binary Literals ✓
Integers ✓
Floats ✓
Hexadecimals ✓
Octals ✓
Conditionals ✓
Functions ✓
Classes ✓
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. *)
(* amodule.ml *)
let hello () = print_endline "Hello"
(* bmodule.ml *)
Amodule.hello ()
Type Inference ✓
Multiple Inheritance ✓
Comments ✓
(* This is a single-line comment. *)
(* This is a
 * multi-line
 * comment.
 *)
Case Insensitive Identifiers X
Semantic Indentation X
Line Comments X

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

Books about OCaml from ISBNdb

title authors year publisher
Concepts and Semantics of Programming Languages 1: A Semantical Approach with OCaml and Python Hardin, The¿re¿se and Jaume, Mathieu and Pessaux, François and Viguie Donzeau-Gouge, Ve¿ronique 2021 Wiley-ISTE
OCaml Scientific Computing: Functional Programming in Data Science and Artificial Intelligence (Undergraduate Topics in Computer Science) Wang, Liang and Zhao, Jianxin and Mortier, Richard 2022 Springer
Practical OCaml Smith, Joshua B. 2006 Apress
Practical OCaml Joshua B. Smith 20080103 Springer Nature
OCaml Scientific Computing Liang Wang; Jianxin Zhao; Richard Mortier 20220526 Springer Nature
Ocaml Programming Language Family: Ocaml Software, Objective Caml, Marionnet, Fftw, Mldonkey, Unison, Frama-c, Hol Light, Coq, Geneweb Books Llc and Books and LLC 2010

Publications about OCaml from Semantic Scholar

title authors year citations influentialCitations
Using, Understanding, and Unraveling the OCaml Language. From Practice to Theory and Vice Versa Didier Rémy 2000 42 2
Type-safe distributed programming for OCaml John N. Billings and Peter Sewell and Mark R. Shinwell and Rok Strnisa 2006 25 2
Typed Embedding of a Relational Language in OCaml D. Kosarev and D. Boulytchev 2018 14 2
Retrofitting effect handlers onto OCaml K. Sivaramakrishnan and Stephen Dolan and Leo White and T. Kelly and S. Jaffer and A. Madhavapeddy 2021 13 2
Merlin: a language server for OCaml (experience report) Frédéric Bour and Thomas Refis and G. Scherer 2018 12 0
GOSPEL - Providing OCaml with a Formal Specification Language A. Charguéraud and J. Filliâtre and C. Lourenço and Mário Pereira 2019 8 0
GPGPU Composition with OCaml M. Bourgoin and E. Chailloux 2014 4 0
Improving Type Error Messages in OCaml A. Charguéraud 2015 4 0
Caml-Shcaml: an ocaml library for unix shell programming A. Heller and Jesse A. Tov 2008 4 1
Chemoinformatics and structural bioinformatics in OCaml F. Berenger and Kam Y. J. Zhang and Yoshihiro Yamanishi 2019 4 0
Retrofitting parallelism onto OCaml K. Sivaramakrishnan and Stephen Dolan and Leo White and S. Jaffer and T. Kelly and Anmol Sahoo and S. Parimala and Atul Dhiman and A. Madhavapeddy 2020 4 1
WCET of OCaml Bytecode on Microcontrollers: An Automated Method and Its Formalisation S. Varoumas and T. Crolard 2019 2 0
Using camlp4 for presenting dynamic mathematics on the web: DynaMoW, an OCaml language extension for the run-time generation of mathematical contents and their presentation on the web F. Chyzak and Alexis Darrasse 2011 1 0
Cameleer: a Deductive Verification Tool for OCaml Mário Pereira and A. Ravara 2021 1 0
yaml.html · ocaml.html · powerpc.html

View source

- Build the next great programming language · Search · Day 213 · About · Blog · Acknowledgements · Traffic · Traffic Today · GitHub · feedback@pldb.com