A software company’s CTO says the software industry’s current trajectory “is toward increasing complexity, longer product development times, and more fragile production systems” — not to mention nightmarish problems maintain coded.
“To fix such problems, companies typically send more people to the problem: more developers, more testers, and more technicians who step in when systems fail. Surely there must be a better way,” they write in IEEE Spectrum. “I’m part of a growing group of developers who think the answer might be functional programming…”
Today we have a multitude of dangerous practices that compromise the robustness and maintainability of software. Almost every modern programming language has some form of null references, shared global state, and functions with side effects – things that are far worse than GOTO ever was. How can these defects be eliminated? It turns out that the answer has been around for decades: purely functional programming languages…
Indeed, software based on pure functions is particularly well suited to modern multi-core CPUs. Indeed, pure functions only operate on their input parameters, which makes any interaction between different functions impossible. This allows the compiler to be optimized to produce code that runs on multiple cores efficiently and easily….
Functional programming also has a solution to Hoare’s “billion dollar mistake”, null references. It solves this problem by disallowing null values. Instead, there is a construct usually called Maybe (Where Option in some languages). A Maybe perhaps Nothing Where Just some value. Work with Maybe s forces developers to always consider both cases. They have no choice in the matter. They have to manage the Nothing case whenever they encounter a Maybe. This eliminates many bugs that null references can cause.
Functional programming also requires data to be immutable, which means that once you set a variable to a certain value, it’s always that value. Variables are more like variables in math…
Pure functional programming solves many of the biggest problems in our industry by removing dangerous features from the language, making it harder for developers to shoot themselves in the foot… I foresee the adoption of functional languages pure will improve the quality and robustness of industry-wide software while dramatically reducing the time wasted on bugs that are simply impossible to generate with functional programming. It’s not magic, but sometimes it is, and I remember how good I have it whenever I’m forced to work with a non-working codebase.