Hacker News new | ask | show | jobs
by mmargerum 1324 days ago
Doesn't include Clojure in GitHub repo count.

"Functional programming also requires that data be immutable" Not true

3 comments

The D programming language is a good example which defines pure functions, not as strictly operating on immutable data, but simply as functions without side effects. So pure functions can still have local mutable variables, but cannot mutate any shared or global state. It goes further with "weakly pure" functions which can have mutable parameters/arguments, but still cannot mutate any global variables.
Not to mention you can use just about any language provided you adhere to FP standards. It doesn't need to be forcibly "baked in".
Pure functional programming does require immutable data. There are lots of FP languages that aren't pure, though.
No, it doesn't. Pure FP is about pure functions, meaning only that they don't have side-effects (essentially just that you could replace the function call with it's return value without changing the semantics of the program). If a function mutates some global state then that would certainly make it impure but a function which takes an input, mutates it and returns the mutated value is absolutely pure.