commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Ersoy <ole.er...@gmail.com>
Subject Re: [Math] Java version
Date Wed, 14 Jan 2015 20:12:00 GMT
Converting an example from the user guide using Lambdas (Not an expert so bear with me - And
note that the inputArray > inputStream):

BEFORE:

// Get a DescriptiveStatistics instance
DescriptiveStatistics stats = new DescriptiveStatistics();

// Add the data from the array
for( int i = 0; i < inputArray.length; i++) {
         stats.addValue(inputArray[i]);
}

AFTER:
DescriptiveStatistics stats = new DescriptiveStatistics();
inputStream.forEach( value -> stats.addValue(value));

And now we can use Java 8's map, reduce, filter, sum, parallel, etc. on the inputStream.

Part of the reason for the rapid growth of NodeJS is that developers like functional programming.
Constructs like forEach, filter, map, and reduce are popular.  This paper has a lot of great
examples
of things that can be done with these functions, and demonstrates adding simple concurrency
with parallel().
http://ref.c24.biz/whitepapers/Java-8-for-Financial-Services.pdf

Cheers,
- Ole


On 01/14/2015 10:16 AM, Phil Steitz wrote:
> On 1/14/15 4:38 AM, sebb wrote:
>> On 14 January 2015 at 08:18, Martin Grotle Soukup
>> <martin.grotle.soukup@gmail.com> wrote:
>>> Hi,
>>>
>>> My two cents in favour of java 8:
>>>
>>> IIUC the next major release will break backwards compatibility and aims to
>>> clean up the API. Taking a look at the release frequency of commons math
>>> [1], it shows releases every 9-12 months (give or take). Given that the
>>> next big release is a major one (4.0), this indicate that a release in 2016
>>> is a more likely target than in 2015.
>>>
>>> It might be the case that people use java 6 or 7 today, but the picture
>>> might be a different one a year from now.
>> Does Java 8 offer any benefits to the user?
> No one has said much about this.  Could be some APIs could be
> expressed better, but no one has provided any examples.
>> i.e. if CM is released for Java 7 or Java 6 would that impact on
>> people running Java 8?
> No, unless they want to see language features used that are not used.
>> As a comparison, libraries that have not been updated to Java 5
>> generics do make a difference to Java 5+ users.
>> But enhanced for loops have no direct impact on the user.
> There are really three things to think about when deciding whether
> to require JDK x+
>
>   1. Are there things you can't do / express without JDK x?
>   2. Does requiring JDK x+ cut out a large portion of the user base?
>   3. Are there a lot of things that are easier / simpler / more fun
>      to implement in JDK x+?
>
> Items 1. and 3. really impact developers and contributors; but being
> too far out in 2. can indirectly influence that as well.  We went
> for a long time requiring only 1.5 because there really was nothing
> material for [math] in 1. and 3. included only a few things (most
> commonly the compat bug I introduced in 3.4.1 due to missing array
> copy, which is something we do a lot in [math]).
>
> I think Martin's point on timing is a good one.  The last time I
> looked at stats, the thundering herd was still 6-7.  Could be by the
> time we actually cut 4.0, that will have changed.
>
> It would be great though if someone could give some positive reasons
> that JDK 8+ features really help us.  I am still in the 7 camp, due
> to where the users are now; but if there are compelling 1. or 3.
> things, I would be OK bumping to 8.
>
> Phil
>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message