Why should I use OCaml?

OCaml is a language that promotes developer productivity. It’s:

  • Statically typed with an excellent implementation of ML type system
  • Inherits features of Pascal and Modula-2 module system with fast incremental compiles
  • Very pragmatic, doesn’t insist on functional purity like other languages. You can smash together stuff to get the job done and refactor later because of the type system
  • Makes some really solid tradeoffs from an engineering point of view, e.g. has very good single-threaded performance and encourages parallelization via multiple processes (but this will change in the near future with Multicore OCaml)

To answer your specific questions:

  • Why are really good languages like OCaml and Erlang/Elixir not more used? I think it’s clear that popularity doesn’t have anything to do with quality. It’s a lot to do with luck and timing.
  • (Assuming by ‘web development’ you mean web server backends) Yes, OCaml has some good options for web development, from complete fullstack solutions like Ocsigen/Eliom to smaller more focused frameworks like Opium (and even my own framework, ReWeb)
  • OCaml code tends to be uniformly functional-style; it’s rare to come across significant use of object-oriented style
  • ‘OCaml’ is the original syntax and compiler; Reason is an alternative JavaScript-like syntax and toolkit for OCaml; ReScript is a TypeScript-like syntax and compiler (fork of OCaml) that specializes in outputting high-quality JavaScript; BuckleScript is the old name of ReScript.
12 Likes