How safe would it be to use functional-java to add closures to a Java production project?
Asked Answered
I

6

6

I would love to use closures in Java. I have read that they may or may not make it into Java 7. But an open-source project called functional-java has implemented functional features including closures.

How safe would it be to use such a library in an enterprise production app?

Is there a better way to add closures to Java currently?

Infusionism answered 20/4, 2009 at 3:11 Comment(1)
You could try using scala or clojur insteadSiracusa
D
6

Closures will definitely not make it into Java 7, due to a lack of consensus around a single implementation. See here.

The Functional Java library is thoroughly tested and actively developed. If you browse the source you will see that it's just simple bog-standard Java, and there's not a lot that could go wrong. I know at least one mission-critical enterprise app that uses it in production. This application has more than a million users.

Go for it.

Disallow answered 20/4, 2009 at 4:33 Comment(0)
I
4

Functional Java does not requires that you use closures -- the source compiles with any Java 1.5 compiler. Functional Java is far more complete than Google collections and just happens to allow you to use it well with BGGA.

Hope this helps.

Incalculable answered 20/4, 2009 at 4:54 Comment(0)
M
4

I think you are looking at this issue from the wrong perspective.

I would love to use closures in Java. ... How safe would it be to use such a library in an enterprise production app?

Your decision making on what technology to use in an enterprise production app should be based on what is going to be best for the enterprise in the long term. You should be asking questions like:

  • Is adding the technology going to significantly improve the app from the standpoint of functionality?
  • What are the risks to the current project?
  • Does the technology claim to be "production ready"?
  • Is the technology supported. Is it likely to still be supported in 5 to 10 years time?
  • If you leave the company, is someone else going to take over maintaining your code?
  • What are the training / recruiting implications of using the technology?

In general, statements like "I would love to use Xxx" should have no place in enterprise decision making. (There are counter-examples; e.g. startups that bet the company on some new technology, but the real success rate is ... umm ... open to speculation.)

To sum it all up, if you are building enterprise production apps, you need to be conservative, and resist the temptation to use shiny new technology "for fun". Try to think like an IT manager.

Meilhac answered 13/9, 2009 at 0:9 Comment(0)
A
2

If you are looking for a lighter solution to have closures in plain Java check out the lambdaj project:

http://code.google.com/p/lambdaj/

Angi answered 12/9, 2009 at 7:30 Comment(3)
Lambdaj was, the last time I tested it, pretty slow. Honestly, I was really disappointed by this because I was hoping to make use of it.Fiberboard
Which version did you test? In which feature did you find it slow? Of course you have to pay something for the use of proxy and reflection, but the performance loss is quite well documented and in the biggest part of the cases is very reasonable.Angi
I wish I could answer your questions, but I didn't make not of much when I tested it. I seem to recall is was 3-5x slower for the use case I was testing it on... and that that case was something I'd use it for (ie, close to something I'm doing in production code), but not more than that. I truly wish I could be more specific, but it was a couple months ago and I didn't take much in the way of notes.Fiberboard
L
0

BGGA is still a prototype implementation, not sure how comfortable you are putting prototype code into production. check out google collections it gets you closer to the goal albeit more verbosely

Leyte answered 20/4, 2009 at 3:29 Comment(4)
Interesting but it doesn't seem to have anything like closures - just collections.Infusionism
Functional Java does not require BGGA, but does support it.Disallow
Google Collections does have a Function<A, B> type, and most of their collections implement a functor. Functional Java's collections implement functors as well as monads, cofunctors and comonads.Disallow
yes, depends on what you are shooting for . Trying to do full fledged functional programming in java would be clumsy and inelegant at best. Google collection nicely fits that gap for collections in java wayLeyte
U
0

Too old question to answer. Here we have lambdas in java8 to make your life easier.

Unknit answered 19/11, 2015 at 16:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.