Is Rust functional? [Blog]
-
What is functional programming?
I’ve answered this question in at least one talk in the past, but to my recollection I haven’t done so in blog post form yet. I don’t believe there is any universally agreed upon definition of what makes a language “functional.” To demonstrate:
Is Javascript functional? Many people successfully leverage higher-order functions, and functions are first class values. Also, by this metric, even C is a functional programming language (though it lacks closures).
Haskell is a purely functional programming language, since all functions are pure. Instead of allowing effects to occur in functions, we create actions which, when run, perform these effects. And then we use the type system to distinguish these effects from pure values. Is that the bar for functional programming? If so, many presumably functional languages like OCaml wouldn’t meet the bar, so that’s not great.
I’ve seen people call XSLT a functional programming language since it’s declarative. But most users of functional programmers would be surprised to use a functional programming language where it’s difficult and/or impossible to create user-defined functions.
Great read on the boarder of functional paradigm vs pure functional languages (Where is Haskell on this scale?)
Is Rust functional?
Rust is an imperative systems programming language. Why does it have so much attention from functional programming advocates? Is it hiding a functional nature?
FP Complete (academy.fpblock.com)