My First OCaml Code

I’m reading “The Art of Functional Programming” by Ming Quan Tran. The book is short (200+ pages) and well-written, offering a rationale for all functional programming constructs and techniques, often comparing FP solutions with imperative / OO approaches.

OCaml is the main language the book uses, but Haskell is often mentioned. My background is rooted in mainstream language and OCaml, at (my) first sight is a bit weird. As in Haskell, all functions have just one argument and are curried by default. If you leave out arguments in a function call then it is turned into a function definition that accepts the missing arguments. Maybe this is trivial for native FP programmers, but it is a bit disorienting for me.

Aside from this, OCaml is a rich and effective language providing all you expect – strong typing, generic programming, pattern matching, algebraic data types, and inheritance. Comparing my knowledge of Scala with OCaml is definitely a worthwhile experiment.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.