What is OCaml?

Introduction to an interesting programming language with wide sphere of use
04 July 2017   828

OCaml (also knows as Objective Caml) — is a modern object-oriented functional programming language of general purpose. Language has a high level of expressiveness, which allows to learn and use it easily. OCaml supports functional, imperative and object-oriented programming paradigms. Also, this is the most popular version of ML programming language. 

The OCaml toolkit includes an interpreter, a compiler in bytecode, and an optimizing compiler into machine code that is comparable in efficiency to Java and only slightly inferior in speed to C and C ++.

Some facts about OCaml:

  • The language was developed at the French Institute INRIA in 1985 and is in developing to this day.
  • It is a multi-paradigmatic (functional, imperative, object-oriented) programming language for general purpose with automatic garbage collection.
  • The language supports lambdas, closures, currying, tail recursion, pattern matching and immutable data.
  • Pointers, loops, variable data and functions with side effects are also presented in OCaml.
  • By default, the calculation is strict, but if necessary, you can use lazy calculations or simply pass functions as arguments.
  • The program on OCaml can be interpreted, compiled into a virtual machine bytecode (called Zinc) or machine code.
  • Even on OCaml, you can write under JVM, as well as under .NET, where the language for some reason is called F #.
  • Indents in OCaml can be put as you like.
  • In terms of performance, OCaml is comparable to Java, Haskell, and Go.

We've collected the information about the most helpful tutorials, interesting books and useful IDEs.

OCaml tutorial

OCaml is not so widely used as Java or Ruby, so, there aren't so many tutorials and learning materials as for those languages. But there are still good materials for both beginners and skilled coders.

How to install OCaml on Mac?

First of all, you will have to install OCaml of your PC. This article will help you to install OCaml on Mac OS. Written by a skilled coder and has step-by-step instructions and screenshots.

TryOCaml

This web tutorial allows you to immediately start learning OCaml in your browser, without installing it. Veru convenient approach.

tryocaml interface
TryOCaml interface

Compiled as a single Javascript page, it gives you the full power of OCaml, even when you are disconnected from the network. Great solution for those, who would like to try OCaml without any installations and etc.

RosettaCode

Big OCaml's section at RosettaCode - a website, that collects task solutions for different programming languages.

RosettaCode interface
RosettaCode interface

Great knowledge portal; every coder can find a solution for his issue here. Every solution is a piece of a code, written on a certain language.

PLEAC-OCaml

This simple website with minimalist design provides OCaml solutions to the complete set of "classic" programming.

 PLEAC-OCaml interface

OCaml is one of only 3 languages for which the full set of solutions has been provided. The approach is based on the popular "Perl Cookbook".

Best OCaml book 

The books will never go out of fashion. Here is the list of most interesting OCaml books.

Real World OCaml

This book will show you how to solve day-to-day problems programming issues in data processing, numerical computation, system scripting, and database-driven web applications with the OCaml.

Real World OCaml
Real World OCaml

This hands-on book shows you how to take advantage of OCaml’s functional, imperative, and object-oriented programming styles with recipes for many real-world tasks.

You’ll start with OCaml basics, including how to set up a development environment, and move toward more advanced topics such as the module system, foreign-function interface, macro language, and the ocamlbuild system. Quickly learn how to put OCaml to work for writing succinct and readable code.

OCaml from the Very Beginning

In this book author takes a direct approach to teaching this programming language.

OCaml from the Very Beginning
Real World OCaml

Each small, self-contained chapter introduces a new topic, building until the reader can write quite substantial programs. There are plenty of questions and worked answers and tips.

"OCaml from the Very Beginning" will appeal both to new and skilled programmers. It is suitable both for formal use within an undergraduate or graduate curriculum, and for the interested amateur.

Also, the newest version of OCaml documentation can be found at the official website

OCaml IDE

When you will become familiar with OCaml and would like to use it for work or fun, it is time chose proper environment. 

Emacs

Platforms: Windows, Linux, Mac OS.

Price: freeware with ability for donation.

emacs interfaceEmacs interface

Features

  • Flexible code editing: most of the operations have hotkeys, cursor can be moved by symbols, worlds, lines, paragraphs, functions or massives;
  • High level of customization. Almost all functions of the editor can be reconfigured for you. To do this, you must have at least basic knowledge in Elisp, but some changes can be made through a visual interface;
  • ocaml-mode from the standard distribution;
  • alternative tuareg-mode;
  • camldebug intergration with debugger.

Vim

Platforms: Windows, Mac OS, Linux, iOS, Android.

Price: freeware. Work with OCaml requires a plugin.

vim interface
Vim interface

Features:

  • Vim is one of the most customizable text editors. It supports the saving of undo operations even after the program is closed, clipboard switching, automatic creation of the workpiece of the scripts;
  • Works in the mode of insertion, console and visual. Simultaneous opening of several files, window management;
  • Simple expansion of the editor with other languages ​​due to the large database of plugins;
  • Support syntax highlighting, automatic indentation, code checking with Syntastic;
  • The plugin is recommended on the official  page.

OCamlEditor 

Platform: Linux, Windows.

Price: freeware.

OCamlEditorOCamlEditor

Features:

  • Specialized OCaml IDE
  • Customizable syntax highlighting;
  • Automatic indentation;
  • Commenting/uncommenting of code blocks;
  • Automatic compilation of the currently open file;
  • Code folding;
  • Completion popup with types description and documentation;
  • Structure Pane;
  • Ability to display the types inferred by the compiler;
  • Find definition/references;
  • Templates;
  • Switch between interface and implementation with automatic interface generation.

Do you use OCaml?

OCaml (also knows as Objective Caml) — is a modern object-oriented functional programming language of general purpose. Language has a high level of expressiveness, which allows to learn and use it easily. Do you use programming language OCaml in your work?

Ocaml developer salary, August 2017

United States Ocaml developers labor market analysis, according to the results
29 August 2017   545

We publish the analysis of the labor market of developers in the United States monthly. For Ocaml developers in August there were 58 vacancies. The vacancy rates were distributed as follows.

Ocaml Salary Estimate, August 2017
Ocaml Salary Estimate, August 2017

The most of the developers are required in Seatle, the least in San Francisco, CA, San Jose, CA, San Carlos, CA, Redwood City, CA, Menlo Park, CA, Illinois, Boston, MA, Eugene, OR.

Number of Ocaml vacancies in different cities, August 2017
Number of Ocaml vacancies in different cities, August 2017

Among the companies that hire Ocaml developers the leaders are: 

  • Oracle
  • IBM
  • Wade & Wendy 

Number of Ocaml vacancies in different companies, August 2017
Number of Ocaml vacancies in different companies, August 2017

According to the required experience, the vacancies are distributed as follows.  

Number of Ocaml vacancies by experience level, August 2017
Number of Ocaml vacancies by experience level, August 2017

The average salary and salary according to the experience level were distributed as follows.

Average Ocaml developer salary, August 2017
Average Ocaml developer salary, August 2017

The analysis was carried out by the Hype.codes portal method using the indeed.com data.