Or even better than using libraries for functional programming in Java, learn and use Scala. You can mix Scala and Java code where needed.
It does have functional programming constructs though
Clojure is a much better candidate for FP on the JVM.
11–20 of 30 posts
Or even better than using libraries for functional programming in Java, learn and use Scala. You can mix Scala and Java code where needed.
It does have functional programming constructs though
Clojure is a much better candidate for FP on the JVM.
Earlier quoted context omitted.
F# doesn't in fact make use of {co|contra}variance: it only needed generics. (Although F# used to run on .NET 1.x using its own implementation of generics - Don Syme designed both .NET generics and the F# language.) For type inference, you just need a sufficiently smart compiler, although it's much more useful if your language knows about generic types.
Thanks for clearing that up (I've yet to try F# in anger). I suppose pre-generics F# did similar type wrangling to Scala's?
I never used F# before .NET 2.0, but the techniques it used on 1.x could be interesting -- I'll see if I can find some old documentation...
Edit: There used to be a paper describing the technique. I can't find it now, but here's an old Don Syme announcement related to it: http://www.mail-archive.com/dotnet-rotor@discuss.develop.com...
Or even better than using libraries for functional programming in Java, learn and use Scala. You can mix Scala and Java code where needed.
java -jar clojure.jarOr even better than using libraries for functional programming in Java, learn and use Scala. You can mix Scala and Java code where needed.
scala != functional programming http://enfranchisedmind.com/blog/posts/scala-not-functional/ It does have functional programming constructs though Clojure is a much better candidate for FP on the JVM.
To those wondering why not move to Clojure or Scala instead of this approach, here is why I am holding back:
a) I have a mission critical enterprise app that is in maintainance mode. I need to enhance certain features dealing with concurrency -- my team can ramp up Actor model implementation in functionaljava or Jetlang faster than they can ramp up on Scala.
b) No doubt that Scala is actually better Java , but I am confident that later versions of JDK would catch up. The concurrency features of JDK 7 are pretty good.
c) did I mention the team -- its hard enough finding a good java programmer; imagine how difficult it would be to hire good Scala programmers from the small eclectic community of Scala programmers.
d) most of the enterprisey stuff my team develops doesn't require functional programming -- just reliable applications delivered within drop dead deadlines. Plain old Java gets me there . JDK 7 concurrency and various Actor model implementations in Java such as FunctionalJava, Jetlang , Kilim are just cherry on top.
Earlier quoted context omitted.
final boolean b = a.exists(new F () { public Boolean f(final String s) { return fromString(s).forall(isLowerCase); } }); It's here that I miss lambdas to make functional code at all readable.
exactly the example I was going to cite. In Scala this would be val b = a.exists(str=>str.forall(_.isLowerCase)) or val b = a.exists(x=>x.toLowerCase() == x) There's no way I'd start using functional programming in Java if it's this clunky. Just stick with Scala.
boolean b = a.any(λ(s, s.equals(s.toLowerCase()));
s and λ are statically imported.
Does anybody know if there is a library like this for C/C++?
http://sourceforge.net/projects/fcpp/
http://www.boost.org/doc/libs/1_45_0/doc/html/lambda.html
http://boost-spirit.com/dl_docs/phoenix-2/libs/spirit/phoeni...
Does anybody know if there is a library like this for C/C++?
The main ones I could find were FC++ and FACT:
http://www.cc.gatech.edu/~yannis/fc++/ http://hci.usask.ca/people/ragu/writings/FunctionalProgrammi...; http://www.fz-juelich.de/jsc/FACT/Old_Pages/fact_index.html http://www.boost.org/doc/libs/1_45_0/libs/functional/index.h... http://okmij.org/ftp/cpp-digest/Functional-Cpp.html or http://www.haskell.org/haskellwiki/Calling_Haskell_from_C...; :)