2019_09_20_look_back_ocaml_since_2011.md 10.2 KB
Newer Older
1 2 3 4 5 6 7
title=A look back on OCaml since 2011
authors=Thomas Blanc
tags=ocaml, highlights, cheat-sheets

[![A look back on OCaml since 2011](assets/img/ocaml-2011-e1600870731841.jpeg)](/blog/2019_09_20_look_back_ocaml_since_2011)
9 10

As you already know if you’ve read [our last blogpost](/blog/2019_09_13_updated_cheat_sheets_language_stdlib_2), we have updated our OCaml cheat sheets starting with the language and stdlib ones. We know some of you have students to initiate in September and we wanted these sheets to be ready for the start of the school year! We’re working on more sheets for OCaml tools like opam or Dune and important libraries such as ~~Obj~~ Lwt or Core. Keep an eye on our blog or the [repo on GitHub](https://github.com/OCamlPro/ocaml-cheat-sheets) to follow all the updates.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

Going through the documentation was a journey to the past: we have looked back on 8 years of evolution of the OCaml language and library. New feature after new feature, OCaml has seen many changes. Needless to say, upgrading our cheat sheets to OCaml 4.08.1 was a trip down memory lane. We wanted to share our throwback experience with you!

## 2011

Fabrice Le Fessant first published our cheat sheets in 2011, the year OCamlPro was created! At the time, OCaml was in its 3.12 version and just [got its current name](https://inbox.ocaml.org/caml-list/E49008DC-30C0-4B22-9939-85827134C8A6@inria.fr/) agreed upon. [First-class modules](https://caml.inria.fr/pub/docs/manual-ocaml/manual028.html) were the new big thing, Camlp4 and Camlp5 were battling for the control of the syntax extension world and Godi and Oasis were the packaging rage.

## 2012

Right after 3.12 came the switch to OCaml 4.00 which brought a major change: [GADTs](https://caml.inria.fr/pub/docs/manual-ocaml/manual033.html) (generalized algebraic data types). Most of OCaml’s developers don’t use their almighty typing power, but the possibilities they provide are really helpful in some cases, most notably the format overhaul. They’re also a fun way to troll a beginner asking how to circumvent the typing system on Stack Overflow. Since most of us might lose track of their exact syntax, GADTs deserve their place in the updated sheet (if you happen to be OCamlPro’s CTO, *of course* the writer of this blogpost remembers how to use GADTs at all times).

On the standard library side, the big change was the switch of `Hashtbl` to Murmur 3 and the support for seeded randomization[.](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-0839)

## 2013

With OCaml 4.01 came [constructor disambiguation](https://github.com/ocaml/ocaml/issues/5759), but there isn’t really a way to add this to the sheet. This feature allows you to avoid misguided usage of polymorphic variants, but that’s a matter of personal taste (there’s a well-known rule that if you refresh the comments section enough times, someone —usually called Daniel— will appear to explain polymorphic variants’ superiority to you). `-ppx` rewriters were introduced in this version as well.

The standard library got a few new functions. Notably, `Printexc.get_callstack` for stack inspection, the optimized application operators `|>` and `@@` and `Format.asprintf`.

## 2014

*Gabriel Scherer, on the Caml-list, end of January:*

> TL;DR: During the six next months, we will follow pull requests (PR) posted on the github mirror of the OCaml distribution, as an alternative to the mantis bugtracker. This experiment hopes to attract more people to participate in the extremely helpful and surprisingly rewarding activity of patch reviews.

Can you guess which change to the cheat-sheets came with 4.02? It’s a universally-loved language feature added in 2014. Still don’t know? It is *exceptional*! Got it?

Drum roll… it is the `match with exception` [construction](https://caml.inria.fr/pub/docs/manual-ocaml/patterns.html#sec131)! It made our codes simpler, clearer and in some cases more efficient. A message to people who want to improve the language: please aim for that.

This version also added the `{quoted|foo|quoted}` [syntax](https://caml.inria.fr/pub/docs/manual-ocaml/lex.html#string-literal) (which broke comments), generative functors, attributes and [extension nodes](https://caml.inria.fr/pub/docs/manual-ocaml/manual036.html), extensible data types, module aliases and, of course, immutable strings (which was optional at the time). Immutable strings is the one feature that prompted us to *remove* a line from the cheat sheets. More space is good. Camlp4 and Labltk moved out of the distribution.

In consequence of immutable strings, `Bytes` and `BytesLabel` were added to the library. For the great pleasure of optimization addicts, `raise_notrace` popped up. Under the hood, the `format` type was re-implemented using GADTs.

## 2015

This release was so big that 4.02.2 feels like a release in itself, with the adding of `nonrec` and `#...` operators.

The standard library was spared by this bug-fix themed release. Note that this is the last comparatively slow year of OCaml as the transition to GitHub would soon make features multiply, as hindsight teaches us.

## 2016

Speaking of a major release, we’re up to OCaml 4.03! It introduced [inline records](https://caml.inria.fr/pub/docs/manual-ocaml/manual040.html), a GADT exhaustiveness check on steroids (with `-> .` to denote unreachability) and standard attributes like `warning`, `inlined`, `unboxed` or `immediate`. Colors appeared in the compiler and last but not least, it was the dawn of a new option called [Flambda](http://ocamlpro.com/tag/flambda2-en/).

The library saw a lot of useful new functions coming in: lots of new iterators for `Array`, an `equal` function in most basic type modules, `Uchar`, the `*_ascii` alternatives and, of course, `Ephemeron`.

4.04 was much more restrained, but it was the second release in a single year. Local opening of module with the `M.{}` syntax was added along with the `let exception ...` in construct. `String.split_on_char` was notably added to the stdlib which means we don’t have to rewrite it anymore.

## 2017

We now get to 4.05… which did not change the language. Not that the development team wasn’t busy, OCaml just got better without any change to the syntax.

On the library side however, much happened, with the adding of `*_opt` functions pretty much everywhere. If you’re using the OCaml compiler from [Debian](https://packages.debian.org/sid/ocaml), this is where you might think the story ends. You’d be wrong…

…because 4.06 added a lot! My own favorite feature from this release has to be user-defined [indexing operators](https://caml.inria.fr/pub/docs/manual-ocaml/manual042.html). This is also when `safe-string` became the default, giving worthwhile work to every late maintainer in the community. This release also added one awesome function in the standard library: `Map.update`.

## 2018

4.07 was aimed towards solidifying the language. It added empty variants and type-based selection of GADT constructors to the mix.

On the library side, one old and two new modules were added, with the integration of `Bigarray`, `Seq` and `Float`.

## 2019

And here we are with 4.08, in the present day! We can now put exceptions under or-patterns, which is the only language change from this release we propagated to the sheet. Time will tell if we need to add custom [binding operators](https://caml.inria.fr/pub/docs/manual-ocaml/manual046.html) or `[@@alert]`. `Pervasives` is now deprecated in profit of `Stdlib` and new modules are popping up (`Int`, `Bool`, `Fun`, `Result`… did we miss one?) while `Sort` made its final deprecation warning.

We did not add 4.09 to this journey to the past, as this release is still solidly in the *now* at the time of this blogpost. Rest assured, we will see much more awesome features in OCaml in the future! In the meantime, we are working on updating more cheat sheets: keep posted!
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

# Comments

Micheal Bacarella (23 September 2019 at 18 h 17 min):
> For a blog-post from a company called OCaml PRO this seems like a rather tone-deaf PR action.
> I wanted to read this and get hyped but instead I’m disappointed and I continue to feel like a chump advocating for this language.
> Why? Because this is a rather underwhelming summary of *8 years* of language activity. Perhaps you guys didn’t intend for this to hit the front of Hacker News, and maybe this stuff is really exciting to programming language PhDs, but I don’t see how the average business OCaml developer would relate to many of these changes at all. It makes OCaml (still!) seem like an out-of-touch academic language where the major complaints about the language are ignored (multicore, Windows support, programming-in-the-large, debugging) while ivory tower people fiddle with really nailing type-based selection in GADTs.
> I expect INRIA not to care about the business community but aren’t you guys called OCaml PRO? I thought you *liked* money.
> You clearly just intended this to be an interesting summary of changes to your cheatsheet but it’s turned into a PR release for the language and leaves normals with the continued impression that this language is a joke.

Thomas Blanc (24 September 2019 at 14 h 57 min):
> Yes, latency can be frustrating even in the OCaml realm. Thanks for your comment, it is nice to see people caring about it and trying to remedy through contributions or comments.
> Note that we only posted on discuss.ocaml.org expecting to get one or two comments. The reason for this post was that while updating the CS we were surprised to see how much the language had changed and decided to write about it.
> You do raise some good points though. We did work on a full windows support back in the day. The project was discontinued because nobody was willing to buy it. We also worked on memory profiling for the debugging of memory leaks (before other alternatives existed). We did not maintain it because the project had no money input. I personally worked on compile-time detection of uncaught exception until the public funding of that project ran out. We also had a proposal for namespaces in the language that would have facilitated programming-in-the-large (no funding) and worked on multicore (funding for one man for one year).