Java Lambdas Finalised!

[quote]I’ve managed 30 years without needing closures.
[/quote]
I guess enough said for everyone who didn’t need closures before wonders if he/she should care about this addition.

Also: It just seems to me that closures just allow stuff to be able to be compiled, but can very well fail at runtime. A thing java usually tries to avoid, and is praised for, in comparison with C++ for example.

When using libs they may force you to use these new featues.

I think I agree with gouessej. Java sourcecode is something I can read like a book. For me Lambda expressions are visually like nested ?-:-expressions. I hope I can get used to it.

PS: :slight_smile: first post, hello there :slight_smile:

Yeah I don’t use ? : just because it’s hard to read.

I guess enough said for everyone who didn’t need closures before wonders if he/she should care about this addition.
[/quote]
Most people have lived for decades without the internet, does that mean we should get rid of it?

I guess enough said for everyone who didn’t need closures before wonders if he/she should care about this addition.
[/quote]
The last 30 years does not give a good guide to the next 30 years! 8) Moore’s Law is coming to an end, etc., etc. http://www.ordina.nl/nl/~/media/Files/Markten/Technologie/Masterclass%20Brian%20Goetz%20%20Project%20Lambda.ashx?forcedownload=1 is interesting.

I have to say I’m at least in partial agreement with Cas’ comment earlier - we may just be papering over the cracks.

The last 30 years does not give a good guide to the next 30 years! 8) Moore’s Law is coming to an end, etc., etc.
[/quote]
People have stated Moore’s Law has been coming to an end, repeatedly, for the last 30 years. We have at least another 10 years to go until we reach the physical barriers for miniaturizing transistors. By then we should have new methods for yielding larger, or layered chips, which will allow Moore’s Law to continue for much longer.

People have stated Moore’s Law has been coming to an end, repeatedly, for the last 30 years. We have at least another 10 years to go until we reach the physical barriers for miniaturizing transistors. By then we should have new methods for yielding larger, or layered chips, which will allow Moore’s Law to continue for much longer.
[/quote]
To an end was perhaps too apocalyptic a way to phrase it ;D , but I think the concept of what it means for us is changing. To quote that Oracle PDF I linked to

[quote]Chip designers have nowhere to go but parallel – Moore’s Law gives more cores, not faster cores
[/quote]
which, right or wrong, seems to be a key reason behind Oracle’s decision to include closures in Java now.

Thank you, after reading this I feel confident that closures will be a convenient feature. BTW I like the syntax in this presentation more :)…

I love how they show anonymous inner classes with no highlighting, then lambdas with highlighted text. ::slight_smile:

Lambdas murder readability when used extensively for loops. I curse every time I have to dig into C# where someone went balls out with lambdas unnecessarily. They probably do improve readability in other cases. I guess it will become just another thing to add to coding standards documents.

Is the method reference stuff going in Java?

That article from Oracle does explain things quite neatly, and I can see that it is quite neat. Wonder how I’ll be applying it to the sort of noddy coding I do for games. Probably won’t :slight_smile:

Cas :slight_smile:

Dito!

[quote] Now they’re going to co-opt a few more ascii characters to do something that makes not a lot of sense and does even more trickery under the hood. Oh well, not much we can do about it.
[/quote]
Yup. IMHO not much else then ‘language x has y feature so we need it to, or else people won’t think we are cool’.

Agree 100%
People want to turn Java into a different language, one where you don’t ‘have to type as much’.

Huh? Isn’t he just highlighting what he’s talking about (these being slides after all).

From the email that Kappa originally linked to (emphasis mine)

[quote]… have not yet come to a decision on method reference syntax.
[/quote]
which to me means, yes. I also presume that the extension mechanism for interfaces is also going to come in, which would be great.

Incidentally, I found this PDF by accident while googling for an old blog post I read on all this (which I still haven’t found!) - pretty useful find. And the naysayers around here should look at the cartoons near the end - I’m picturing all your faces in that crowd! ;D

Thanks for the PDF. It is less bad than I thought but I will stay far from lambdas as it does not match with my natural way of programming. I agree with using predicates, reducers, etc… but with anonymous inner classes.

Just sayin’! :slight_smile:

The implementation of lambdas is not based on inner classes, I know what the sentences above mean. However, what lambdas do can be done with inner classes and I hope that future APIs won’t force programmers to use this feature like in this case:


students.filter(new Predicate<Student>() {
             public boolean op(Student s) {
                    return s.gradYear == 2010;
             }
       }).map(new Extractor<Student,Double>() {
              public Double extract(Student s) {
                     return s.score;
             }
       }).max();

You ask me, that last bit of code demonstrates the use case for lambdas right there. That sort of thing is a one-liner in every other language that matters that I can think of. Syntax does matter.

I think the implication of that statement is that there is the potential to get better performance than inner classes. At least that’s what I gather from what else I’ve read. If anyone can elucidate how and why, please step in!

Yeah but honestly it would have been better to write


select max(score) from students where gradYear = 2010

wouldn’t it? It does seem to me that introducing SQL as a first class syntax in Java would have been a whole lot nicer. Maybe some less kludgy examples would help illustrate the point, but honestly I’m just as happy with the code as it is because it’s trivial to see what it’s doing and understand it despite what all the detractors say.

Cas :slight_smile:

I’d agree, if only so I can have DB SQL queries validated at compile time.

It would also be nice to see some original ideas in Java, rather then just stealing them from C#.

I was doing that in Powerbuilder nearly 20 years ago :frowning:

Cas :slight_smile: