I do mostly some numerical/physical simulations in C/Fotran/numpy and I use Java (especially Processing and jMonkey ) just to get some real-time interactivity during prototyping of code.
Recently I've read about new features of Java 8, namely:
- Lambda expressions (watching this video )
- proposed support of parallelism, heterogeneous computing ( GPGPU, OpenCL ) called sumatra project
To me it seems a bit contradictory - Functional programing and numerical performance. Maybe it is just my naieve prejudice.
Typical argument is like:
Functional style declarations make the code easier to paralelize and give compiler greater optimization oppurtinities than strictly sequential loops and mutable data types
OK, in theory it make sense, but in practice it seems that common Number-Crushing operations are much slower in functional programing languages like haskell, Erlang, Clojure and List than in imperative languages like C or Java. Probably this has something to do with the fact that you pay a lot of operations for abstraction - the functional constructs are just too far from machine code and how processors works. That's why I was never interested in functional programing.
So my question is:
- what to expect from functional programing in Java 8. Should I care and try to learn if my area of interest is performance critical numerical code?
- Is there, or is there not a performance penalty for using functional constructs instead of normal imperative code with loops ? ( I mean in simple tasks, like testing of prime numbers, or computing dot_product )