Decision Mechanics

Insight. Applied.

  • Services
    • Decision analysis
    • Big data analysis
    • Software development
  • Articles
  • Blog
  • Privacy
  • Hire us

The rise of functional programming

May 7, 2021 By editor

Yes, I know functional programming has been around since the 1950s. And, yes—Excel users are functional programmers. There’s nothing particularly new to see here.

Or is there?

There’s been sustained hype around functional languages for a few years now. Yet they have failed to break into the mainstream. Languages such as Haskell, Clojure and F# remaining frustratingly niche.

The top ten programming languages rankings in recent surveys by Stack Overflow and GitHub are devoid of functional programming languages.

Except that they aren’t.

Functional programming is on the rise, but through approach, techniques and style—not language choice.

Mainstream languages are hybridizing—adding functional capabilities to their (predominantly object-oriented) features. C# has LINQ. Java has added Lambda Expressions. JavaScript has many features that support a functional approach—which is actively encourage React, for instance. Rust, Kotlin, Swift…and a host of other modern languages…have a distinctly functional flavour to them.

Functional programming languages have a lot going for them. They encourage (or enforce) functional design principles. And they often bring desirable features with them, such as powerful type inference. However, the real revolution in functional programming is happening through traditional enterprise languages—gradually introducing practising software developers to the ideas without forcing them into a "paradigm shift".

Why does functional programming matter?

Functional programming brings with it skills and concepts that are valuable when building modern applications.

One benefit for data scientists is that functions look like…well…functions. Mathematical functions to be more specific. The closer the code is to the equations you are using, it easier it is to make sure you have the correct implementation. There’s a reason that Excel and R draw heavily on functional ideas.

Today’s applications are increasingly asynchronous. Mobile…web…microservices…functions-as-a-service (FaaS). Asynchronous software is hard to write—and even harder to debug. Functional programming encourages practices such as immutability and isolation of side-effects that make it easier to reason about asynchronous code.

There’s a view, admittedly controversial, that the object-oriented programming (OOP) paradigm that’s dominated software development for over 30 years has retarded progress.

Alan Kay, who coined the term "object-oriented", has long criticised mainstream OOP.

I’m sorry that I long ago coined the term “objects” for this topic because it gets many people to focus on the lesser idea. The big idea is messaging.

He has also expressed his dissatisfaction with major OOP languages.

Java is the most distressing thing to hit computing since MS-DOS.

I invented the term "Object-Oriented" and I can tell you I did not have C++ in mind."

It’s been called the "trillion dollar disaster". Its "three pillars" are a combination of the unremarkable (encapsulation) and positively harmful (inheritance).

OOP’s singular focus on "nouns" has given us an industry of convoluted patterns in an attempt to impose some order–leading to CommandExecutor classes with executeCommand methods.

As we build more complex, asynchronous systems, OOP is failing to scale effectively.

The tools used in functional programming—map, filter, reduce, copy-on-write, etc—are simpler and more generic than OOP patterns. And, as functional programming has a mathematical foundation (lambda calculus), it opens the door to more advanced tooling for automatically diagnosing problems in our code.

Unlike OOP, functional programming encourages us to separate our data from our calculations. This makes our code easier to test and aligns perfectly with today’s data-centric workflows. Data pipelines fit snugly into functional designs.

Can I use functional techniques without adopting a functional programming language?

Yes! That’s the point. Absolutely.

Functional programming is a set of concepts and techniques. It’s a way of thinking about and writing code. Sure, functional languages make it easier to apply those ideas, but you can apply them in any programming language.

And, as mentioned previously, modern languages are increasingly becoming hybrid languages—supporting the use of multiple paradigms.

Focusing on the concepts, rather than language features, will allow you to take your functional programming skills with you as you move from language to language during your career.

I’d argue that it’s worth learning at least one functional-first language as it helps consolidate your ideas, but it’s not essential.

Just start writing functional code. Today. Your customers will thank you for it.

Filed Under: Data science, Software Tagged With: FP, functional programming, object-oriented programming, OOP

Spreadsheet error delays opening of children’s hospital

October 26, 2020 By editor

An audit report has blamed a spreadsheet "copy and paste" error for cost overruns and delays at an Edinburgh children’s hospital.

A local politician called it

[…] one of the most expensive typos in history.

How many more high-profile spreadsheet failures is it going to take before we deem the inappropriate use of them to be professional malpractice?

Filed Under: Data analysis, Software Tagged With: spreadsheet abuse, spreadsheets

Skin in the game

December 8, 2018 By editor

knife-wielding robot

I tend to listen more to opinions when people have placed money on their espoused outcome—having “skin in the game”, as Nicholas Taleb calls it in his latest book.

However, this robotics developer seems to have gone one better. He literally has skin in the game.

Good scientists aren’t supposed to experiment on themselves, but I will feel better if the first people to use autonomous cars are those who built the guidance systems.

At least it’s more impressive than Test-Driven Development.

Filed Under: Artificial intelligence, Machine learning, Software Tagged With: quality, robotics, skin in the game, software

CIA’s malware development guidelines

March 8, 2017 By editor

computer commands

I thought the CIA’s “best practices” for coding malware were interesting.

It’s basically a list of things you have to consider when dealing with a sophisticated attacker. Basic audit features aren’t enough if your data and systems present an attractive target.

Filed Under: Software Tagged With: encryption, hacking, security, software

US lotteries rigged using malicious code

April 9, 2016 By editor

The Des Moines Register reports that an information security officer used malicious code to manipulate lottery results in Wisconsin, Colorado and Oklahoma.

Apparently

Examiners found out-of-place programs known as dynamic link libraries, or DLLs, that had been written onto the Wisconsin computer. The programs were designed to “redirect” a drawing if certain conditions were met…

This is a problem with applications that use common libraries (such as DLLs). It’s difficult to be sure what code is being executed.

Filed Under: Software Tagged With: fraud, lottery, random number generator

  • 1
  • 2
  • Next Page »

Search

Subscribe to blog via e-mail

Subscribe via RSS

Recent posts

  • Digital transformation
  • And if thine data offend Excel, change it
  • A passion for decision analysis
  • JavaScript for data science?
  • Human brains hate probability

Copyright © 2022 · Decision Mechanics Limited · info@decisionmechanics.com