groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russel Winder <rus...@winder.org.uk>
Subject Re: GPars 2 Stuff
Date Mon, 08 Jan 2018 10:30:26 GMT
On Mon, 2018-01-08 at 08:21 +0530, Balachandran Sivakumar wrote:
> Hi Dr. Russel,
> 
> On Thu, Jan 4, 2018 at 12:20 AM, Russel Winder <russel@winder.org.uk> wrote:
> > In GPars 1.X it was possible to do things such as:
> > 
> >     [1, 2, 3, 4, 5].parallel.reduce{a, b -> Math.min(a, b)}
> > 
> > Without GPars it is possible using Groovy to achieve the exact same
> > functionality on JDK8+ with:
> > 
> >     [1, 2, 3, 4, 5].parallelStream().reduce{a, b -> Math.min(a, b)}.get()
> > 
> 
>     The GPars way is a lot more terse and more "functional" than the
> JDK8+ way. As a user, we don't have to know whether the underlying
> stuff is a parallelStream or ParallelArray(like it is in GPars 1.x).
> So, I would prefer to retain the API, but base it over streams instead
> of ParallelArrays. Thanks

I guess it depends on the definition of "functional": in the sense "functional
programming", no Streams and the use of Optional is correct; in the sense of
"works for me" I guess it is personal choice!

-- 
Russel.
==========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk

Mime
View raw message