# What is an example for which the purely functional programming approach gives better results than imperative style?

I have seen some questions related to functional programming on stackexchange sites which suggests it has significant popularity. I have some experience with it from many years ago in Lisp/Scheme and have seen commentary on the difference between functional and imperative/mutable approaches eg [4].

The wikipedia page on the subject says "Pure functional programming disallows side effects completely and so provides referential transparency, which makes it easier to verify, optimize, and parallelize programs, and easier to write automated tools to perform those tasks." But it is known to have a cost of up to a factor of $O(\log(n))$ slowdown factor [2] due to lack of mutable data structures, leading to a lot of research in functional programming datastructures that have a much different flavor than mutable approaches [3].

Along these lines,

What is an example for which the purely functional programming approach leads to better overall results than the imperative approach?

(Also it seems the word "mutable" here is a bit subtle. functional languages appear to allow one to "store" data eg via balanced trees, but not later "change" it. This is a little different than mutability eg in java, where initial storage and later changing are nearly identical operations eg with "setter" methods on the Java objects.)

[2] stackexchange, efficiency of purely functional programming

• What kind of "better results" are you after? Better performance? Smaller code? – Dave Clarke Oct 3 '12 at 17:51
• xodarap says in his answer this question is subjective. =( on 2nd thought maybe it should be closed by rigorous stackexchange stds. – vzn Oct 3 '12 at 17:58
• If you fail to modify the question to make it clearer and less subjective, then perhaps it should be closed. The reason we have standards and request that posters comply to them is to maintain the level of quality of the site. – Dave Clarke Oct 3 '12 at 18:10
• I have removed a discussion about language issues. Please restrict meta comments to a minimum and open a thread on Computer Science Meta if need be. – Raphael Oct 4 '12 at 7:15
• I think this question (in improved form) may be better off on Software Engineering; please flag the question if you want us to be migrated there. It is also a good example of "not a real question" as it is subjective and it is not clear what is being asked. If you specified what "good" means (runtime or space efficiency, safety, security, ...) it would be a good question, imho. – Raphael Oct 4 '12 at 7:18