State of the collections

Hi all,

I'm working on the second major release of Javaslang, a functional component library for Java 8+.

Thanks to Ruslan Sennov, Patryk Najda and other helpful hands, the immutable Javaslang collections are evolving fast. I'm really proud of the results. This is a simple example:

import javaslang.collection.Stream;

Stream.from(1)               // 1, 2, 3, ...
    .filter(i -> i % 2 == 0) // 2, 4, 6, ...
    .sliding(2, 2)           // (2, 4), (6, 8), (10, 12), ...
    .take(2)                 // (2, 4), (6, 8)
    .stdout();               // print to console

// output:
// Vector(2, 4)
// Vector(6, 8)

Compared to Java 8, Stream results are not collected. Javaslang's Stream is a collection by itself - a lazy evaluated linked list. The operations are deferred until elements are requested. This makes it possible to create Streams of an infinite number of elements, like prime numbers.

Javaslang 1.x currently has List and Stream. Javaslang 2.0.0 will include a full-blown immutable collection library.

The base interfaces javaslang.Iterable and javaslang.Value added operations like sliding, forEach, isEmpty, map and flatMap to many types. Value abstracts over defined and undefined/empty state and closes the gap between controls like Option, Try, etc. and collections.

Value<Integer> val1 = Try.of(() -> { throw new Error(); }); -> i + 1).isEmpty(); // = true

Value<Integer> val2 = List.of(1); -> i + 1).isEmpty(); // = false

Currently we focus on the backing data structures. Ruslan added the HashArrayMappedTrie, known from Clojure and Scala, for HashMap, HashSet and Vector. I am working on a fast Red/Black Tree implementation, based on publications of the last few years, for TreeMap and TreeSet.

The collections are created from the scratch, Javaslang is still under heavy development. I'm really looking forward to see 2.0.0 in production - soon!

- Daniel