Abstract: “Functional programming has traditionally been considered elegant and powerful, but also somewhat impractical for ordinary computing. Proponents of functional programming claim that the evolution of functional languages makes their use feasible in many domains. In this work, a popular imperative language (C++) and the leading functional language (Haskell) are compared in a math-intensive, real-world application using a variety of criteria: ease of implementation, efficiency, and readability. The programming tasks that were used as benchmarks involved mathematical transformations between local and global coordinate systems. Details regarding the application area and how language features of both languages were used to solve critical problems are described. The paper closes with some conclusions regarding applicability of functional programming for mathematical applications.”
It is very nice that people are trying to compare imperative and functional languages under measurements that mostly people are interested: lines of code and performance.
I just skimmed through the text and found some downsides, namely:
Still, I’m glad to see an effort to compare the implementations from a “standard programmer”.
It isn’t a problem if the structure has O(n) random access if you don’t access it randomly, i.e. recursion over a linked list is the same as looping.
Yeah I couldn’t tell how they implemented the haskell algorithms, so it was hard to deduce if the haskell was slower due to using improper constructs or not. It can be really easy to make things slow in haskell if you don’t understand the transformations behind things. Also hard to tell why its slow without a dump of the assembly.
I’m not a fan of papers that don’t provide source, doesn’t make any findings all that useful. Just looks like a filler paper if I can’t poke around.
It seems when they say “functional” they mean “purely functional” or “haskell”.
Is haskell the leading functional language? It seems like there are several ahead of it: scheme, ML, erlang, maybe prolog, maybe swift depending on your definition of functional.
Lastly, I’m not sure it’s fair to compare C++, a language without a GC, with Haskell which does have a GC. Certainly if you were really interested in comparing functional vs. imperative languages, I’d want to see a larger variety in the mix.
Referential transparency is a pretty central concept in FP. Every modern language can let you have basic pattern-matching and first-class functions. But that’s not functional programming in and of itself.
You certainly can program in a functional style in, say, Scala, but it ends up looking like really ugly Haskell code anyway. Other times you’re usually just using first-class functions as someone might drop in English terms when speaking their native non-English language.
It’s pretty common to think of Haskell as the functional language since it’s both pure and widely used. The fairness is questionable. Of the imperative languages, C++ is the goto choice for programming in the large that has to be efficient. It’s flexible enough to do a lot of different styles. The fact that Haskell has a GC is a language, design choice on their part. C++ offers several options. If the design slows it down, then that’s just what they chose. That Rust has some features of functional language without a GC might make it a nice alternative, though. Might even be able to do both imperative and functional version in it.
Is the resulting C++ and Haskell source available somewhere?
I gave up trying to find it shortly in due to how University of West Florida’s website is laid out. Most can take me right to the publications and software. It’s like they’re trying to hide their work behind a bunch of sales pitches. Coffey’s page was interesting in that he did a bunch of work on knowledge bases and cognitive applications. If not paywalled, his work on knowledge elicitation and representation might be submission-worthy.