The first few days…
Before that, what was the reading material? The following:
- Real World OCaml
- A first hour with OCaml – OCaml
- Data Types and Matching – OCaml
- OCaml - The core language
As promised, I did not touch the computer other than installing the system and running at least one “Hello OCaml” program (Couldn’t prevent myself from doing that). The rest was mostly pencil and paper.
OCaml is very appealing, visually. I don’t think I would have appreciated the
| syntax had I not started with an editor. For example, the following code…
let rec sigma f = function
|  -> 0
| x :: l -> f x + sigma f l;;
…does look good in the editor, but when typing it, I would probably feel weird, especially having been a Python programmer for some time. But I have this habit of scratching out extra lines for visual inspection when writing with a pencil, and this made total sense when I was scratching a few programs out. Some more tidbits from my experience:
- I totally dig the
let rec mentioning of recursion! Explicit is better than implicit.
= as an equality operator will take some time to sink in.
A * B notation is <3 very Cartesian.
- Ugh dealing with error through exception, no language could satisfy me with their exceptions, this is because they all do the same things differently, overloading my brain with 10 patterns that could just be one. At least OCaml way is closer to the two language I am currently using most (Python and Elixir, and I usually avoid exception in the latter).
let..in is a form I like, I remember seeing that as an “alternative” in a ReasonML tutorial where they kindof negatively marketed it, but I think I would prefer this syntax.
- OPAM looked good, as did Dune, but I mostly read about them, not used them, yet.
- Module system is not a paper/pencil friendly system to learn, so saved those pearls for the long weekend.
As an Elixir programmer, I already knew I’d love the pattern matching capabilities of OCaml! I couldn’t have fathomed the beauty and power of their typing system in the first few days but I think I have some idea on what to expect. I will spend the upcoming weeks deciphering those, alongside the toolchains.
I think I am ready to get on the computer with OCaml. And I will change my decision to predominantly use the official Tutorials and use the book “Real World OCaml” instead and use the official ones as reference. The book is very well written.
What I foresee is, the “Module System” will become a bit of challenge for me and probably will be asking help on this region. Or maybe not.
Overall, the first 2/3 days were amazing and I can tell it’s one of those languages that I’d stick to and improve upon.