SlideShare a Scribd company logo
Dori Waldman

Lambda Expressions

CompletableFuture

Method References

Functional Interfaces

Default Methods

Streams

Optional Class

New Date/Time API
...
Agenda
Functional programming: “Lambda allow us to treat functionality as a method
argument (passing functions around)”
Syntax:
1) Infers syntax : return / type / {} / ()
Integer sub = (a, b) → a – b; // no need to write (int a, int b) -> { return a * b; }
Arrays.asList( "a", "b").forEach( e → System.out.println( e ) );
// no need to write ((String)e) → ...
Lambda (→)
Lambda (→)
2) Function as parameter
Lambda (→)
3) Eliminates the need of anonymous class
4) Make code more immutable
Lambda (→) , the bad parts
https://dzone.com/articles/whats-wrong-java-8-part-ii - be aware of auto-boxing
System.out.println((x -> x / 100 * (100 + 10)).apply(100)); // java does not know type of X
System.out.println((Integer x) -> x / 100 * 100 + 10).apply(100)); // → is a function , java does
not know Function type
System.out.println(((Function<Integer, Integer>) x -> x / 100 * 100 + 10).apply(100));
* Auto-boxing means automatic convert between primitive and object
To allow functions to take lambdas as arguments, Java 8 use “functional interface”
which is an interface with has only one abstract method (like Runnable)
Functional Interface
Interface (Default & Static method)
Default methods make interfaces similar to scala trait,
Interface must implement the default method each implement will inherit it
java.util.function contains 43 methods like:
BiFunction<T,U,R>
Represents a function that accepts two arguments and produces a result.
http://www.tutorialspoint.com/java8/java8_functional_interfaces.htm
Predicate<T> // represent a function that return true/false
public void calculate(List<Integer> list, Predicate<Integer> predicate) {
for(Integer n: list) {
if(predicate.test(n)) { //test evaluate predicate on argument
System.out.println(n + " ");
}
}
}
calculate(list, n-> n%2 == 0 );
Function API
http://howtodoinjava.com/java-8/how-to-use-predicate-in-java-8/
Call methods by their names
allows us to reference constructors or methods without executing them
You can’t pass arguments to methods Reference
List names = ArrayList::new;
names.add(“a”);
names.add(“b”);
names.forEach(System.out::println);
Car carInstance = Car.create( Car::new );
Car::collide;
carInstance::drive;
Method reference (::)
Method reference vs Lamdba
Curring
function that returns a function instead of a result.
Java 8 brings new abilities to work with Collections,Arrays, or I/O resources as
input source
Stream API offers easy filtering, aggregation, and mapping actions
Operations can return stream (pipelined) or result (like collect())
parallelStream : leverage multicore architecture without the need to write any
specific code for it (using ForkJoinThreadPool)
http://zeroturnaround.com/rebellabs/java-parallel-streams-are-bad-for-your-health/
https://dzone.com/articles/whats-wrong-java-8-part-iii
Stream
Stream() / filter() / map() return new stream object
Stream() convert collection to stream
Stream
collect() allows us to collect the results of a stream
Collectors are used to combine the stream result:
List<String>strings = Arrays.asList("a", "", "b", "");
List<String> filtered = strings.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList());
String mergedString = strings.stream().filter(string -> string.isEmpty()).collect(Collectors.joining(", "));
List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5);
IntSummaryStatistics stats = numbers.stream().mapToInt((x) -> x).summaryStatistics();
stats.getMax();
stats.getSum();
stats.getAverage();
Stream – Collectors & Aggregation
Stream – yet another example
Parallel Stream
CompletableFuture
Java 7 has no interface to get the async task result in the future , there is a way to get
the result outside of the future and when its done perform another action
Java 8 added Completefuture<T> interface
CompletableFuture
Optional is a container: it can hold a value of some type T or just be null.
It replace null checking and can avoid NullPointerException.
Integer value1 = null;
Integer value2 = new Integer(10);
Optional<Integer> a = Optional.ofNullable(value1); //represent null
Optional<Integer> b = Optional.of(value2);
Public Integer sum(Optional<Integer> a, Optional<Integer> b){
a.isPresent(); // false
Integer value1 = a.orElse(new Integer(5)); // 5
a.orElseGet( () -> 77 ) // instead of parameter it accept a method
Integer value2 = b.get(); // 10
return value1 + value2; // 15
}
What makes Optional truly appealing are methods such as ifPresent() and
orElseThrow() along with map() and filter() which all accept lambda
expressions ~ scala monad
Optional Class
java.util.Date & Calendar are not thread safe, developer need to manage timezone issues
popular solution JodaTime is 3#party not part of the Java api.
Java 8 has 2 implementation : Local / Zoned (which support timezone)
LocalDateTime currentTime = LocalDateTime.now(); //2014-12-10
LocalDate.now(Clock.systemUTC()) // Clock object provide access to datetime using timezone
// Clock can be used instead of System.currentTimeMillis() and TimeZone.getDefault().
LocalDate nextWeek = currentTime.plus(1, ChronoUnit.WEEKS); //2014-12-17
Period period = Period.between(currentTime, nextWeek);
Duration.between( currentTime, nextWeek ).toDays();
LocalDate nextTuesday = date1.with(TemporalAdjusters.next(DayOfWeek.TUESDAY)); //2014-12-16
LocalDate date = LocalDate.of(2014, Month.DECEMBER, 12);
ZonedDateTime date1 =
ZonedDateTime.parse("2007-12-03T10:15:30+05:30[Asia/Karachi]");
DateTime (immutable)
DateTime
Concurrency
how-longadder-performs-better-than-atomiclong
Atomic are used to increment a variable across threads, faster than locks.
Java 8 added adders and accumulators which to improve Atomic
Concurrency
JVM options -XX:PermSize and –XX:MaxPermSize have been replaced by
-XX:MetaSpaceSize and -XX:MaxMetaspaceSize respectively
JVM
GC1
Built in base64 encoder/decoder
Invoke JAVA from JS and JS from JAVA using Nashorn (replace Rhino)
Annotate local variables, generic types ...
Repeating annotation
Extra
“As a Scala and Java developer, I am not even slightly tempted to replace Scala as my main language for my next project with Java 8.
If I'm forced to write Java, it might better be Java 8,
but if I have a choice, there are so many things (as the OP correctly states) that make Scala compelling for me beyond Lambdas
that just adding that feature to Java doesn't really mean anything to me.
Ruby has Lambdas, so does Python and JavaScript, Dart and I'm sure any other modern language.
I like Scala because of so many other things other than lambdas that a single comment is not enough.
But to name a few (some were referenced by the OP)
Everything is an expression,
For comprehensions (especially with multiple futures, resolving the callback triangle of death in a beautiful syntax IMHO),
Implicit conversions,
Case classes,
Pattern Matching,
Tuples,
The fact that everything has equals and hashcode already correctly implemented (so I can put a tuple, or even an Array as a key in a map),
string interpolation,
multiline string,
default parameters,
named parameters,
built in dependency injection,
most complex yet most powerful type system in any language I know of, type inference (not as good as Haskell, but better than the non existent in Java).
The fact I always get the right type returned from a set of "monadic" actions thanks to infamous things like CanBuildFrom (which are pure genius).
Let's not forget pass by name arguments and the ability to construct a DSL. Extractors (via pattern matching). And many more.
I think Scala is here to stay, at least for Scala developers,
I am 100% sure you will not find a single Scala developer that will say: "Java 8 got lambdas? great, goodbye scala forever!".
Only reason I can think of is compile time and binary compatibility.
If we ignore those two, all I can say is that this just proves how Scala is in the right direction
(since Java 8 lambdas and default interface methods and steams are so clearly influenced)
I do wish however that Scala will improve Java 8 interoperability, e.g. support functional interfaces the same way.
and add new implicit conversions to Java 8 collections as well as take advantage to improvements in the JVM.
I will replace Scala as soon as I find a language that gives me what Scala does and does it better.
So far I didn't find such a language (examined Haskell, Clojure, Go, Kotlin, Ceylon, Dart, TypeScript, Rust, Julia, D and Nimrod, Ruby Python, JavaScript and C#,
some of them were very promising but since I need a JVM language, and preferably a statically typed one, it narrowed down the choices pretty quickly)
Java 8 is by far not even close, sorry. Great improvement, I'm very happy for Java developers that will get "permission" to use it (might be easier to adopt than Scala in an enterprise)
but this is not a reason for a Scala shop to consider moving back to Java.”
So should I leave Scala ?
https://news.ycombinator.com/item?id=7478367
Java has taken "Scala - the good parts"“martin odersky improve Java again (Generics)”

https://www.toptal.com/java/why-you-need-to-upgrade-to-java-8-already

http://www.javaworld.com/article/2078836/java-se/love-and-hate-for-java-8.html

http://allegro.tech/2014/12/How-to-migrate-to-Java-8.html

https://www.javacodegeeks.com/2014/05/java-8-features-tutorial.html

http://zeroturnaround.com/rebellabs/java-parallel-streams-are-bad-for-your-health/

https://dzone.com/articles/whats-wrong-java-8-currying-vs

https://dzone.com/articles/whats-wrong-java-8-part-ii

https://dzone.com/articles/whats-wrong-java-8-part-iii

https://dzone.com/articles/whats-wrong-java-8-part-iv

https://dzone.com/articles/whats-wrong-java-8-part-v

https://dzone.com/articles/whats-wrong-java-8-part-vi

https://dzone.com/articles/whats-wrong-java-8-part-vii

http://www.tutorialspoint.com/java8/

http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html

http://winterbe.com/posts/2015/05/22/java8-concurrency-tutorial-atomic-concurrent-map-examples/

http://www.concretepage.com/java/jdk-8/function-apply-in-java-8
Links
Ad

More Related Content

What's hot (20)

Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Dan Halperin
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 
HBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceHBase RowKey design for Akka Persistence
HBase RowKey design for Akka Persistence
Konrad Malawski
 
Spark Summit EU talk by Nimbus Goehausen
Spark Summit EU talk by Nimbus GoehausenSpark Summit EU talk by Nimbus Goehausen
Spark Summit EU talk by Nimbus Goehausen
Spark Summit
 
Real-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormReal-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and Storm
John Georgiadis
 
Harnessing the power of YARN with Apache Twill
Harnessing the power of YARN with Apache TwillHarnessing the power of YARN with Apache Twill
Harnessing the power of YARN with Apache Twill
Terence Yim
 
Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
Kros Huang
 
Developing Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache StormDeveloping Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache Storm
Lester Martin
 
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Reactivesummit
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
Alex Payne
 
Distributed Real-Time Stream Processing: Why and How 2.0
Distributed Real-Time Stream Processing:  Why and How 2.0Distributed Real-Time Stream Processing:  Why and How 2.0
Distributed Real-Time Stream Processing: Why and How 2.0
Petr Zapletal
 
Unit testing of spark applications
Unit testing of spark applicationsUnit testing of spark applications
Unit testing of spark applications
Knoldus Inc.
 
A dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenarioA dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenario
Gioia Ballin
 
Distributed real time stream processing- why and how
Distributed real time stream processing- why and howDistributed real time stream processing- why and how
Distributed real time stream processing- why and how
Petr Zapletal
 
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Databricks
 
RxJava 2.0 介紹
RxJava 2.0 介紹RxJava 2.0 介紹
RxJava 2.0 介紹
Kros Huang
 
Meetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbcMeetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbc
zznate
 
Realtime Statistics based on Apache Storm and RocketMQ
Realtime Statistics based on Apache Storm and RocketMQRealtime Statistics based on Apache Storm and RocketMQ
Realtime Statistics based on Apache Storm and RocketMQ
Xin Wang
 
Spark summit2014 techtalk - testing spark
Spark summit2014 techtalk - testing sparkSpark summit2014 techtalk - testing spark
Spark summit2014 techtalk - testing spark
Anu Shetty
 
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Alexey Kharlamov
 
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Introduction to Apache Beam & No Shard Left Behind: APIs for Massive Parallel...
Dan Halperin
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
Rick Warren
 
HBase RowKey design for Akka Persistence
HBase RowKey design for Akka PersistenceHBase RowKey design for Akka Persistence
HBase RowKey design for Akka Persistence
Konrad Malawski
 
Spark Summit EU talk by Nimbus Goehausen
Spark Summit EU talk by Nimbus GoehausenSpark Summit EU talk by Nimbus Goehausen
Spark Summit EU talk by Nimbus Goehausen
Spark Summit
 
Real-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and StormReal-Time Analytics with Kafka, Cassandra and Storm
Real-Time Analytics with Kafka, Cassandra and Storm
John Georgiadis
 
Harnessing the power of YARN with Apache Twill
Harnessing the power of YARN with Apache TwillHarnessing the power of YARN with Apache Twill
Harnessing the power of YARN with Apache Twill
Terence Yim
 
Rxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJavaRxjava 介紹與 Android 中的 RxJava
Rxjava 介紹與 Android 中的 RxJava
Kros Huang
 
Developing Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache StormDeveloping Java Streaming Applications with Apache Storm
Developing Java Streaming Applications with Apache Storm
Lester Martin
 
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Reactivesummit
 
The Why and How of Scala at Twitter
The Why and How of Scala at TwitterThe Why and How of Scala at Twitter
The Why and How of Scala at Twitter
Alex Payne
 
Distributed Real-Time Stream Processing: Why and How 2.0
Distributed Real-Time Stream Processing:  Why and How 2.0Distributed Real-Time Stream Processing:  Why and How 2.0
Distributed Real-Time Stream Processing: Why and How 2.0
Petr Zapletal
 
Unit testing of spark applications
Unit testing of spark applicationsUnit testing of spark applications
Unit testing of spark applications
Knoldus Inc.
 
A dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenarioA dive into akka streams: from the basics to a real-world scenario
A dive into akka streams: from the basics to a real-world scenario
Gioia Ballin
 
Distributed real time stream processing- why and how
Distributed real time stream processing- why and howDistributed real time stream processing- why and how
Distributed real time stream processing- why and how
Petr Zapletal
 
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Deep Dive into Stateful Stream Processing in Structured Streaming with Tathag...
Databricks
 
RxJava 2.0 介紹
RxJava 2.0 介紹RxJava 2.0 介紹
RxJava 2.0 介紹
Kros Huang
 
Meetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbcMeetup cassandra sfo_jdbc
Meetup cassandra sfo_jdbc
zznate
 
Realtime Statistics based on Apache Storm and RocketMQ
Realtime Statistics based on Apache Storm and RocketMQRealtime Statistics based on Apache Storm and RocketMQ
Realtime Statistics based on Apache Storm and RocketMQ
Xin Wang
 
Spark summit2014 techtalk - testing spark
Spark summit2014 techtalk - testing sparkSpark summit2014 techtalk - testing spark
Spark summit2014 techtalk - testing spark
Anu Shetty
 
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Alexey Kharlamov
 

Viewers also liked (15)

Spark streaming with kafka
Spark streaming with kafkaSpark streaming with kafka
Spark streaming with kafka
Dori Waldman
 
Dori waldman android _course_2
Dori waldman android _course_2Dori waldman android _course_2
Dori waldman android _course_2
Dori Waldman
 
Dori waldman android _course
Dori waldman android _courseDori waldman android _course
Dori waldman android _course
Dori Waldman
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
jclingan
 
TDC 2015 - Java: from old school to modern art!
TDC 2015 - Java: from old school to modern art!TDC 2015 - Java: from old school to modern art!
TDC 2015 - Java: from old school to modern art!
Marcos Ferreira
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
Leninkumar Koppoju
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
Andrzej Grzesik
 
from old java to java8 - KanJava Edition
from old java to java8 - KanJava Editionfrom old java to java8 - KanJava Edition
from old java to java8 - KanJava Edition
心 谷本
 
50 new things you can do with java 8
50 new things you can do with java 850 new things you can do with java 8
50 new things you can do with java 8
José Paumard
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
Vikas Gupta
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8
AppDynamics
 
Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelization
José Paumard
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
Stephen Colebourne
 
java 8
java 8java 8
java 8
Unguryan Vitaliy
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Spark streaming with kafka
Spark streaming with kafkaSpark streaming with kafka
Spark streaming with kafka
Dori Waldman
 
Dori waldman android _course_2
Dori waldman android _course_2Dori waldman android _course_2
Dori waldman android _course_2
Dori Waldman
 
Dori waldman android _course
Dori waldman android _courseDori waldman android _course
Dori waldman android _course
Dori Waldman
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
jclingan
 
TDC 2015 - Java: from old school to modern art!
TDC 2015 - Java: from old school to modern art!TDC 2015 - Java: from old school to modern art!
TDC 2015 - Java: from old school to modern art!
Marcos Ferreira
 
from old java to java8 - KanJava Edition
from old java to java8 - KanJava Editionfrom old java to java8 - KanJava Edition
from old java to java8 - KanJava Edition
心 谷本
 
50 new things you can do with java 8
50 new things you can do with java 850 new things you can do with java 8
50 new things you can do with java 8
José Paumard
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
Vikas Gupta
 
Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8Memory Management: What You Need to Know When Moving to Java 8
Memory Management: What You Need to Know When Moving to Java 8
AppDynamics
 
Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelization
José Paumard
 
Ad

Similar to whats new in java 8 (20)

Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
Mohammad Faizan
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
Dinesh Pathak
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Emiel Paasschens
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
Martin Toshev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
icarter09
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
Ganesh Samarthyam
 
Gude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerGude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic Server
Apache Traffic Server
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
Ahmed mar3y
 
Xebicon2013 scala vsjava_final
Xebicon2013 scala vsjava_finalXebicon2013 scala vsjava_final
Xebicon2013 scala vsjava_final
Urs Peter
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
Raffi Khatchadourian
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
NexThoughts Technologies
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Wien15 java8
Wien15 java8Wien15 java8
Wien15 java8
Jaanus Pöial
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
Nicola Pedot
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
Dinesh Pathak
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Emiel Paasschens
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
Martin Toshev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
icarter09
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
Ganesh Samarthyam
 
Gude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerGude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic Server
Apache Traffic Server
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 
New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
Ahmed mar3y
 
Xebicon2013 scala vsjava_final
Xebicon2013 scala vsjava_finalXebicon2013 scala vsjava_final
Xebicon2013 scala vsjava_final
Urs Peter
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
Raffi Khatchadourian
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Ad

More from Dori Waldman (8)

openai.pptx
openai.pptxopenai.pptx
openai.pptx
Dori Waldman
 
iceberg introduction.pptx
iceberg introduction.pptxiceberg introduction.pptx
iceberg introduction.pptx
Dori Waldman
 
spark stream - kafka - the right way
spark stream - kafka - the right way spark stream - kafka - the right way
spark stream - kafka - the right way
Dori Waldman
 
Druid meetup @walkme
Druid meetup @walkmeDruid meetup @walkme
Druid meetup @walkme
Dori Waldman
 
Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies
Dori Waldman
 
Druid
DruidDruid
Druid
Dori Waldman
 
Memcached
MemcachedMemcached
Memcached
Dori Waldman
 
Big data should be simple
Big data should be simpleBig data should be simple
Big data should be simple
Dori Waldman
 
iceberg introduction.pptx
iceberg introduction.pptxiceberg introduction.pptx
iceberg introduction.pptx
Dori Waldman
 
spark stream - kafka - the right way
spark stream - kafka - the right way spark stream - kafka - the right way
spark stream - kafka - the right way
Dori Waldman
 
Druid meetup @walkme
Druid meetup @walkmeDruid meetup @walkme
Druid meetup @walkme
Dori Waldman
 
Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies Machine Learning and Deep Learning 4 dummies
Machine Learning and Deep Learning 4 dummies
Dori Waldman
 
Big data should be simple
Big data should be simpleBig data should be simple
Big data should be simple
Dori Waldman
 

Recently uploaded (20)

Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 

whats new in java 8

  • 2.  Lambda Expressions  CompletableFuture  Method References  Functional Interfaces  Default Methods  Streams  Optional Class  New Date/Time API ... Agenda
  • 3. Functional programming: “Lambda allow us to treat functionality as a method argument (passing functions around)” Syntax: 1) Infers syntax : return / type / {} / () Integer sub = (a, b) → a – b; // no need to write (int a, int b) -> { return a * b; } Arrays.asList( "a", "b").forEach( e → System.out.println( e ) ); // no need to write ((String)e) → ... Lambda (→)
  • 5. Lambda (→) 3) Eliminates the need of anonymous class 4) Make code more immutable
  • 6. Lambda (→) , the bad parts https://dzone.com/articles/whats-wrong-java-8-part-ii - be aware of auto-boxing System.out.println((x -> x / 100 * (100 + 10)).apply(100)); // java does not know type of X System.out.println((Integer x) -> x / 100 * 100 + 10).apply(100)); // → is a function , java does not know Function type System.out.println(((Function<Integer, Integer>) x -> x / 100 * 100 + 10).apply(100)); * Auto-boxing means automatic convert between primitive and object
  • 7. To allow functions to take lambdas as arguments, Java 8 use “functional interface” which is an interface with has only one abstract method (like Runnable) Functional Interface
  • 8. Interface (Default & Static method) Default methods make interfaces similar to scala trait, Interface must implement the default method each implement will inherit it
  • 9. java.util.function contains 43 methods like: BiFunction<T,U,R> Represents a function that accepts two arguments and produces a result. http://www.tutorialspoint.com/java8/java8_functional_interfaces.htm Predicate<T> // represent a function that return true/false public void calculate(List<Integer> list, Predicate<Integer> predicate) { for(Integer n: list) { if(predicate.test(n)) { //test evaluate predicate on argument System.out.println(n + " "); } } } calculate(list, n-> n%2 == 0 ); Function API http://howtodoinjava.com/java-8/how-to-use-predicate-in-java-8/
  • 10. Call methods by their names allows us to reference constructors or methods without executing them You can’t pass arguments to methods Reference List names = ArrayList::new; names.add(“a”); names.add(“b”); names.forEach(System.out::println); Car carInstance = Car.create( Car::new ); Car::collide; carInstance::drive; Method reference (::)
  • 12. Curring function that returns a function instead of a result.
  • 13. Java 8 brings new abilities to work with Collections,Arrays, or I/O resources as input source Stream API offers easy filtering, aggregation, and mapping actions Operations can return stream (pipelined) or result (like collect()) parallelStream : leverage multicore architecture without the need to write any specific code for it (using ForkJoinThreadPool) http://zeroturnaround.com/rebellabs/java-parallel-streams-are-bad-for-your-health/ https://dzone.com/articles/whats-wrong-java-8-part-iii Stream Stream() / filter() / map() return new stream object Stream() convert collection to stream
  • 14. Stream collect() allows us to collect the results of a stream Collectors are used to combine the stream result: List<String>strings = Arrays.asList("a", "", "b", ""); List<String> filtered = strings.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList()); String mergedString = strings.stream().filter(string -> string.isEmpty()).collect(Collectors.joining(", "));
  • 15. List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5); IntSummaryStatistics stats = numbers.stream().mapToInt((x) -> x).summaryStatistics(); stats.getMax(); stats.getSum(); stats.getAverage(); Stream – Collectors & Aggregation
  • 16. Stream – yet another example
  • 18. CompletableFuture Java 7 has no interface to get the async task result in the future , there is a way to get the result outside of the future and when its done perform another action Java 8 added Completefuture<T> interface
  • 20. Optional is a container: it can hold a value of some type T or just be null. It replace null checking and can avoid NullPointerException. Integer value1 = null; Integer value2 = new Integer(10); Optional<Integer> a = Optional.ofNullable(value1); //represent null Optional<Integer> b = Optional.of(value2); Public Integer sum(Optional<Integer> a, Optional<Integer> b){ a.isPresent(); // false Integer value1 = a.orElse(new Integer(5)); // 5 a.orElseGet( () -> 77 ) // instead of parameter it accept a method Integer value2 = b.get(); // 10 return value1 + value2; // 15 } What makes Optional truly appealing are methods such as ifPresent() and orElseThrow() along with map() and filter() which all accept lambda expressions ~ scala monad Optional Class
  • 21. java.util.Date & Calendar are not thread safe, developer need to manage timezone issues popular solution JodaTime is 3#party not part of the Java api. Java 8 has 2 implementation : Local / Zoned (which support timezone) LocalDateTime currentTime = LocalDateTime.now(); //2014-12-10 LocalDate.now(Clock.systemUTC()) // Clock object provide access to datetime using timezone // Clock can be used instead of System.currentTimeMillis() and TimeZone.getDefault(). LocalDate nextWeek = currentTime.plus(1, ChronoUnit.WEEKS); //2014-12-17 Period period = Period.between(currentTime, nextWeek); Duration.between( currentTime, nextWeek ).toDays(); LocalDate nextTuesday = date1.with(TemporalAdjusters.next(DayOfWeek.TUESDAY)); //2014-12-16 LocalDate date = LocalDate.of(2014, Month.DECEMBER, 12); ZonedDateTime date1 = ZonedDateTime.parse("2007-12-03T10:15:30+05:30[Asia/Karachi]"); DateTime (immutable)
  • 23. Concurrency how-longadder-performs-better-than-atomiclong Atomic are used to increment a variable across threads, faster than locks. Java 8 added adders and accumulators which to improve Atomic
  • 25. JVM options -XX:PermSize and –XX:MaxPermSize have been replaced by -XX:MetaSpaceSize and -XX:MaxMetaspaceSize respectively JVM GC1
  • 26. Built in base64 encoder/decoder Invoke JAVA from JS and JS from JAVA using Nashorn (replace Rhino) Annotate local variables, generic types ... Repeating annotation Extra
  • 27. “As a Scala and Java developer, I am not even slightly tempted to replace Scala as my main language for my next project with Java 8. If I'm forced to write Java, it might better be Java 8, but if I have a choice, there are so many things (as the OP correctly states) that make Scala compelling for me beyond Lambdas that just adding that feature to Java doesn't really mean anything to me. Ruby has Lambdas, so does Python and JavaScript, Dart and I'm sure any other modern language. I like Scala because of so many other things other than lambdas that a single comment is not enough. But to name a few (some were referenced by the OP) Everything is an expression, For comprehensions (especially with multiple futures, resolving the callback triangle of death in a beautiful syntax IMHO), Implicit conversions, Case classes, Pattern Matching, Tuples, The fact that everything has equals and hashcode already correctly implemented (so I can put a tuple, or even an Array as a key in a map), string interpolation, multiline string, default parameters, named parameters, built in dependency injection, most complex yet most powerful type system in any language I know of, type inference (not as good as Haskell, but better than the non existent in Java). The fact I always get the right type returned from a set of "monadic" actions thanks to infamous things like CanBuildFrom (which are pure genius). Let's not forget pass by name arguments and the ability to construct a DSL. Extractors (via pattern matching). And many more. I think Scala is here to stay, at least for Scala developers, I am 100% sure you will not find a single Scala developer that will say: "Java 8 got lambdas? great, goodbye scala forever!". Only reason I can think of is compile time and binary compatibility. If we ignore those two, all I can say is that this just proves how Scala is in the right direction (since Java 8 lambdas and default interface methods and steams are so clearly influenced) I do wish however that Scala will improve Java 8 interoperability, e.g. support functional interfaces the same way. and add new implicit conversions to Java 8 collections as well as take advantage to improvements in the JVM. I will replace Scala as soon as I find a language that gives me what Scala does and does it better. So far I didn't find such a language (examined Haskell, Clojure, Go, Kotlin, Ceylon, Dart, TypeScript, Rust, Julia, D and Nimrod, Ruby Python, JavaScript and C#, some of them were very promising but since I need a JVM language, and preferably a statically typed one, it narrowed down the choices pretty quickly) Java 8 is by far not even close, sorry. Great improvement, I'm very happy for Java developers that will get "permission" to use it (might be easier to adopt than Scala in an enterprise) but this is not a reason for a Scala shop to consider moving back to Java.” So should I leave Scala ? https://news.ycombinator.com/item?id=7478367 Java has taken "Scala - the good parts"“martin odersky improve Java again (Generics)”
  • 28.  https://www.toptal.com/java/why-you-need-to-upgrade-to-java-8-already  http://www.javaworld.com/article/2078836/java-se/love-and-hate-for-java-8.html  http://allegro.tech/2014/12/How-to-migrate-to-Java-8.html  https://www.javacodegeeks.com/2014/05/java-8-features-tutorial.html  http://zeroturnaround.com/rebellabs/java-parallel-streams-are-bad-for-your-health/  https://dzone.com/articles/whats-wrong-java-8-currying-vs  https://dzone.com/articles/whats-wrong-java-8-part-ii  https://dzone.com/articles/whats-wrong-java-8-part-iii  https://dzone.com/articles/whats-wrong-java-8-part-iv  https://dzone.com/articles/whats-wrong-java-8-part-v  https://dzone.com/articles/whats-wrong-java-8-part-vi  https://dzone.com/articles/whats-wrong-java-8-part-vii  http://www.tutorialspoint.com/java8/  http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html  http://winterbe.com/posts/2015/05/22/java8-concurrency-tutorial-atomic-concurrent-map-examples/  http://www.concretepage.com/java/jdk-8/function-apply-in-java-8 Links