News11/05/2009: fluentjava 0.3 Released.
The whole EnumerationProtocol was implemented, as you can see here, with a little closure coercion as well. Fluent Sets, Fluent Maps and Fluent lists can be easily be created from other collections libraries. Lazy methods on enumeration protocol, so that you can cascade, filter, map, take and only invoke the actual closures when you actually need the result. And much more.
Get started here.
IntroductionProject that attempts to reduce the verbosity, lack of fluency and unfriendly interface that is common to several tasks in Java, such as:
Blocks of code manipulation (Closures) Collection manipulation Reflection Input/Output Raw Type conversion Next few StepsReally planned list Deprecated as 14/01/2010 by Mark Reinhold's assertion that lambda expressions or even full blown closures will be brought to java7. Ok, evidences are (here, here and here): java 7 will very likely not have closures, which made me reconsider adding it to this project, while making it backwards compatible with all the bringing closure to java attempts. Automatic object to Closure coercion is vital to this, and little AOP can make it even more fluent. New File-like returning reades/writers, streams, and ExtendedIterators for paths and lines of content for simple files/Files for directories (many features are already included on commons-io, but all as top-level functions). Fluent style. Make Files a Composite: File-like structure composed of folders and files. Mirror getting Maps as input/output Mirror being able to convert types like Spring does on its IoC Fluent output. System.out just doesn't cut. Also use Xstream to allow output of any object in XML format. Generic Decorators that turn any object into Serializable (via Xstream in the generic case) and Comparables (receiving Comparators) Create Order objects, which require only lessThanMethod to be implemented (no more 0, -1 or negative, or +1 or positive that Comparators need). Comparator built from Orders. Inspiration: Python. General ConceptsA few links to clear things up.
Fluent Style and DSLs: http://martinfowler.com/dslwip/ http://martinfowler.com/bliki/FluentInterface.html Closures: Article that introduces closures and its uses, using apache commons: http://www.ibm.com/developerworks/library/j-fp.html Martin Fowler's post on the uses of closures and collections: http://martinfowler.com/bliki/CollectionClosureMethod.html No closures in java: http://weblogs.java.net/blog/brucechapman/archive/2008/03/anouncement_no.html Enumerable in ruby: How closures are usefull. Scala also has its own enumeration protocol. Closures in Smalltalk: where all the oo + functional rage began. Also, they are called blocks here. Functional java is a project that aims to prepare the Java programming language for the inclusion of closures, and would benefit from java incorporating the BGGA implementation. Groovy also makes good use of it. No need to wait for closures on java to use the project above. It is not pure java though. Fork join javadoc: filter, map, find, etc. Not only are they usefull for expressing, but IBM has made it clear that they work very well with closures, and are great at making common tasks trivally parallel. Unlike closures, this made through the cut into java 7. Similar ProjectsApache Commons (formerly known as Jarkata Commons): similar feature-wise mostly to the features encompassed by commons lang, commons io and commons collections. Jaggregate: great project of Smalltalk-like collections. The project has its downfalls though, such as using Java collections classes names, which can be confusing. Generic algorithmns for java: closure api to Java. Still not as terse as real smtalltalk, python, ruby or scheme's syntax, but provides quite a few pre-made closures. Google collections: also provides some closures, not as much as jga. Has several kinds of collections though, and several utility methods on them as well. Hamcrest Collections: very fluent interface for collections. Development is still at the beginning, and uses a lot of Global Scoping technique, which mostly comes from Hamcrest. http://functionalj.sourceforge.net/: Another project that tries to bring functional programming to java world. Yeah google did it a long time ago, and Hadoop did it again. Yes, map and reduce are functional concepts. gparallelizer By using Groovy, it wrapps around Fork-join and make it more usable.
Copyright © 2013 Black Duck Software, Inc. and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a Creative Commons Attribution 3.0 Unported License . Ohloh ® and the Ohloh logo are trademarks of Black Duck Software, Inc. in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.