Simple Reactive Extension Style Support in Streams (original) (raw)
David Hartveld david at hartveld.com
Wed Apr 17 10:11:15 PDT 2013
- Previous message: Simple Reactive Extension Style Support in Streams
- Next message: hg: lambda/lambda: 11 new changesets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
There are several initiatives to 'port' some form of reactive extensions to Java. Netflix's is probably the most promising. It's open source, available at: https://github.com/Netflix/RxJava. Still under heavy development and feature-incomplete, but also used in production at Netflix (see their techblog, they posted a few blogs in January and February).
As for the possibility of basing a reactive stream library on the Stream API: The Stream API can be compared with LINQ to objects, or IEnumerable and its extension methods. These compare quite well in terms of general use
- however, there are also technical differences (there is a complete query expression tree model underlying LINQ in general, and these are reusable which streams definitely are not). Rx is LINQ to events, or IObservable & friends, which behave differently, and have radically different contracts. However, the Stream interface provides many 'query' methods which are applicable in both APIs (filter, map, reduce, flatMap, sorted, any/all/noneMatch, etc.). But, it also has several methods which do not make sense for reactive programming (parallel, sequential, unordered, perhaps even forEach, just to name a few).
I have been experimenting with an Observable extends Stream in combination with Swing. Take a look at these two projects:
- https://github.com/dlhartveld/reactive-stream
- https://github.com/dlhartveld/reactive-stream-swing Note that in the end, Observable would not extend Stream any more, as Observables now also have to implement the nonsensical methods.
Finally, I have started to prototype a universal Queryable interface, which would provide the basic operators (methods) that would apply to both an Iterable and an Observer here:
But if your question is whether JDK 8 will provide anything like Rx, I can predict with confidence that it will not, because it is out of scope for the Stream API (remember, it is just Iterable/Enumerable) and, more importantly, it would delay the release of JDK 8 significantly. Something for the future, perhaps...
Regards, David
On Wed, Apr 17, 2013 at 4:47 AM, Olexandr Demura < oleksander.demura at gmail.com> wrote:
For me, mere java user ignorant of outside world, it looks like streams already designed to be used pretty much similarly to Rx style (w/o publish to observers and exceptions handling)
simple name substitution: Select -> map ManySelect -> flatMap Where -> filter Aggregate -> reduce Run -> forEach ForkJoin -> parallelStream Since streams are read-once, they should not use notifications and events, but reactive style libraries should consider implementing (Base-)Stream to be generally accepted in java 8 world, just like http://code.google.com/p/reactive4java/ project states it will. Did I miss something? 2013/4/16 Suminda Dharmasena <sirinath at sakrio.com> > Hi, > > Is it possible to follow through with infinite streams and add helper > classes for (.net) reactive extensions style usage. >
- Previous message: Simple Reactive Extension Style Support in Streams
- Next message: hg: lambda/lambda: 11 new changesets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]