August 23, 2015

LambdaOmega 0.1 RC-1 released!



I’m happy to announce that LambdaOmega, a more concise Java collection and functional API, 0.1 RC-1 has been released and 0.1 RELEASE is imminent. In this blog post, I’d like to show you what’s in the current release and what is yet to come in the near future.

Update June 12, 2016: LambdaOmega 0.3 is now officially released. Read the update post here.

I kindly invite you to take a look at LambdaOmega’s GitHub repository to find the current project status and usage information, or take a look at the API docs if you’d like to dive in into the technical details.

What is LambdaOmega?

  • It’s a wrapper API to make usage of Java collections, lambdas and CompletableFuture more simple, concise and enjoyable, as inspired by Groovy and JavaScript / lodash.
  • It provides simple Ranges and 2d Vectors.
  • It perfectly fits unit tests where fluid, maintainable code is key.
  • It has a small footprint (JAR < 85KB) and no other dependencies.
  • It’s thoroughly tested (coverage > 80%).
  • It comes with human-readable documentation.
For more information, you may read my introductory blog post as well.

What’s currently part of LambdaOmega

A simple yet powerful List / Map API

The heart of LambdaOmega is the L class which is a wrapper for a Java List
L<Integer> myL = l(0, 1, 2);
and the M class with is a wrapper for a Java Map.
Map<String, Integer> map = m("a", 0).Insert("b", 1).i("c", 2).m;
As of now, both classes provide the complete functionality of their vanilla Java counterparts, but with enhanced method signatures and return types:
List<Integer> outcome = l(0, 1, 2).add(3, 4);
Where sensible, there are “immediate” and “terminal” variations of a method, returning either another wrapper or the final result:
L<Integer> modifiedList = l(0, 1, 2).Add(3).Add(4, 5);
The most commonly used functional operations (with lambda expressions) on Stream have been implemented on these wrappers:
List<Integer> list246 = l(0, 1, 2).Map(it -> it + 1).map(it -> it * 2);
Although inspired my Java Collection / Map, a new API has been built from scratch, allowing Map-like access on a L and List-like access on a M:
String c = m("a", 0).i("b", 1).i("c", 2).indexOf(2);
With version 0.1, the main work on L, M, the super class C, and their interfaces is finished.

Additional data structures: Ranges, vectors

The R class represents an int range. It’s basically syntactic sugar to create ranges using the Java 8 stream API.
List<Integer> list012 = r(0).to(3).list;
The V2 class represents a 2-dimensional vector = a 2-ary tuple:
V2<String, Integer> vector = v("a", 0);
With version 0.1, the main work on R and V2 is finished.

FunctionalInterface transformations

The F class is built to encapsulate and unify the 40+ implementations of FunctionInterface in Java, wrapping a common API around any FunctionalInterface implementation.
int two = f((Integer it) -> it + 1).call(1); // Function
int three = f((Integer x, Integer y) -> x + y).call(1, 2); // BiFunction
boolean yes = f((Integer it) -> it > 0).call(1); // Predicate
Currently, the basic 1- and 2-ary Function, Consumer, Predicate, and Supplier are supported.

Support for additional FunctionalInterface transformations is planned for future releases.

A better CompletableFuture API

The Promise class is a drop-in replacement for CompletableFuture. It streamlines its API and provides fixes for the API flaws discussed here.

With version 0.1, the main work on Promise is finished.

RELEASE plans

  • 0.1 RC-1 is out now
  • If there are any error reports, these will be fixed and incorporated into a RC2 at ~ August 30
  • 0.1 RELEASE will be available either at ~ August 30 (unless there’s a RC2) or ~ September 6.
The RCs really are just tags, not branches. Until the 0.1 RELEASE, no new functionality will be built in, only bugfixes. This makes managing this small project a lot easier.

Future plans

Future plans primarily consist of adding features to the existing API. As such, the existing parts of the API should stay stable.

V. 0.2: F++

  • Support for all FunctionalInterfaces and more transformations in the F class.

V. 0.3: S++

  • Fully implement S (Set)

V. 0.4: Final touches

  • Add more utility methods if sensible
  • Add more syntactic sugar for existing methods where sensible
  • Clean up minor disputed parts of the API
After that, there will probably be a version jump to 1.0, marking the API “finished”.

Please keep in mind that this is a private project of mine. I will work on it as long as I think it’s fun and useful. Any kind of feedback, encouragement and collaboration is welcome! Feel free to leave me a comment down below with any question, suggestion or general feedback you may come up with.

Update June 12, 2016: LambdaOmega 0.3 is now officially released. Read the update post here.

No comments:

Post a Comment