4 ms·
On one end we have FP, which is great for expressiveness and its declarative nature of getting things done, side-effect free, with nearly perl like terseness :)
by martin1975 7y ago
On one end we have FP, which is great for expressiveness and its declarative nature of getting things done, side-effect free, with nearly perl like terseness :)... but on the opposite end you have von Neumann CPU architectures which know nothing about FP. The utopian "silver bullet" is always something in the middle of course, a language that can give you the power and expressiveness of FP without sacrificing all the things that FP style compels you to bear - like mutability, performance optimizations/fine tuning, etc.
Personally, I find languages like Scala to be right there in the middle, where neither performance nor FP expressiveness is sacrificed severely.
That makes Scala flippin complex like C++ was, but it is probably the best attempt to bridge this gap if we all just want to learn "one language to rule them all" and incorporates both FP and imnperative/mutable style techniques that milk the hardware for what it's worth as well as give you the power/expressiveness of FP.
Of course one can write an operating system in Haskell... just as one can imitate functional style programming in C... or we can come up w/some "middle ground" language that takes the cake from both worlds and call that "the best".
My point is, this quest or journey for the best language/paradigm never ends and always shifts across the years as hardware develops and as we discover better ways of doing more with less (e.g. the crux of FP).
IMHO, ultimately you have to pick an appropriate language (tool) for the job at hand. If we forget that languages/programming paradigms are just tools... then, you'll forgive me for saying, we become tools ourselves. Or... fools, rather.
To me, whomever has realized this trade-off, is a true zen master of programming/engineering...not the one who espouses one paradigm/language over another. That's just me tho... YMMV.
- lalaithion 7y agoIs Scala really that much more performant than Haskell? I haven't done much high performance computing in either, but the Scala compiler is significantly slower than the Haskell compiler (both self hosted).
- randomidiot123 7y agoSlower compilation doesn't mean slower execution. Scala has "Native" and JVM implementations with different performance characteristics. Scala is a hybrid that allows imperative code with a lower level of abstraction than Haskell, closer to hardware. Thus it is potentially more performant.
- jolux 7y agoSure, but has it been benchmarked? From what I've seen on the benchmarks game GHC is neck and neck with the JVM in most stuff, which is damn impressive. That is admittedly a silly comparison, though.
- randomidiot123 7y agoOf course they have been benchmarked. Both compile to native code, so performance can be roughly the same if the algorithms are the same. However, figuring out how to design a Haskell program that reaches maximum performance is very difficult, and the code probably won't be idiomatic.
- jolux 7y ago> Both compile to native code, so performance can be roughly the same if the algorithms are the same. Can and will are very different statements here though, particularly as the quality of a compiler makes an enormous difference in the performance of the resulting code.
- lalaithion 7y agoMy point is that both compilers are written in their own languages. If scala could be performant, surely the compiler would be too?
- iLemming 7y agoJVM can be extremely performant, although sometimes memory hungry. I haven't done any Scala, but I've tried comparing Haskell and similar Clojure code. Most of the time it was easier to write more performant Clojure code, and accidentally write Haskell code that was not as performant. I have to admit though that my Haskell knowledge is pretty weak.