I have been considering learning Haskell seriously. It really is sweet in many ways. And I'm getting tired of Java politics. Maybe just a phase I'm going through.
But in any case, I thought, "Wouldn't it be sweet if purely functional meant that Haskell caches useful tidbits automatically for fast performance?" The answer is that it doesn't, but you can cache (er ... memoize) results manually. The complaint being that caching everything would be expensive for memory.
Well, if someone made a cool VM for Haskell, couldn't it learn the hot spots in code from watching it run, and thereby know more easily what to cache? Maybe HotSpot can't do this particular optimization so easily (Java not being purely functional or anything), but it definitely made me think about the mentality of prior vs JIT/lazy optimization. Hmm, and there's that lazy word again.
Anyway, back to doing statistics and plots in MATLAB.
D has pure functions
ReplyDeletehttp://www.digitalmars.com/d/2.0/function.html
Adding @Pure to Java would enable the compiler to check if the function is pure and enable the VM to cache the return values (and GC them if they are not used, or cache them only if the function is hot)
Would be a nice optimization.
Peace
Stephan
Programming is hard - http://www.codemonkeyism.com
Thanks for the pointers and ideas.
ReplyDelete