The Functional Style
We'll cover the following...
The functional style of programming has been around for a very long time, although it hasn’t been the mainstream. In recent years, it’s been gaining in popularity. Let’s first look at what it is, and then why that’s significant.
What’s the functional style?
“Computers are stupid; you have to tell them every detail,” were the words of my teenager learning to program. Sadly, feeling that pain every single day is the job of most professional programmers. Anything that can alleviate those troubles is a step in the right direction. Functional programming is one such solution.
In the imperative style of programming, we have to key in every step. Create a variable named i
, set the initial value to 0
, check if the value is less than k
—wait, is it less than or less than or equal to? Hmm.
The declarative style is where you say what you want and let the functions you call figure out how to do it. For example, to find if our friend Nemo ...