Speaker
Description
As Niklaus Wirth stated in 1976, ‘Algorithms + Data Structures = Programs’. In the world of functional programming, algorithms are functions, and data is immutable. Each function performs a transformation on immutable data passed to it as parameters, returning the result of the transformation. With no mutable data, side effects are effectively excluded.
Repetitions can be realized by recursion; the correctness of a recursive function can be proved by induction. Repetitions can also be achieved with higher-order functions and comprehensions that transform the elements of a collection; in such cases, recursion remains hidden from the programmer.
Recursive algorithms work best on recursive data structures. In modern functional languages, like Elixir, recursive data structures – linear and tree-recursive – can be constructed, with links hidden from the programmer.
Elixir, first published in 2012, is a modern, open-source functional programming language, developed with practical aspects and requirements taking precedence over theoretical ones. The code generated by the Elixir compiler runs on Erlang’s virtual machine, BEAM. As the latter supports concurrency, Elixir includes language constructs that make it easy to create and handle lightweight processes, as well as pass messages between processes.
Proponents argue – and we agree – that the first programming language a student learns should be a functional language. Elixir is near-ideal for this purpose: an Elixir program is easy to write, load and run. Importantly, Elixir’s ecosystem includes a Livebook web application (similar to Python’s Jupyter Notebook), making the teaching and learning programming easier as instruction cells and interactive evaluation cells can alternate in the learning material.
With Elixir, what a student has learned about arithmetic, expressions, math functions and math variables at school need not be unlearned – as is often the case when instructions and procedures with side-effects and mutable data are introduced with imperative programming.
In our presentation, we’ll discuss some important features of functional programming with Elixir, while illustrating its use with Livebook.