The popular wisdom says that programming is like giving directions to an idiot. It is a rather handy analogy, and you can use to explain to your grandparents what you do for a living. However, it doesn’t quite hit the mark.

I mean, even the dumbest person you could possibly imagine is still orders and orders of magnitude more complex than all your computers put together. So, it is not really like that. It’s not even like teaching a monkey to ride a bicycle. That cool online app that recognizes people’s expressions does not have hardware worth millions of years of evolution between its ears. All it has is ones and zeroes - that and a whole lot of layers of abstraction.

But you already knew all that! If you didn’t, you wouldn’t be here reading a book about programming paradigms. Still, it makes a fine ice-breaker, so here it is - I said it.

So, what’s the point with all the paradigms, you might ask? Well, with all those layers of complexity our modern software has we need to be able to:

  1. Develop it successfully or at all.
  2. Maintain it, preferably in a way where it does not collapse like a house of cards.
  3. If anyhow possible, keep our own sanity while we do so.

Using the right way to mold and shape our programs moves us one step closer to these noble goals, and we do that by choosing the most appropriate paradigm.

There are lots of paradigms, but these three are the most important for us at the moment:

  • Imperative programming - programs consist of ordered lists of statements that get executed sequentially, changing the computer’s state while doing so. This has been the most common programming style for a very long time and conceptually it is closest to how computers actually work. The list of example languages is very long, but some of them are: C/C++, Java, JavaScript, and so on.
  • Declarative programming - programs are actually accurate specifications of the desired outcomes, rather than lists of instruction how to achieve them. The most common examples are HTML, CSS and SQL.
  • Functional programming - mathematical functions are the main building blocks and programs rely on their evaluation given certain parameters. Functions are supposed to be pure - their outcome may only depend on the input parameters and they may not have any side effects. This property makes functional programming very close to the declarative paradigm. Some of the examples are Haskell, Clojure (and other Lisps), Erlang and so on.