Functional Programming Is on the Rise
I&#x27;m concerned about the use of functional languages. I like them but they seem to be treated as an implementation, not a model, and as such can be very inefficient. I&#x27;ve used scala and like it, but basic stuff with flatmap etc can unfold to be a gross mess of code which, had I written it non-functionally, would be vastly more efficient.<p>I&#x27;d expect the compiler to do more work, perhaps with some additional hints from me, go get efficiency. SQL does this because it has to (not with total success) but with scala I have had to abandon &#x27;nice&#x27; functional stuff, which I like, to get speed. It&#x27;s disappointing. I shouldn&#x27;t be doing the compiler&#x27;s job. With a literal implementation, functional programming just seems inevitably expensive and that&#x27;s morally wrong (just cos computers are fast doesn&#x27;t mean cycles are free, and don&#x27;t quote the programmer time vs computer time stuff at me, wasting hardware can become <i>more</i> expensive as the number of machines increases).<p>Optimising FP to the extent I want is something I&#x27;m sure the compiler can&#x27;t do alone; it would require hints and pointers from the human.  The necessary optimisations would need to be from high-level functional transformations (eg. map f (map g x) -&gt; map f.g x), down to eg. escape analysis so as to not produce so much garbage, down to data layout to stop the thrashing the cache.<p>Also someone I worked with just went quite mad on it - FP should be used where it fits best, he forced us to use it exclusively, even when a procedural code would simply have been simpler and clearer. And faster too - the end result just crawled (it was scala btw). Not a fault of the paradigm but of overselling, and someone in dire need of common sense.<p>Multiple disclaimers: I&#x27;m not a scala expert and haven&#x27;t used it for a couple of years. I&#x27;m not an FP expert. What I&#x27;ve said above is a brief overview of a much larger and more nuanced criticism, which I don&#x27;t have time to give; I hope you see what I&#x27;m getting at. I have little experience with other FP languages so what I say is based on scala and maybe eg. haskell does the clever stuff.<p>Edit: tidied up.