Workshops

A Taste of Functional Programming with OCaml


Proposed by Sudha Parimala
|
No. of presenters: 2

Schedule

Day 2
Room 2
10:45 AM - 01:15 PM

Brief Description

# A Taste of Functional Programming


Have you used first class functions in JavaScript, or React? Java streams? Anonymous functions and list comprehensions in Python? Pattern matching in Rust? What if I tell you they all have something in common — they were all derived from functional programming.


Recently, functional programming concepts have been increasingly adopted by more mainstream languages, although functional programming itself has been around for much longer. A substantial amount of academic research has been dedicated to the creation of functional languages. Functional programming (FP) concepts are founded on Lambda Calculus, which was developed by Alonzo Church in the 1930s. Around the same time, Alan Turing introduced Turing machines, which serve as the foundation of automata theory and compilers. What's more, they went on to prove that Lambda Calculus and Turing Machines are equivalent.


The very first functional programming (FP) language is Lisp, developed by John McCarthy, also known as the father of Artificial Intelligence, in the late '50s and early '60s. Lisps, of which Common Lisp, Scheme, and Racket are dialects, don't have the notion of types. In the '70s, Robin Milner built upon Roger Hindley's work on type theory and type inference algorithms, introducing what is termed as the Hindley-Milner type system. This system became the basis for the development of Standard ML (ML standing for Meta-Language, not Machine Learning). Standard ML, in turn, went on to influence many modern functional languages such as Haskell, Elm, Scala, Rust, OCaml, and more.


Why is functional programming gaining attention now? Our hardware systems are faster than ever, but Moore's Law has started to recede. Memory and computational power are no longer as expensive as they once were. Support for parallelism, concurrency, higher-order functions, and compiler optimizations is no longer the distant dream it used to be. Now, more than ever, is a great time to learn functional programming. Even if one doesn't end up using an FP language to build something, these concepts can be applied in almost any language.


Among the various strongly-typed languages, OCaml occupies a sweet spot. It fully embraces the rigor that the ML family of languages offers while remaining pragmatic enough to accommodate innovations. This tutorial will provide participants with an introduction to functional programming concepts such as recursion, higher-order functions, and algebraic data types. Additionally, they will get up to speed with the latest developments in the OCaml platform, including the use of the build system Dune, the LSP server, and Merlin for an IDE-like experience.


The workshop material is derived from a previous run of a similar tutorial: https://github.com/ocamllabs/learn-ocaml-workshop


Supporting Links

Comments
Want to discuss?
Post it here, our mentors will help you out.