From Imperative to Functional: how to make the leap.
Many programmers find functional programming difficult, if not downright cryptic. This is because functional programming is not merely about relinquishing the assignment statement and using closures liberally. It’s a whole different mindset. …basically boils down to three things: For this tutorial, I won’t be using the syntax of any particular programming language. That would obscure my point. Instead, I will borrow from high school mathematics. Here is an example: Which means, “let n be a natural number whose value is 42. More generally, when I say I mean that x has type T. Basically x is an element of the set T (let’s just assume that types are sets). And when I say I just mean that x is the value denoted by the expression Expr. Now let’s define a function: Which means “Let f be a function from natural numbers to real numbers, which returns its input plus π”. To make reading easier, we will use this more familiar syntax whenever possible: I will however insist on using type annotatio
March 2013 From Imperative to Functional: how to make the leap Many programmers find functional programming difficult, if not downright cryptic. This is because functional programming is not merely about relinquishing the assignment statement and using closures liberally. It’s a whole different mindset . The functional mindset …basically boils down to three things: Your program isn’t about what it does, but about what things are. Your code isn’t just a linear sequence of instructions, but a tree of nested expressions. Functions are ordinary mathematical objects, just like an integer is. Some n
related reading
- An introduction to functional programmingcodewords.recurse.com
- A practical introduction to functional programmingmaryrosecook.com
- how I think when I think about programming - alice mazalicemaz.com
- What’s so great about functional programming anyway?jrsinclair.com
- A half-hour to learn Rustfasterthanli.me
- Functional Programming HOWTO — Python 3.14.6 documentationdocs.python.org
- Get better at programming by learning how things workjvns.ca
- 1.2. OCaml · Functional Programming in OCamlcourses.cs.cornell.edu
- Reading 13: Map, Filter, Reduceweb.mit.edu
- It's hard to write code for computers, but it's even harder to write code for humans · Erik Bernhardssonerikbern.com
- Starting Out - Learn You a Haskell for Great Good!learnyouahaskell.github.io
- JAX core from scratch — JAX documentationdocs.jax.dev