The
promises of Functional Programming
I’m
a computer science enthusiastic and I love the idea that a
programming language can be specifically designed to fit all the
needs for computer science to advance faster.
However
I am still very sceptic about functional programming.
While
it certainly makes some good points about the use of recursion and
the extra feature of not needing the locks for parallelism and so on,
I don’t think is such a great feature. Rather I would consider it a
miss from part of the creators or some trick to avoid data
corruption. I mean it certainly works and in practice makes it much
easier to avoid data corruption.
But
I would argue the next analogy to explain my point of view on the
matter.
Imagine
a highway, on which there will be thousands of high speed vehicles
travelling at all times.
I
would argue that the feature functional programming provides of not
needing to worry about data corruption, because you cannot write data
would be like building this hypothetical highway with multiple levels
each specially designed for each vehicle.
Each
thread running on their own highway uninterrupted and undisturbed
because there is no way of interacting with one another.
I
see this as cheating cause the whole point of having parallel
programming is to execute a little part of a big task while other
thread executes other little part of the task.
I
believe the perfect parallel program should be able to time perfectly
how much to “slow down” a thread without necessarily freezing it
completely in order for it to miss another threads writing or reading
or processing of data.
Instead
of making a safer highway, the drivers should become better so the
highway remains the same but the drivers are so smart, advanced and
well trained that the same level of efficiency can be achieved while
having the feature of sharing information.