Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are your experiences using the functional java project?

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?
like image 352
Elijah Avatar asked Apr 20 '09 03:04

Elijah


People also ask

What is the use of functional programming in Java?

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.

What is your take on functional programming answer?

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.

What is functional approach in Java?

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.

Is Java good for functional programming?

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.


1 Answers

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.

like image 90
Apocalisp Avatar answered Oct 13 '22 21:10

Apocalisp