SlideShare a Scribd company logo
Main sponsor
Project Lambda: Functional
Programming Constructs In
Java
Simon Ritter
Head of Java Evangelism
Oracle Corporation

Twitter: @speakjava
2

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The following is intended to outline our general product
direction. It is intended for information purposes only, and may
not be incorporated into any contract. It is not a commitment to
deliver any material, code, or functionality, and should not be
relied upon in making purchasing decisions.
The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole
discretion of Oracle.

3

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Some Background

4

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Computing Today
 Multicore is now the default
– Moore’s law means more cores, not faster clockspeed

 We need to make writing parallel code easier

 All components of the Java SE platform are adapting
– Language, libraries, VM

Herb Sutter
5

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

http://www.gotw.ca/publications/concurrency-ddj.htm
http://drdobbs.com/high-performance-computing/225402247
http://drdobbs.com/high-performance-computing/219200099

360 Cores
2.8 TB RAM
960 GB Flash
InfiniBand
…
Concurrency in Java
java.util.concurrent
(jsr166)
Phasers, etc
java.lang.Thread
(jsr166)

1.4

5.0

6

Project Lambda
Fork/Join Framework
(jsr166y)

7 8

2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
6

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

2013...
Goals For Better Parallelism In Java
 Easy-to-use parallel libraries
– Libraries can hide a host of complex concerns
 task scheduling, thread management, load balancing, etc

 Reduce conceptual and syntactic gap between serial and parallel

expressions of the same computation
– Currently serial code and parallel code for a given computation are very different
 Fork-join is a good start, but not enough

 Sometimes we need language changes to support better libraries
– Lambda expressions

7

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Bringing Lambdas To Java

8

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The Problem: External Iteration
List<Student> students = ...

double highestScore = 0.0;
for (Student s : students) {
if (s.gradYear == 2011) {

if (s.score > highestScore) {
highestScore = s.score;
}

}
}

9

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

•
•
•

Client controls iteration
Inherently serial: iterate from
beginning to end
Not thread-safe because
business logic is stateful
(mutable accumulator
variable)
Internal Iteration With Inner Classes
More Functional, Fluent and Monad Like
 Iteraction, filtering and
SomeList<Student> students = ...
double highestScore =
students.filter(new Predicate<Student>() {
public boolean op(Student s) {
return s.getGradYear() == 2011;
}
}).map(new Mapper<Student,Double>() {
public Double extract(Student s) {
return s.getScore();
}
}).max();
10

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

accumulation are handled by the
library
 Not inherently serial – traversal

may be done in parallel
 Traversal may be done lazily – so

one pass, rather than three
 Thread safe – client logic is

stateless
 High barrier to use
– Syntactically ugly
Internal Iteration With Lambdas
SomeList<Student> students = ...

double highestScore =
students.filter(Student s -> s.getGradYear() == 2011)
.map(Student s -> s.getScore())

.max();

• More readable

• More abstract
• Less error-prone
• No reliance on mutable state

• Easier to make parallel

11

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Lambda Expressions
Some Details
 Lambda expressions are anonymous functions
– Like a method, has a typed argument list, a return type, a set of thrown

exceptions, and a body
double highestScore =
students.filter(Student s -> s.getGradYear() == 2011)
.map(Student s -> s.getScore())
.max();

12

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Lambda Expression Types
•

Single-method interfaces used extensively to represent functions and
callbacks
– Definition: a functional interface is an interface with one method (SAM)
– Functional interfaces are identified structurally

– The type of a lambda expression will be a functional interface
 This is very important
interface
interface
interface
interface
interface
13

Comparator<T>
FileFilter
Runnable
ActionListener
Callable<T>

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

{
{
{
{
{

boolean compare(T x, T y); }
boolean accept(File x); }
void run(); }
void actionPerformed(…); }
T call(); }
Target Typing
 A lambda expression is a way to create an instance of a functional interface
– Which functional interface is inferred from the context

– Works both in assignment and method invocation contexts
 Can use casts if needed to resolve ambiguity
Comparator<String> c = new Comparator<String>() {
public int compare(String x, String y) {
return x.length() - y.length();
}
};

Comparator<String> c = (String x, String y) -> x.length() - y.length();
14

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Local Variable Capture
•

Lambda expressions can refer to effectively final local variables from
the enclosing scope
•

Effectively final means that the variable meets the requirements for final
variables (e.g., assigned once), even if not explicitly declared final

•

This is a form of type inference

void expire(File root, long before) {
...
root.listFiles(File p -> p.lastModified() <= before);
...
}
15

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Lexical Scoping
•

The meaning of names are the same inside the lambda as outside
•

A ‘this’ reference – refers to the enclosing object, not the lambda itself

•

Think of ‘this’ as a final predefined local

•

Remember the type of a Lambda is a functional interface

class SessionManager {
long before = ...;
void expire(File root) {
...
// refers to „this.before‟, just like outside the lambda
root.listFiles(File p -> checkExpiry(p.lastModified(), before));
}
boolean checkExpiry(long time, long expiry) { ... }
}

16

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Type Inferrence
 Compiler can often infer parameter types in lambda expression
Collections.sort(ls, (String x, String y) -> x.length() - y.length());

Collections.sort(ls, (x, y) -> x.length() - y.length());

 Inferrence based on the target functional interface’s method signature
 Fully statically typed (no dynamic typing sneaking in)
– More typing with less typing

17

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Method References
•

Method references let us reuse a method as a lambda expression
FileFilter x = new FileFilter() {
public boolean accept(File f) {
return f.canRead();
}
};

FileFilter x = (File f) -> f.canRead();

FileFilter x = File::canRead;
18

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Constructor References
interface Factory<T> {
T make();
}

Factory<List<String>> f = ArrayList<String>::new;
Equivalent to
Factory<List<String>> f = () -> return new ArrayList<String>();

 When f.make() is invoked it will return a new ArrayList<String>
19

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Lambda Expressions In Java
Advantages
 Developers primary tool for computing over aggregates is the for loop
– Inherently serial
– We need internal iteration

 Useful for many libraries, serial and parallel

 Adding Lambda expressions to Java is no longer a radical idea

20

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Library Evolution

21

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Library Evolution
The Real Challenge
• Adding lambda expressions is a big language change
• If Java had them from day one, the APIs would definitely look different
• Adding lambda expressions makes our aging APIs show their age even

more
 Most important APIs (Collections) are based on interfaces
• How to extend an interface without breaking backwards compatability

• Adding lambda expressions to Java, but not upgrading the APIs to use

them, would be silly
• Therefore we also need better mechanisms for library evolution

22

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Library Evolution Goal
 Requirement: aggregate operations on collections
– New methods on Collections that allow for bulk operations
– Examples: filter, map, reduce, forEach, sort
– These can run in parallel (return Stream object)
int heaviestBlueBlock =
blocks.filter(b -> b.getColor() == BLUE)
.map(Block::getWeight)
.reduce(0, Integer::max);

 This is problematic
– Can’t add new methods to interfaces without modifying all implementations
– Can’t necessarily find or control all implementations
23

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Solution: Virtual Extension Methods
AKA Defender Methods
• Specified in the interface
• From the caller’s perspective, just an ordinary interface method
• List class provides a default implementation
• Default is only used when implementation classes do not provide a body

for the extension method
• Implementation classes can provide a better version, or not

 Drawback: requires VM support
interface List<T> {
void sort(Comparator<? super T> cmp)
default { Collections.sort(this, cmp); };
}
24

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Virtual Extension Methods
Stop right there!
• Err, isn’t this implementing multiple inheritance for Java?
• Yes, but Java already has multiple inheritance of types
• This adds multiple inheritance of behavior too
• But not state, which is where most of the trouble is
• Though can still be a source of complexity due to separate compilation and

dynamic linking

25

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Functional Interface Definitions
 Single Abstract Method (SAM) type

 A functional interface is an interface that has one abstract method
– Represents a single function contract
– Doesn’t mean it only has one method

 Abstract classes may be considered later
 @FunctionalInterface annotation
– Helps ensure the functional interface contract is honoured

– Compiler error if not a SAM

26

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
The Stream Class
java.util.stream
 Stream<T>
– A sequence of elements supporting sequential and parallel operations

 A Stream is opened by calling:
– Collection.stream()
– Collection.parallelStream()

List<String> names = Arrays.asList(“Bob”, “Alice”, “Charlie”);
System.out.println(names.
stream().
filter(e -> e.getLength() > 4).
findFirst().
get());
27

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
java.util.stream Package
 Accessed from Stream interface

 Collector<T, R>
– A (possibly) parallel reduction operation
– Folds input elements of type T into a mutable results container of type R
 e.g. String concatenation, min, max, etc

28

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
java.util.function Package
 Predicate<T>
– Determine if the input of type T matches some criteria

 Consumer<T>
– Accept a single input argumentof type T, and return no result

 Function<T, R>
– Apply a function to the input type T, generating a result of type R

 Plus several more

29

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Lambda Expressions in Use

30

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Simple Java Data Structure
public class Person {
public enum Gender { MALE, FEMALE };
String name;
Date birthday;
Gender gender;
String emailAddress;
public String getName() { ... }
public Gender getGender() { ... }
public String getEmailAddress() { ... }
public void printPerson() {
// ...
}
}
31

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

List<Person> membership;
Searching For Specific Characteristics (1)
Simplistic, Brittle Approach
public static void printPeopleOlderThan(List<Person> members, int age) {
for (Person p : members) {
if (p.getAge() > age)
p.printPerson();
}
}
public static void printPeopleYoungerThan(List<Person> members, int age) {
// ...
}
// And on, and on, and on...

32

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Searching For Specific Characteristics (2)
Separate Search Criteria
/* Single abstract method type */
interface PeoplePredicate {
public boolean satisfiesCriteria(Person p);
}
public static void printPeople(List<Person> members, PeoplePredicate match) {
for (Person p : members) {
if (match.satisfiesCriteria(p))
p.printPerson();
}
}

33

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Searching For Specific Characteristics (3)
Separate Search Criteria
public class RetiredMen implements PeoplePredicate {
// ...
public boolean satisfiesCriteria(Person p) {
if (p.gender == Person.Gender.MALE && p.getAge() >= 65)
return true;
return false;
}
}

printPeople(membership, new RetiredMen());

34

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Searching For Specific Characteristics (4)
Separate Search Criteria Using Anonymous Inner Class
printPeople(membership, new PeoplePredicate() {
public boolean satisfiesCriteria(Person p) {
if (p.gender == Person.Gender.MALE && p.getAge() >= 65)
return true;
return false;
}
});

35

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Searching For Specific Characteristics (5)
Separate Search Criteria Using Lambda Expression

printPeople(membership,
p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65);

 We now have parameterised behaviour, not just values
– This is really important
– This is why Lambda statements are such a big deal in Java

36

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Make Things More Generic (1)
interface PeoplePredicate {
public boolean satisfiesCriteria(Person p);
}

/* From java.util.function class library */
interface Predicate<T> {
public boolean test(T t);
}

37

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Make Things More Generic (2)
public static void printPeopleUsingPredicate(
List<Person> members, Predicate<Person> predicate) {
for (Person p : members) {
if (predicate.test())
p.printPerson();
}
Interface defines behaviour
}

Call to method executes behaviour

printPeopleUsingPredicate(membership,
p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65);

Behaviour passed as parameter
38

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Using A Consumer (1)
interface Consumer<T> {
public void accept(T t);
}

public void processPeople(List<Person> members,
Predicate<Person> predicate,
Consumer<Person> consumer) {
for (Person p : members) {
if (predicate.test(p))
consumer.accept(p);
}
}

39

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Using A Consumer (2)
processPeople(membership,
p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65,
p -> p.printPerson());

processPeople(membership,
p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65,
Person::printPerson);

40

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Using A Return Value (1)
interface Function<T, R> {
public R apply(T t);
}
public static void processPeopleWithFunction(
List<Person> members,
Predicate<Person> predicate,
Function<Person, String> function,
Consumer<String> consumer) {
for (Person p : members) {
if (predicate.test(p)) {
String data = function.apply(p);
consumer.accept(data);
}
}
}
41

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Using A Return Value (2)
processPeopleWithFunction(
membership,
p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65,
p -> p.getEmailAddress(),
email -> System.out.println(email));
processPeopleWithFunction(
membership,
p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65,
Person::getEmailAddress,
System.out::println);

42

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
Conclusions
 Java needs lambda statements for multiple reasons
– Significant improvements in existing libraries are required
– Replacing all the libraries is a non-starter
– Compatibly evolving interface-based APIs has historically been a problem

 Require a mechanism for interface evolution
– Solution: virtual extension methods
– Which is both a language and a VM feature
– And which is pretty useful for other things too

 Java SE 8 evolves the language, libraries, and VM together

43

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
44

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

More Related Content

What's hot (20)

The Java Carputer
The Java CarputerThe Java Carputer
The Java Carputer
Simon Ritter
 
Plsql les04
Plsql les04Plsql les04
Plsql les04
sasa_eldoby
 
Cso gaddis java_chapter2
Cso gaddis java_chapter2Cso gaddis java_chapter2
Cso gaddis java_chapter2
mlrbrown
 
Android coding guide lines
Android coding guide linesAndroid coding guide lines
Android coding guide lines
lokeshG38
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Eelco Visser
 
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Simplilearn
 
Cso gaddis java_chapter4
Cso gaddis java_chapter4Cso gaddis java_chapter4
Cso gaddis java_chapter4
mlrbrown
 
Using Stratego/XT for generation of software connectors.
Using Stratego/XT for generation of software connectors.Using Stratego/XT for generation of software connectors.
Using Stratego/XT for generation of software connectors.
Michal Malohlava
 
Objc
ObjcObjc
Objc
Pragati Singh
 
LOM DCAM at LOM Meeting 2008-04-23
LOM DCAM at LOM Meeting 2008-04-23LOM DCAM at LOM Meeting 2008-04-23
LOM DCAM at LOM Meeting 2008-04-23
Mikael Nilsson
 
Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of Variable
MOHIT DADU
 
Java RMI
Java RMIJava RMI
Java RMI
Ankit Desai
 
DC-2008 DCMI/IEEE workshop
DC-2008 DCMI/IEEE workshopDC-2008 DCMI/IEEE workshop
DC-2008 DCMI/IEEE workshop
Mikael Nilsson
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
cesarmendez78
 
Les01
Les01Les01
Les01
Akmal Rony
 
Unit 4 plsql
Unit 4  plsqlUnit 4  plsql
Unit 4 plsql
DrkhanchanaR
 
JAVA BASICS
JAVA BASICSJAVA BASICS
JAVA BASICS
VEERA RAGAVAN
 
ProgrammingPrimerAndOOPS
ProgrammingPrimerAndOOPSProgrammingPrimerAndOOPS
ProgrammingPrimerAndOOPS
sunmitraeducation
 
Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...
Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...
Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...
Simplilearn
 
Chapter2
Chapter2Chapter2
Chapter2
Namomsa Amanuu
 
Cso gaddis java_chapter2
Cso gaddis java_chapter2Cso gaddis java_chapter2
Cso gaddis java_chapter2
mlrbrown
 
Android coding guide lines
Android coding guide linesAndroid coding guide lines
Android coding guide lines
lokeshG38
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Eelco Visser
 
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Top TCS Interview Questions And Answers | How to Crack An Interview At TCS | ...
Simplilearn
 
Cso gaddis java_chapter4
Cso gaddis java_chapter4Cso gaddis java_chapter4
Cso gaddis java_chapter4
mlrbrown
 
Using Stratego/XT for generation of software connectors.
Using Stratego/XT for generation of software connectors.Using Stratego/XT for generation of software connectors.
Using Stratego/XT for generation of software connectors.
Michal Malohlava
 
LOM DCAM at LOM Meeting 2008-04-23
LOM DCAM at LOM Meeting 2008-04-23LOM DCAM at LOM Meeting 2008-04-23
LOM DCAM at LOM Meeting 2008-04-23
Mikael Nilsson
 
Operator Overloading and Scope of Variable
Operator Overloading and Scope of VariableOperator Overloading and Scope of Variable
Operator Overloading and Scope of Variable
MOHIT DADU
 
DC-2008 DCMI/IEEE workshop
DC-2008 DCMI/IEEE workshopDC-2008 DCMI/IEEE workshop
DC-2008 DCMI/IEEE workshop
Mikael Nilsson
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
cesarmendez78
 
Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...
Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...
Top 10 Highest Paying Jobs in 2019 | Highest Paying IT Jobs 2019 | High Salar...
Simplilearn
 

Similar to Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Oracle) (20)

Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3
Simon Ritter
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
javafxpert
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
Simon Ritter
 
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
JDK8 Lambdas and Streams: Changing The Way You Think When Developing JavaJDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
Simon Ritter
 
Functional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterFunctional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritter
Simon Ritter
 
Java SE 8
Java SE 8Java SE 8
Java SE 8
Simon Ritter
 
Lambdas : Beyond The Basics
Lambdas : Beyond The BasicsLambdas : Beyond The Basics
Lambdas : Beyond The Basics
Simon Ritter
 
JSR 335 / java 8 - update reference
JSR 335 / java 8 - update referenceJSR 335 / java 8 - update reference
JSR 335 / java 8 - update reference
sandeepji_choudhary
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
jaxconf
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
JAX London
 
Java 8
Java 8Java 8
Java 8
vilniusjug
 
Project Lambda: Evolution of Java
Project Lambda: Evolution of JavaProject Lambda: Evolution of Java
Project Lambda: Evolution of Java
Can Pekdemir
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
Mario Fusco
 
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
Chuk-Munn Lee
 
Major Java 8 features
Major Java 8 featuresMajor Java 8 features
Major Java 8 features
Sanjoy Kumar Roy
 
Project Lambda: To Multicore and Beyond
Project Lambda: To Multicore and BeyondProject Lambda: To Multicore and Beyond
Project Lambda: To Multicore and Beyond
Dmitry Buzdin
 
Java 8-revealed
Java 8-revealedJava 8-revealed
Java 8-revealed
Hamed Hatami
 
Java 8 new features
Java 8 new featuresJava 8 new features
Java 8 new features
Aniket Thakur
 
Java SE 8
Java SE 8Java SE 8
Java SE 8
Murali Pachiyappan
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
Indrajit Das
 
Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3Lambdas and-streams-s ritter-v3
Lambdas and-streams-s ritter-v3
Simon Ritter
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
javafxpert
 
Lambdas And Streams in JDK8
Lambdas And Streams in JDK8Lambdas And Streams in JDK8
Lambdas And Streams in JDK8
Simon Ritter
 
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
JDK8 Lambdas and Streams: Changing The Way You Think When Developing JavaJDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
JDK8 Lambdas and Streams: Changing The Way You Think When Developing Java
Simon Ritter
 
Functional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterFunctional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritter
Simon Ritter
 
Lambdas : Beyond The Basics
Lambdas : Beyond The BasicsLambdas : Beyond The Basics
Lambdas : Beyond The Basics
Simon Ritter
 
JSR 335 / java 8 - update reference
JSR 335 / java 8 - update referenceJSR 335 / java 8 - update reference
JSR 335 / java 8 - update reference
sandeepji_choudhary
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
jaxconf
 
Lambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian GoetzLambda: A Peek Under The Hood - Brian Goetz
Lambda: A Peek Under The Hood - Brian Goetz
JAX London
 
Project Lambda: Evolution of Java
Project Lambda: Evolution of JavaProject Lambda: Evolution of Java
Project Lambda: Evolution of Java
Can Pekdemir
 
FP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyondFP in Java - Project Lambda and beyond
FP in Java - Project Lambda and beyond
Mario Fusco
 
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
NUS Hackers Club Mar 21 - Whats New in JavaSE 8?
Chuk-Munn Lee
 
Project Lambda: To Multicore and Beyond
Project Lambda: To Multicore and BeyondProject Lambda: To Multicore and Beyond
Project Lambda: To Multicore and Beyond
Dmitry Buzdin
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
Indrajit Das
 
Ad

More from jaxLondonConference (20)

Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...
Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...
Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...
jaxLondonConference
 
Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...
Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...
Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...
jaxLondonConference
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)
jaxLondonConference
 
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
jaxLondonConference
 
What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)
jaxLondonConference
 
Why other ppl_dont_get_it
Why other ppl_dont_get_itWhy other ppl_dont_get_it
Why other ppl_dont_get_it
jaxLondonConference
 
Databases and agile development - Dwight Merriman (MongoDB)
Databases and agile development - Dwight Merriman (MongoDB)Databases and agile development - Dwight Merriman (MongoDB)
Databases and agile development - Dwight Merriman (MongoDB)
jaxLondonConference
 
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
jaxLondonConference
 
Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...
Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...
Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...
jaxLondonConference
 
How Java got its Mojo Back - James Governor (Redmonk)
How Java got its Mojo Back - James Governor (Redmonk)					How Java got its Mojo Back - James Governor (Redmonk)
How Java got its Mojo Back - James Governor (Redmonk)
jaxLondonConference
 
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
jaxLondonConference
 
Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)
jaxLondonConference
 
Streams and Things - Darach Ennis (Ubiquiti Networks)
Streams and Things - Darach Ennis (Ubiquiti Networks)Streams and Things - Darach Ennis (Ubiquiti Networks)
Streams and Things - Darach Ennis (Ubiquiti Networks)
jaxLondonConference
 
Big Events, Mob Scale - Darach Ennis (Push Technology)
Big Events, Mob Scale - Darach Ennis (Push Technology)Big Events, Mob Scale - Darach Ennis (Push Technology)
Big Events, Mob Scale - Darach Ennis (Push Technology)
jaxLondonConference
 
What makes Groovy Groovy - Guillaume Laforge (Pivotal)
What makes Groovy Groovy  - Guillaume Laforge (Pivotal)What makes Groovy Groovy  - Guillaume Laforge (Pivotal)
What makes Groovy Groovy - Guillaume Laforge (Pivotal)
jaxLondonConference
 
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
jaxLondonConference
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
jaxLondonConference
 
Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...
Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...
Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...
jaxLondonConference
 
The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)
jaxLondonConference
 
TDD at scale - Mash Badar (UBS)
TDD at scale - Mash Badar (UBS)TDD at scale - Mash Badar (UBS)
TDD at scale - Mash Badar (UBS)
jaxLondonConference
 
Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...
Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...
Garbage Collection: the Useful Parts - Martijn Verburg & Dr John Oliver (jCla...
jaxLondonConference
 
Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...
Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...
Conflict Free Replicated Data-types in Eventually Consistent Systems - Joel J...
jaxLondonConference
 
JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)JVM Support for Multitenant Applications - Steve Poole (IBM)
JVM Support for Multitenant Applications - Steve Poole (IBM)
jaxLondonConference
 
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
Packed Objects: Fast Talking Java Meets Native Code - Steve Poole (IBM)
jaxLondonConference
 
What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)
jaxLondonConference
 
Databases and agile development - Dwight Merriman (MongoDB)
Databases and agile development - Dwight Merriman (MongoDB)Databases and agile development - Dwight Merriman (MongoDB)
Databases and agile development - Dwight Merriman (MongoDB)
jaxLondonConference
 
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
jaxLondonConference
 
Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...
Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...
Are Hypermedia APIs Just Hype? - Aaron Phethean (Temenos) & Daniel Feist (Mul...
jaxLondonConference
 
How Java got its Mojo Back - James Governor (Redmonk)
How Java got its Mojo Back - James Governor (Redmonk)					How Java got its Mojo Back - James Governor (Redmonk)
How Java got its Mojo Back - James Governor (Redmonk)
jaxLondonConference
 
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
jaxLondonConference
 
Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)
jaxLondonConference
 
Streams and Things - Darach Ennis (Ubiquiti Networks)
Streams and Things - Darach Ennis (Ubiquiti Networks)Streams and Things - Darach Ennis (Ubiquiti Networks)
Streams and Things - Darach Ennis (Ubiquiti Networks)
jaxLondonConference
 
Big Events, Mob Scale - Darach Ennis (Push Technology)
Big Events, Mob Scale - Darach Ennis (Push Technology)Big Events, Mob Scale - Darach Ennis (Push Technology)
Big Events, Mob Scale - Darach Ennis (Push Technology)
jaxLondonConference
 
What makes Groovy Groovy - Guillaume Laforge (Pivotal)
What makes Groovy Groovy  - Guillaume Laforge (Pivotal)What makes Groovy Groovy  - Guillaume Laforge (Pivotal)
What makes Groovy Groovy - Guillaume Laforge (Pivotal)
jaxLondonConference
 
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
The Java Virtual Machine is Over - The Polyglot VM is here - Marcus Lagergren...
jaxLondonConference
 
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
Java EE 7 Platform: Boosting Productivity and Embracing HTML5 - Arun Gupta (R...
jaxLondonConference
 
Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...
Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...
Exploring the Talend unified Big Data toolset for sentiment analysis - Ben Br...
jaxLondonConference
 
The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)The Curious Clojurist - Neal Ford (Thoughtworks)
The Curious Clojurist - Neal Ford (Thoughtworks)
jaxLondonConference
 
Ad

Recently uploaded (20)

Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 

Project Lambda: Functional Programming Constructs in Java - Simon Ritter (Oracle)

  • 2. Project Lambda: Functional Programming Constructs In Java Simon Ritter Head of Java Evangelism Oracle Corporation Twitter: @speakjava 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 4. Some Background 4 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 5. Computing Today  Multicore is now the default – Moore’s law means more cores, not faster clockspeed  We need to make writing parallel code easier  All components of the Java SE platform are adapting – Language, libraries, VM Herb Sutter 5 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. http://www.gotw.ca/publications/concurrency-ddj.htm http://drdobbs.com/high-performance-computing/225402247 http://drdobbs.com/high-performance-computing/219200099 360 Cores 2.8 TB RAM 960 GB Flash InfiniBand …
  • 6. Concurrency in Java java.util.concurrent (jsr166) Phasers, etc java.lang.Thread (jsr166) 1.4 5.0 6 Project Lambda Fork/Join Framework (jsr166y) 7 8 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 6 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 2013...
  • 7. Goals For Better Parallelism In Java  Easy-to-use parallel libraries – Libraries can hide a host of complex concerns  task scheduling, thread management, load balancing, etc  Reduce conceptual and syntactic gap between serial and parallel expressions of the same computation – Currently serial code and parallel code for a given computation are very different  Fork-join is a good start, but not enough  Sometimes we need language changes to support better libraries – Lambda expressions 7 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 8. Bringing Lambdas To Java 8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 9. The Problem: External Iteration List<Student> students = ... double highestScore = 0.0; for (Student s : students) { if (s.gradYear == 2011) { if (s.score > highestScore) { highestScore = s.score; } } } 9 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. • • • Client controls iteration Inherently serial: iterate from beginning to end Not thread-safe because business logic is stateful (mutable accumulator variable)
  • 10. Internal Iteration With Inner Classes More Functional, Fluent and Monad Like  Iteraction, filtering and SomeList<Student> students = ... double highestScore = students.filter(new Predicate<Student>() { public boolean op(Student s) { return s.getGradYear() == 2011; } }).map(new Mapper<Student,Double>() { public Double extract(Student s) { return s.getScore(); } }).max(); 10 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. accumulation are handled by the library  Not inherently serial – traversal may be done in parallel  Traversal may be done lazily – so one pass, rather than three  Thread safe – client logic is stateless  High barrier to use – Syntactically ugly
  • 11. Internal Iteration With Lambdas SomeList<Student> students = ... double highestScore = students.filter(Student s -> s.getGradYear() == 2011) .map(Student s -> s.getScore()) .max(); • More readable • More abstract • Less error-prone • No reliance on mutable state • Easier to make parallel 11 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 12. Lambda Expressions Some Details  Lambda expressions are anonymous functions – Like a method, has a typed argument list, a return type, a set of thrown exceptions, and a body double highestScore = students.filter(Student s -> s.getGradYear() == 2011) .map(Student s -> s.getScore()) .max(); 12 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 13. Lambda Expression Types • Single-method interfaces used extensively to represent functions and callbacks – Definition: a functional interface is an interface with one method (SAM) – Functional interfaces are identified structurally – The type of a lambda expression will be a functional interface  This is very important interface interface interface interface interface 13 Comparator<T> FileFilter Runnable ActionListener Callable<T> Copyright © 2012, Oracle and/or its affiliates. All rights reserved. { { { { { boolean compare(T x, T y); } boolean accept(File x); } void run(); } void actionPerformed(…); } T call(); }
  • 14. Target Typing  A lambda expression is a way to create an instance of a functional interface – Which functional interface is inferred from the context – Works both in assignment and method invocation contexts  Can use casts if needed to resolve ambiguity Comparator<String> c = new Comparator<String>() { public int compare(String x, String y) { return x.length() - y.length(); } }; Comparator<String> c = (String x, String y) -> x.length() - y.length(); 14 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 15. Local Variable Capture • Lambda expressions can refer to effectively final local variables from the enclosing scope • Effectively final means that the variable meets the requirements for final variables (e.g., assigned once), even if not explicitly declared final • This is a form of type inference void expire(File root, long before) { ... root.listFiles(File p -> p.lastModified() <= before); ... } 15 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 16. Lexical Scoping • The meaning of names are the same inside the lambda as outside • A ‘this’ reference – refers to the enclosing object, not the lambda itself • Think of ‘this’ as a final predefined local • Remember the type of a Lambda is a functional interface class SessionManager { long before = ...; void expire(File root) { ... // refers to „this.before‟, just like outside the lambda root.listFiles(File p -> checkExpiry(p.lastModified(), before)); } boolean checkExpiry(long time, long expiry) { ... } } 16 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 17. Type Inferrence  Compiler can often infer parameter types in lambda expression Collections.sort(ls, (String x, String y) -> x.length() - y.length()); Collections.sort(ls, (x, y) -> x.length() - y.length());  Inferrence based on the target functional interface’s method signature  Fully statically typed (no dynamic typing sneaking in) – More typing with less typing 17 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 18. Method References • Method references let us reuse a method as a lambda expression FileFilter x = new FileFilter() { public boolean accept(File f) { return f.canRead(); } }; FileFilter x = (File f) -> f.canRead(); FileFilter x = File::canRead; 18 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 19. Constructor References interface Factory<T> { T make(); } Factory<List<String>> f = ArrayList<String>::new; Equivalent to Factory<List<String>> f = () -> return new ArrayList<String>();  When f.make() is invoked it will return a new ArrayList<String> 19 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 20. Lambda Expressions In Java Advantages  Developers primary tool for computing over aggregates is the for loop – Inherently serial – We need internal iteration  Useful for many libraries, serial and parallel  Adding Lambda expressions to Java is no longer a radical idea 20 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 21. Library Evolution 21 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 22. Library Evolution The Real Challenge • Adding lambda expressions is a big language change • If Java had them from day one, the APIs would definitely look different • Adding lambda expressions makes our aging APIs show their age even more  Most important APIs (Collections) are based on interfaces • How to extend an interface without breaking backwards compatability • Adding lambda expressions to Java, but not upgrading the APIs to use them, would be silly • Therefore we also need better mechanisms for library evolution 22 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 23. Library Evolution Goal  Requirement: aggregate operations on collections – New methods on Collections that allow for bulk operations – Examples: filter, map, reduce, forEach, sort – These can run in parallel (return Stream object) int heaviestBlueBlock = blocks.filter(b -> b.getColor() == BLUE) .map(Block::getWeight) .reduce(0, Integer::max);  This is problematic – Can’t add new methods to interfaces without modifying all implementations – Can’t necessarily find or control all implementations 23 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 24. Solution: Virtual Extension Methods AKA Defender Methods • Specified in the interface • From the caller’s perspective, just an ordinary interface method • List class provides a default implementation • Default is only used when implementation classes do not provide a body for the extension method • Implementation classes can provide a better version, or not  Drawback: requires VM support interface List<T> { void sort(Comparator<? super T> cmp) default { Collections.sort(this, cmp); }; } 24 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 25. Virtual Extension Methods Stop right there! • Err, isn’t this implementing multiple inheritance for Java? • Yes, but Java already has multiple inheritance of types • This adds multiple inheritance of behavior too • But not state, which is where most of the trouble is • Though can still be a source of complexity due to separate compilation and dynamic linking 25 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 26. Functional Interface Definitions  Single Abstract Method (SAM) type  A functional interface is an interface that has one abstract method – Represents a single function contract – Doesn’t mean it only has one method  Abstract classes may be considered later  @FunctionalInterface annotation – Helps ensure the functional interface contract is honoured – Compiler error if not a SAM 26 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 27. The Stream Class java.util.stream  Stream<T> – A sequence of elements supporting sequential and parallel operations  A Stream is opened by calling: – Collection.stream() – Collection.parallelStream() List<String> names = Arrays.asList(“Bob”, “Alice”, “Charlie”); System.out.println(names. stream(). filter(e -> e.getLength() > 4). findFirst(). get()); 27 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 28. java.util.stream Package  Accessed from Stream interface  Collector<T, R> – A (possibly) parallel reduction operation – Folds input elements of type T into a mutable results container of type R  e.g. String concatenation, min, max, etc 28 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 29. java.util.function Package  Predicate<T> – Determine if the input of type T matches some criteria  Consumer<T> – Accept a single input argumentof type T, and return no result  Function<T, R> – Apply a function to the input type T, generating a result of type R  Plus several more 29 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 30. Lambda Expressions in Use 30 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 31. Simple Java Data Structure public class Person { public enum Gender { MALE, FEMALE }; String name; Date birthday; Gender gender; String emailAddress; public String getName() { ... } public Gender getGender() { ... } public String getEmailAddress() { ... } public void printPerson() { // ... } } 31 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. List<Person> membership;
  • 32. Searching For Specific Characteristics (1) Simplistic, Brittle Approach public static void printPeopleOlderThan(List<Person> members, int age) { for (Person p : members) { if (p.getAge() > age) p.printPerson(); } } public static void printPeopleYoungerThan(List<Person> members, int age) { // ... } // And on, and on, and on... 32 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 33. Searching For Specific Characteristics (2) Separate Search Criteria /* Single abstract method type */ interface PeoplePredicate { public boolean satisfiesCriteria(Person p); } public static void printPeople(List<Person> members, PeoplePredicate match) { for (Person p : members) { if (match.satisfiesCriteria(p)) p.printPerson(); } } 33 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 34. Searching For Specific Characteristics (3) Separate Search Criteria public class RetiredMen implements PeoplePredicate { // ... public boolean satisfiesCriteria(Person p) { if (p.gender == Person.Gender.MALE && p.getAge() >= 65) return true; return false; } } printPeople(membership, new RetiredMen()); 34 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 35. Searching For Specific Characteristics (4) Separate Search Criteria Using Anonymous Inner Class printPeople(membership, new PeoplePredicate() { public boolean satisfiesCriteria(Person p) { if (p.gender == Person.Gender.MALE && p.getAge() >= 65) return true; return false; } }); 35 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 36. Searching For Specific Characteristics (5) Separate Search Criteria Using Lambda Expression printPeople(membership, p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65);  We now have parameterised behaviour, not just values – This is really important – This is why Lambda statements are such a big deal in Java 36 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 37. Make Things More Generic (1) interface PeoplePredicate { public boolean satisfiesCriteria(Person p); } /* From java.util.function class library */ interface Predicate<T> { public boolean test(T t); } 37 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 38. Make Things More Generic (2) public static void printPeopleUsingPredicate( List<Person> members, Predicate<Person> predicate) { for (Person p : members) { if (predicate.test()) p.printPerson(); } Interface defines behaviour } Call to method executes behaviour printPeopleUsingPredicate(membership, p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65); Behaviour passed as parameter 38 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 39. Using A Consumer (1) interface Consumer<T> { public void accept(T t); } public void processPeople(List<Person> members, Predicate<Person> predicate, Consumer<Person> consumer) { for (Person p : members) { if (predicate.test(p)) consumer.accept(p); } } 39 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 40. Using A Consumer (2) processPeople(membership, p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65, p -> p.printPerson()); processPeople(membership, p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65, Person::printPerson); 40 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 41. Using A Return Value (1) interface Function<T, R> { public R apply(T t); } public static void processPeopleWithFunction( List<Person> members, Predicate<Person> predicate, Function<Person, String> function, Consumer<String> consumer) { for (Person p : members) { if (predicate.test(p)) { String data = function.apply(p); consumer.accept(data); } } } 41 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 42. Using A Return Value (2) processPeopleWithFunction( membership, p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65, p -> p.getEmailAddress(), email -> System.out.println(email)); processPeopleWithFunction( membership, p -> p.getGender() == Person.Gender.MALE && p.getAge() >= 65, Person::getEmailAddress, System.out::println); 42 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 43. Conclusions  Java needs lambda statements for multiple reasons – Significant improvements in existing libraries are required – Replacing all the libraries is a non-starter – Compatibly evolving interface-based APIs has historically been a problem  Require a mechanism for interface evolution – Solution: virtual extension methods – Which is both a language and a VM feature – And which is pretty useful for other things too  Java SE 8 evolves the language, libraries, and VM together 43 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.
  • 44. 44 Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Editor's Notes

  • #11: Fluent APIMonad
  • #12: Question: how are we going to get there with real collections?
  • #14: Erasedfunction types are the worst of both worlds
  • #24: Current fashion: imagine the libraries you want, then build the language features to suitBut, are we explicit enough that this is what we&apos;re doing? This is hard because lead times on language work are longer than on librariesSo temptation is to front-load language work and let libraries slideWe should always be prepared to answer: why *these* language features?
  • #25: Can also say “default none” to reabstract the method
  • #26: Start talking about how this is a VM feature