Is Functional Programming really slow?
josipbakic.wordpress.com
josipbakic.wordpress.com
Technically, I can write efficient code in either OO languages or functional languages, but I've found that for scientific software, meaning PDE solvers or optimization solvers, it's easier to do that in a functional language because the language encourages it. And, no, I'm not ignorant of the issues with writing low level dense linear algebra solvers. Those solvers I do write in C, then I link it out using a foreign function interface. Basically, the right tool for the right job.
First, functional != lazy evaluation. We can once again thank the Haskell converts for further trying to redefine what "functional" means to match Haskell's featureset (which began with purity... I'm waiting for Hindley-Milner to gradually become a requirement).
In fact, laziness in the context of OOP is a very natural fit as the paradigm encourages encapsulation and state hiding. Build the right interface (basically one that looks like consuming items from a stream) and you could swap out approaches largely at will.
Second, laziness is the source for a huge number of performance issues in Haskell. Show me a high performance Haskell program and I'll show you one whose developer probably banged their head against a space leak and found themselves littering !'s throughout their code.
After all, several factors key to the concept have indubitable costs – garbage collection is a must
I'm trying to avoid being snarky, but all I really want to point out that if one doesn't understand the benefits and drawbacks of GC's, perhaps your opinion on performance of FP might not be very accurate.Has anyone done FP in Rust? What was memory management like?