F# and functional programming
This module offers a gradual and pragmatic introduction to functional programming, aimed at students who are already comfortable with imperative, object-oriented Java.
The main goal is not to learn a new syntax, but to change the way you reason about programs:
moving from a sequence of actions to a view of the program as a transformation of data, one that is readable, testable and robust.
Main themes
The course emphasises:
- code readability and local understanding;
- reducing side effects;
- immutability and the separation between computation and input/output;
- reasoning through types as a design tool;
- iteration without imperative loops (through
map,filter,fold); - recursion and tail recursion;
- function composition and writing in a pipeline style.
Language and transferable skills
The main language is F#, chosen for the clarity of its functional model and of its type system.
The end of the module pays particular attention to the transfer to modern Java:
- lambda expressions,
- Streams,
- good practice,
- the limits of the functional style in an industrial setting.
Teaching format
The module alternates between:
- demonstrations,
- guided exercises,
- lab work,
with a constant emphasis on:
- reading code,
- understanding invariants,
- being able to explain what a program does without simulating its execution step by step.
Learning outcomes
By the end of the course, students will have acquired design reflexes that are useful well beyond the functional paradigm, and directly applicable to their everyday professional programming.