News for hackers. Stuff that matters.
Re:Why study functional programming? (2012) by MaxBarraclough on Tuesday August 02, 2022 @04:43PM (#32324041)
Right. Pure functions make it considerably easier to reason about code, even in the absence of concurrency.

It's a shame D's pure modifier (to statically guarantee purity) isn't available in many other languages. [0] SPARK Ada has something similar in that functions must always be pure, forcing procedures to be used for impure functionality. [1] edit I think that's mistaken, SPARK appears to permit functions to read globals but not to modify them.

edit John Carmack has written about this kind of thing. From [2]:

> if a function only references a piece or two of global state, it is probably wise to consider passing it in as a variable. It would be kind of nice if C had a "functional" keyword to enforce no global references.

[0] https://dlang.org/spec/function.html#pure-functions

[1] https://learn.adacore.com/courses/intro-to-spark/chapters/01...

[2] https://cbarrete.com/carmack.html

There are no comments on this comment yet.