March 12th, 2015
(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: email@example.com
That promised time when we’d have applications running distributed and concurrently finally has come. Unfortunately, we are not ready: our “current” (i.e., most used) model for concurrency and parallelism, even though might solve the problem, it adds a lot of complexity.
For a better applications, we need a simple and reliable manner to do it. Do you remember above-mentioned features of FP? Pure Functions and Immutable State? Exactly. You can run a function a thousand of times in different cores or machines that you’re not going to get different outputs from what you’ve gotten before. So, you can use the same code to run in 1 core as well as 1k. Life can be good again.
“But why can’t I keep using OOP?”
At least for concurrency and parallelism, OOP cannot save you anymore. It’s just because OOP relies directly on mutable state (in Imperative Languages, which are the most common OOP implementation). The Object’s methods you call is supposed to mutate the current self or this. A lot of complexity will be needed to keep all threads correctly updated and synchronized.
I’m not here to argue that you must move from your whatever paradigm to FP (even though some people would say you must), but you definitely need to master it: Java and C++11 already got lambda expressions. I can say that almost every modern and maintained language is going to rely on FP features soon. And most of them already do.