views:

211

answers:

1

I was reading the following question - How safe would it be to use functional-java to add closures to a Java production project? and I had been thinking of using the Functional Java project as well in my current project. I was wondering what are Stack Overflow's users experiences with using the Functional Java project? In particular, I'm curious about some of these specifics:

  • Did it increase code quality or clarity?
  • Improve productivity?
  • Reduce potential points of failure?
  • Impact performance?
+4  A: 

I've been on a team that uses the FJ library, and I know of others. On one team it was used as a replacement for a home-grown library that was less polished, on another it replaced Google Collections. I also know some folks that copycat the source code from FJ to roll their own implementation.

In my opinion, if you must use Java, you should be using something like Functional Java to make your life easier.

Did it increase code quality or clarity?

Code written in a functional style is more concise, hence more clear. The library comes with, and encourages the use of, immutable data structures, which improves quality. The library also encourages composition over inheritance, which improves the reusability of your code.

Improve productivity?

Definitely. Developers with more powerful tools are more productive. In my experience developers feel that first-class functions make programming easier and more enjoyable. Happy programmers are productive programmers.

Reduce potential points of failure?

A more functional style of programming discourages mutable state, which eliminates a large class of bugs. Also, more powerful abstractions lead to less repetition, which reduces the number of places where something is wrong.

Impact performance?

There's no reason to believe that performance would be impacted one way or the other. The provided datastructures are designed for ease of use and expressiveness rather than performance, but they're written optimally for what they are. As with anything else, how you drive is more important than what you're driving. For example, fj.data.List is a linked list, so it has O(n) random access and concatenation, therefore you avoid it for those purposes. fj.data.Stream has O(1) concatenation, by comparison.

Apocalisp