I've long been a fan of Lambdas and Functional interfaces introduced in JDK 8 but I felt that the Streams API added
significant complexity with insufficient return. Particularly, it is impossible to add new operators to the stream
API. Although the Stream API's approach of building a collection of stream operators allows the use of compiler
techniques to globally optimize a pipeline, it has insufficient visibility into the functions that it takes as
arguments to methods like map
and filter
to optimize as well as a relational database. The Streams API fails to
deliver efficient and scalable parallelism and, in the effort of doing so, neglects useful order-dependent operators such as
pairwise
and zip
Instead of creating a new interface for Streams Pidove implements a set of static methods that act on Iterable. Pidove offers nearly all the methods that the Stream API does and is compatible with Collectors from the Stream API. In addition to some unique operators such as a windowing operator, pidove also implements a operators of methods from Python's itertools such as accumulate and product. Other Pythonisms include an implementation of defaultdict as well as uniform indexing and length for common types as well as a range generator.
Unlike the Stream API, pidove has a sane strategy for closing resources. So long as an Iterable returns an Iterator that implements AutoCloseable, pidove will close it when an operation like collect, forEach, or asMap completes on a derived Iterable.
In addition to a powerful set of operators on Iterable, pidove includes static methods for composing functions, partial application, handling nulls, and controlling exceptions and more. All in a library with no dependencies other than the Java standard libraries.
over("bushfire").forEach(System.out::println);
sum(filter(x->x%2==0,List.of(5,3,4,19,75,6)));
collect(groupingBy(word->word.charAt(0)),words);