3 ms·
C++'s generic-programming feature still has shortcomings - I think functional-programming has more relevance to scientific computing, but C++'s functional featu
by DaiPlusPlus 9y ago
C++'s generic-programming feature still has shortcomings - I think functional-programming has more relevance to scientific computing, but C++'s functional features are "okay" but still not as capable or proven as, say, Haskell's or OCaml's - for example for tail-recursion you still depend on the compiler supporting that optimization, you can't force it or necessarily assume it will happen, with fun consequences for your stack if it doesn't.
- sidlls 9y ago> I think functional-programming has more relevance to scientific computing What do you base this on?
- beisner 9y agoFunctional languages force you to be more correct, more often. Eliminates a bunch of classes of bugs which are anathema to scientific computing, and are generally so high level that compilers can optimize extremely aggressively. Also, scientific programming is usually much more about data flow and transformation, which is FP’s wheelhouse.
- sidlls 9y agoDo you have examples where it is the case that FP code yielded a superior scientific result?
- DaiPlusPlus 9y agoOutput results would be the same - that's concerned with program correctness, regardless of whether it's written in a function, object-oriented, or procedural paradigm. It should instead be compared with how long it took to engineer and build the system or program in a particular paradigm and the qualitative engineering aspects of a particular platform. FP may be amazing for certain areas, but a difficulty in basing a large-scale project or business on it would be hampered by the small supply of developers who can comfortably program in it.
- HelloNurse 9y agoFor scientific computing, whether a language has very advanced or merely okay functional features is only a superficial style issue. Regarding more important performance issues like low level control of memory layout and avoiding pointless copying and indirection, C++ and Fortran are both at the most effective end of the spectrum, while typical functional languages lie between "don't even think about it, by design" and "it might be OK but only a fool would put a project at the mercy of what optimizations a relatively unproven compiler opts to do".