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:
Functional programming supports lazy evaluation, parallel-programming and it is thread-safe. Functional programming is based on First-Class Functions, Pure Functions, Immutability, and Referential Transparency. Function composition, currying, monads, and recursion are functional programming techniques.
Functional programming is writing pure functions And a function without side effects is a pure function. A very simple definition of functional programming is this: writing a program only in pure functions. Pure functions never modify variables, but only create new ones as an output.
Functional programming is a programming style in which computations are codified as functional programming functions. These are mathematical function-like constructs (e.g., lambda functions) that are evaluated in expression contexts.
Java is a functional style language and the language like Haskell is a purely functional programming language. Let's understand a few concepts in functional programming: Higher-order functions: In functional programming, functions are to be considered as first-class citizens.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With