Purity is Great for Collaboration

submited by
Style Pass
2024-10-06 07:00:05

When people talk about the benefits of purity in functional programming, the benefits that are often mentioned are equational reasoning (if the language is lazy), ease of testing, memoization and ease of parallelization. To me, these are all great benefits, but might not be enough to convince a skeptic.

What I often do find missing in these conversations is how much of a benefit purity can be to collaboration, specifically for dependencies. Purity is a contract that says: I will not do any kind of I/O; I.E. no network calls, no db calls, no file reading, no reading environment variables etc. The third-party dependencies won’t because if they try , the program won’t compile. That is in some sense a very simple portable permission model.

Today, software is probably more vulnerable than ever to supply chain attacks, especially in languages like JavaScript and Rust that have a culture of importing dependencies for every small problem they have.

Leave a Comment