Functional Programming - A Sightseeing Tour

Thach MAI
Slide location: https://www.thachmai.info/2016/05/10/fp-tour

The Current King: Object-Oriented, Imperative paradigm

Java (1996) was the first popular "pure OO" language
The main focus is the object: data + state + method
Program execution is often viewed as a sequence of steps
The "current step" jumps between object boundary

Techniques: design patterns, SOLID, principle of least knowledge

The Landscape Is Changing

C# introduced LINQ (2007)
Scala (2004) and Clojure (2007) got a foothold in the JVM world
Go-lang did away with object altogether (2009)
Java introduced "lambda" in Java 8 (2014)
Javascript formalised the Promise specification (2015)
Perl 6 (2015) can do functional programming

Ideas from Functional Programming (FP) are affecting us in substantial ways

A Brief History of FP

An ancient idea, started with lambda calculus by Alonzo Church in the 1930s
FP stayed as a niche in mostly in acamedia until recently
FP is still a niche today, but is arguably a mainstream niche
For some, FP might seem intimidating due to its mathy roots

What is the big deal about FP?

Programs are made of functions
Data "flows" through the program guided by functions
Functions are not your typical OO methods. FP has a lot of neat tricks with its functions
Notably, FP allows you to easily compose new functions based on existing ones

Typical FP programs have less variables
FP programs are often smaller in size than those of other paradigms
FP programs can look cryptic at first, but the rules are simple

Examples

https://github.com/thachmai/fpTour
In this example, let's build a web page that retrieves information from Github API and shows it in a table format.

FP Today

Functional Programming is already here. It's affecting many design choices from popular languages.
Learning directly the FP paradigm can help you to simplify the concepts.
FP is rich in useful techniques

Learning a new paradigm takes time. But for me, the FP journey has been most rewarding.
I hope that you'll give it a try.