SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
Java 8
A step closer to Parallelism
 
JDK General Evolution Policy
 
!  Don't break binary compatibility
!  Avoid introducing source incompatibilities.
!  Manage behavioral compatibility change

Extends to Language Evolution
 
!  Continue to recognize old class files
!  Limit cases where current legal code stops compiling
!  Avoid changes in code generation introducing behavioral changes
Modernizing the Java Platform in JDK8
 
!  Language
–  Lambda Expressions (Closures)
–  Interface Evolution (default methods)

!  Libraries
–  Bulk data operations on Collections
–  More library support for Parallelism

!  JVM
–  Default Methods
–  Enhancement to invokedynamic
What is a Lambda Expression?
 
!  A Lambda expression is an anonymous method.
–  Has an argument list, a return type and a body.
!  (Object o) - o.toString()

–  Can refer to values from the enclosing lexical scope.
!  (Person p) - p.getName().equals(name)

!  A method reference is a reference to an existing method.
–  Object :: toString

!  Allow you to treat code as data.
–  Behavior can be stored in variables and passed to methods.
 
External Iteration
 
!  Lets say I write a code to check marathon method.
!  Check each marathon. If it can’t be finished on time, return the marathon that
can be a problem, otherwise return null.
private Marathon checkMarathons(ListMarathon problemMarathons) {
Marathon problemMarathon = null;
IteratorMarathon marathonItr = problemMarathons.iterator();
while (marathonItr.hasNext()  problemMarathon == null) {
Marathon marathon = marathonItr.next();
problemMarathon = chckMarathon(marathon);
}
return problemMarathon;
}
–  Loop is inherently sequential.
–  Client has to manage iteration and parallelization if needed.
–  bring the data to the code
 
Internal Iteration with Lambda
 
!  We could write this as
private OptionalMarathon checkMarathons(ListMarathon problemMarathons) {
return problemMarathons.stream().
map(p-checkMarathon(p)).
filter(p- p!=null).
findfirst();
}

– 
– 
– 
– 

bring the operation to the data
Library free to use parallelism(like fork/join), out-of-order execution, laziness.
Client passes behavior into APIs as data
Enables APIs designers to build more powerful, expressive APIs.

!  And easily make it execute in parallel !!!
 
Interface Evolution
 
!  Interfaces are a double-edged sword
–  Cannot compatibly evolve them unless you control all implementations
–  Reality : APIs age
–  What to do with old APIs :
!  Let the APIs stagnate
!  Replace it in entirely
!  Modify existing APIs

!  Burden of API evolution should fall to implementors, not users.
Functional Interfaces
 
!  We have used single-method interfaces to represent functions
–  Runnable, Comparator, ActionListener

!  Lets call them Functional Interfaces.
!  And introduce some new ones like PredicateT, BlockT
!  A lambda expression evaluates to an instance of a functional inte
rface.
–  PredicateString isEmpty = s-s.isEmpty();
–  PredicateString isEmpty = String::isEmpty;
–  Runnable r = ()-{System.out.println(“lambda”);}
Taking values to higher order
 
!  Instead of supplying values to specific library methods like here
public interface CollectionE {
boolean remove(Object o);
}

!  We’re going to supply behavior to general library methods.
public interface CollectionE {
boolean removeIf(Predicate? Super E p);
}

!  Each stage has specific operation
!  Client code reads like problem statement
Predicate is an interface with a single abstract boolean-valued method test. removeIf() executes test fo
r each element and if test() returns true, removeIf() removes that element.
Default Methods
 
!  A default method provides an implementation in the interface.
!  Woven in by the VM at link time.
!  Multiple Inheritance?
–  Java always had multiple inheritance of TYPES
–  This adds multiple inheritance of BEHAVIOR
interface CollectionT {
...
default void forEach(BlockT action) {
for (T t : this)
action.apply(t);
}
}
Default Methods – Inheritance Rules

Contenu connexe

Tendances

Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Harmeet Singh(Taara)
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8icarter09
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8LivePerson
 
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
 
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 GoetzJAX London
 
java 8 new features
java 8 new features java 8 new features
java 8 new features Rohit Verma
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features OverviewSergii Stets
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Nayden Gochev
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014Nayden Gochev
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8Talha Ocakçı
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIGanesh Samarthyam
 
Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java langer4711
 
SoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringSoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringNayden Gochev
 

Tendances (20)

Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
 
Java 8
Java 8Java 8
Java 8
 
Java8
Java8Java8
Java8
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
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
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 
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
 
java 8 new features
java 8 new features java 8 new features
java 8 new features
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java Programming with Lambda Expressions in Java
Programming with Lambda Expressions in Java
 
SoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with SpringSoftwareUniversity seminar fast REST Api with Spring
SoftwareUniversity seminar fast REST Api with Spring
 

En vedette

How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...Amazon Web Services
 
Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...
Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...
Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...Amazon Web Services
 
16h00 globant - aws globant-big-data_summit2012
16h00   globant - aws globant-big-data_summit201216h00   globant - aws globant-big-data_summit2012
16h00 globant - aws globant-big-data_summit2012infolive
 
Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014
Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014
Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014Amazon Web Services
 
Overview of .Net Development on AWS
Overview of .Net Development on AWSOverview of .Net Development on AWS
Overview of .Net Development on AWSAmazon Web Services
 

En vedette (8)

ArcServe in the AWS Cloud - part II
ArcServe in the AWS Cloud - part IIArcServe in the AWS Cloud - part II
ArcServe in the AWS Cloud - part II
 
How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...How Public Sector Entities are Advancing Their Security and Governance Capabi...
How Public Sector Entities are Advancing Their Security and Governance Capabi...
 
History of london
History of londonHistory of london
History of london
 
Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...
Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...
Updating Security Operations for the Cloud - AWS Symposium 2014 - Washington ...
 
16h00 globant - aws globant-big-data_summit2012
16h00   globant - aws globant-big-data_summit201216h00   globant - aws globant-big-data_summit2012
16h00 globant - aws globant-big-data_summit2012
 
Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014
Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014
Amazon Web Services in the Public Sector - AWS Washington D.C. Symposium 2014
 
Running Lean Architectures
Running Lean ArchitecturesRunning Lean Architectures
Running Lean Architectures
 
Overview of .Net Development on AWS
Overview of .Net Development on AWSOverview of .Net Development on AWS
Overview of .Net Development on AWS
 

Similaire à Java 8 - A step closer to Parallelism

Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Codeerikmsp
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
Java 8 New features
Java 8 New featuresJava 8 New features
Java 8 New featuresSon Nguyen
 
A Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its APIA Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its APIJörn Guy Süß JGS
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Raffi Khatchadourian
 
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 InterfacesRaffi Khatchadourian
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, androidi i
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipseanshunjain
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8Dinesh Pathak
 
ParaSail
ParaSail  ParaSail
ParaSail AdaCore
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8 Dori Waldman
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 

Similaire à Java 8 - A step closer to Parallelism (20)

Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Working Effectively With Legacy Perl Code
Working Effectively With Legacy Perl CodeWorking Effectively With Legacy Perl Code
Working Effectively With Legacy Perl Code
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Java basics
Java basicsJava basics
Java basics
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Java 8 New features
Java 8 New featuresJava 8 New features
Java 8 New features
 
A Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its APIA Brief Conceptual Introduction to Functional Java 8 and its API
A Brief Conceptual Introduction to Functional Java 8 and its API
 
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
Open Problems in Automatically Refactoring Legacy Java Software to use New Fe...
 
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
 
Java 8 Feature Preview
Java 8 Feature PreviewJava 8 Feature Preview
Java 8 Feature Preview
 
imperative programming language, java, android
imperative programming language, java, androidimperative programming language, java, android
imperative programming language, java, android
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
New Features of JAVA SE8
New Features of JAVA SE8New Features of JAVA SE8
New Features of JAVA SE8
 
ParaSail
ParaSail  ParaSail
ParaSail
 
whats new in java 8
whats new in java 8 whats new in java 8
whats new in java 8
 
Lambdas
LambdasLambdas
Lambdas
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 

Plus de jbugkorea

Hawkular overview
Hawkular overviewHawkular overview
Hawkular overviewjbugkorea
 
미들웨어 엔지니어의 클라우드 탐방기
미들웨어 엔지니어의 클라우드 탐방기미들웨어 엔지니어의 클라우드 탐방기
미들웨어 엔지니어의 클라우드 탐방기jbugkorea
 
기업, 통합, 마이크로서비스
기업, 통합, 마이크로서비스기업, 통합, 마이크로서비스
기업, 통합, 마이크로서비스jbugkorea
 
개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링
개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링
개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링jbugkorea
 
JBUG Korea 소개
JBUG Korea 소개JBUG Korea 소개
JBUG Korea 소개jbugkorea
 
Micro Service Architecture 탐방기
Micro Service Architecture 탐방기Micro Service Architecture 탐방기
Micro Service Architecture 탐방기jbugkorea
 
Jbug 발표 msa탐방기_공유자료
Jbug 발표 msa탐방기_공유자료Jbug 발표 msa탐방기_공유자료
Jbug 발표 msa탐방기_공유자료jbugkorea
 
Micro Service Architecture(MSA) 탐방기
Micro Service Architecture(MSA) 탐방기Micro Service Architecture(MSA) 탐방기
Micro Service Architecture(MSA) 탐방기jbugkorea
 
INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축
INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축
INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축jbugkorea
 
테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트
테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트
테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트jbugkorea
 
맛만 보자 Undertow
맛만 보자 Undertow맛만 보자 Undertow
맛만 보자 Undertowjbugkorea
 
맛만 보자 액터 모델이란
맛만 보자 액터 모델이란 맛만 보자 액터 모델이란
맛만 보자 액터 모델이란 jbugkorea
 
맛만 보자 Finagle이란
맛만 보자 Finagle이란 맛만 보자 Finagle이란
맛만 보자 Finagle이란 jbugkorea
 
Undertow 맛보기
Undertow 맛보기Undertow 맛보기
Undertow 맛보기jbugkorea
 
JBoss Community Introduction
JBoss Community IntroductionJBoss Community Introduction
JBoss Community Introductionjbugkorea
 
JBoss AS 7 따라잡기
JBoss AS 7 따라잡기JBoss AS 7 따라잡기
JBoss AS 7 따라잡기jbugkorea
 
Wildfly 8.0에서 SOAP 웹 서비스 구현
Wildfly 8.0에서 SOAP 웹 서비스 구현Wildfly 8.0에서 SOAP 웹 서비스 구현
Wildfly 8.0에서 SOAP 웹 서비스 구현jbugkorea
 
Infinispan Data Grid Platform
Infinispan Data Grid PlatformInfinispan Data Grid Platform
Infinispan Data Grid Platformjbugkorea
 
JBoss Community's Application Monitoring Platform
JBoss Community's Application Monitoring PlatformJBoss Community's Application Monitoring Platform
JBoss Community's Application Monitoring Platformjbugkorea
 

Plus de jbugkorea (19)

Hawkular overview
Hawkular overviewHawkular overview
Hawkular overview
 
미들웨어 엔지니어의 클라우드 탐방기
미들웨어 엔지니어의 클라우드 탐방기미들웨어 엔지니어의 클라우드 탐방기
미들웨어 엔지니어의 클라우드 탐방기
 
기업, 통합, 마이크로서비스
기업, 통합, 마이크로서비스기업, 통합, 마이크로서비스
기업, 통합, 마이크로서비스
 
개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링
개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링
개발자가 인프라를 만났을때 - RHQ를 활용한 Legacy System 모니터링
 
JBUG Korea 소개
JBUG Korea 소개JBUG Korea 소개
JBUG Korea 소개
 
Micro Service Architecture 탐방기
Micro Service Architecture 탐방기Micro Service Architecture 탐방기
Micro Service Architecture 탐방기
 
Jbug 발표 msa탐방기_공유자료
Jbug 발표 msa탐방기_공유자료Jbug 발표 msa탐방기_공유자료
Jbug 발표 msa탐방기_공유자료
 
Micro Service Architecture(MSA) 탐방기
Micro Service Architecture(MSA) 탐방기Micro Service Architecture(MSA) 탐방기
Micro Service Architecture(MSA) 탐방기
 
INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축
INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축
INFINISPAN non-clustering Spring4 WEB/MOBILE APP 구축
 
테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트
테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트
테스트 어디까지 해봤니? Arquillian을 이용한 Real Object 테스트
 
맛만 보자 Undertow
맛만 보자 Undertow맛만 보자 Undertow
맛만 보자 Undertow
 
맛만 보자 액터 모델이란
맛만 보자 액터 모델이란 맛만 보자 액터 모델이란
맛만 보자 액터 모델이란
 
맛만 보자 Finagle이란
맛만 보자 Finagle이란 맛만 보자 Finagle이란
맛만 보자 Finagle이란
 
Undertow 맛보기
Undertow 맛보기Undertow 맛보기
Undertow 맛보기
 
JBoss Community Introduction
JBoss Community IntroductionJBoss Community Introduction
JBoss Community Introduction
 
JBoss AS 7 따라잡기
JBoss AS 7 따라잡기JBoss AS 7 따라잡기
JBoss AS 7 따라잡기
 
Wildfly 8.0에서 SOAP 웹 서비스 구현
Wildfly 8.0에서 SOAP 웹 서비스 구현Wildfly 8.0에서 SOAP 웹 서비스 구현
Wildfly 8.0에서 SOAP 웹 서비스 구현
 
Infinispan Data Grid Platform
Infinispan Data Grid PlatformInfinispan Data Grid Platform
Infinispan Data Grid Platform
 
JBoss Community's Application Monitoring Platform
JBoss Community's Application Monitoring PlatformJBoss Community's Application Monitoring Platform
JBoss Community's Application Monitoring Platform
 

Dernier

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

Java 8 - A step closer to Parallelism

  • 1. Java 8 A step closer to Parallelism
  • 2.  
  • 3.
  • 4.
  • 6.   !  Don't break binary compatibility !  Avoid introducing source incompatibilities. !  Manage behavioral compatibility change Extends to Language Evolution
  • 7.   !  Continue to recognize old class files !  Limit cases where current legal code stops compiling !  Avoid changes in code generation introducing behavioral changes
  • 8. Modernizing the Java Platform in JDK8
  • 9.   !  Language –  Lambda Expressions (Closures) –  Interface Evolution (default methods) !  Libraries –  Bulk data operations on Collections –  More library support for Parallelism !  JVM –  Default Methods –  Enhancement to invokedynamic
  • 10. What is a Lambda Expression?
  • 11.   !  A Lambda expression is an anonymous method. –  Has an argument list, a return type and a body. !  (Object o) - o.toString() –  Can refer to values from the enclosing lexical scope. !  (Person p) - p.getName().equals(name) !  A method reference is a reference to an existing method. –  Object :: toString !  Allow you to treat code as data. –  Behavior can be stored in variables and passed to methods.
  • 12.  
  • 14.   !  Lets say I write a code to check marathon method. !  Check each marathon. If it can’t be finished on time, return the marathon that can be a problem, otherwise return null. private Marathon checkMarathons(ListMarathon problemMarathons) { Marathon problemMarathon = null; IteratorMarathon marathonItr = problemMarathons.iterator(); while (marathonItr.hasNext() problemMarathon == null) { Marathon marathon = marathonItr.next(); problemMarathon = chckMarathon(marathon); } return problemMarathon; } –  Loop is inherently sequential. –  Client has to manage iteration and parallelization if needed. –  bring the data to the code
  • 15.  
  • 17.   !  We could write this as private OptionalMarathon checkMarathons(ListMarathon problemMarathons) { return problemMarathons.stream(). map(p-checkMarathon(p)). filter(p- p!=null). findfirst(); } –  –  –  –  bring the operation to the data Library free to use parallelism(like fork/join), out-of-order execution, laziness. Client passes behavior into APIs as data Enables APIs designers to build more powerful, expressive APIs. !  And easily make it execute in parallel !!!
  • 18.  
  • 20.   !  Interfaces are a double-edged sword –  Cannot compatibly evolve them unless you control all implementations –  Reality : APIs age –  What to do with old APIs : !  Let the APIs stagnate !  Replace it in entirely !  Modify existing APIs !  Burden of API evolution should fall to implementors, not users.
  • 22.   !  We have used single-method interfaces to represent functions –  Runnable, Comparator, ActionListener !  Lets call them Functional Interfaces. !  And introduce some new ones like PredicateT, BlockT !  A lambda expression evaluates to an instance of a functional inte rface. –  PredicateString isEmpty = s-s.isEmpty(); –  PredicateString isEmpty = String::isEmpty; –  Runnable r = ()-{System.out.println(“lambda”);}
  • 23. Taking values to higher order
  • 24.   !  Instead of supplying values to specific library methods like here public interface CollectionE { boolean remove(Object o); } !  We’re going to supply behavior to general library methods. public interface CollectionE { boolean removeIf(Predicate? Super E p); } !  Each stage has specific operation !  Client code reads like problem statement Predicate is an interface with a single abstract boolean-valued method test. removeIf() executes test fo r each element and if test() returns true, removeIf() removes that element.
  • 26.   !  A default method provides an implementation in the interface. !  Woven in by the VM at link time. !  Multiple Inheritance? –  Java always had multiple inheritance of TYPES –  This adds multiple inheritance of BEHAVIOR interface CollectionT { ... default void forEach(BlockT action) { for (T t : this) action.apply(t); } }
  • 27. Default Methods – Inheritance Rules
  • 28.   !  Rule 1 – prefer superclass methods to interface methods (Class wins) !  Rule 2 – prefer more specific interfaces to less (Subtype wins) !  Rule 3 – otherwise, act as if the method is abstract. In the case of conflicting defaults, the concrete class must provide an impleme ntation.
  • 30.   !  Venerable unix tool-building pattern ps –ef | grep login | cut –c 50- | head !  And in Enterprise integration patterns Incoming Order - Pipe|Filter - Decrypt - Pipe|Filter - Authenticate - Pipe|Filter - De-Dup - Pipe - Order !  Pipes and Filters in Collections
  • 32.  
  • 33. Bulk Operations on Collections
  • 34.   Bulk operations on collections also enable a map / reduce style of progra mming. For example, the above code could be further decomposed by gett ing a stream from the shapes collection, filtering the red elements, and the n iterating only over the filtered elements. shapes.stream() .filter(s - s.getColor() == RED) .forEach(s - { s.setColor(BLUE); }); !  Compose compound operations from basic building blocks. !  Each stage has specific operation !  Client code reads like problem statement
  • 35. Streams Fork/Join Parallelism
  • 36.   Streams !  Represents streams of values, not a data structure. !  Source can be collection, array, functions, I/O… collection.stream() .filter(f-f.isBlue()) .map(f-f.getBar()) .forEach(System.out…); Fork/Join Parallelism !  Powerful and efficient but not so easy !  Divide problem into subsets, solve in parallel and combine results.
  • 38.   !  Collection.parallel().filter(…).map(…).reduce(…); !  ConcurrentHashMap.parallel(ForkJoinPool) –  Returns parallel view of CHM –  Methods : forEach, forEachEntry, forEachKey, forEachValue –  Consider forEachValue(ConcurrentHashMap.ActionV action) !  Creates a new ForEachValueTask !  Subclass of ForkJoinTask !  Submits that to the ForkJoinPool !  ForkJoinPool executes ForEachValueTask on one of its threads.
  • 39.
  • 41.   !  ConcurrentHashMap.ForEachValueTask @SupressWarnings(“unchecked”) public final void compute() { final ActionV action = this.action; if (action == null) throw new Error(NullFunctionMessage); int b = batch(), c; while (b 1 baseIndex != baseLimit) { do{} while (@casPending(c=pending, c+1)); new ForEachValueTaskK,V(this, b=1, true, action).fork(); Object v; while ((v == advance()) != null) action.apply((V)v); tryComplete(); } }
  • 43.   !  Sorting a list using comparator Collections.sort(planList, new ComparatorPlan() { public int compare(Plan P1, Plan P2) { return P1.getTask().compareTo(P2.getTask()); } } The method compare must extract the first level sort keys and then compare them. !  Suppose we have a method that accepts and returns behaviors : ComparatorT comparing(MapperT,U m); Now, its much easier to create custom comparators : ComparatorPlan byTask = Comparators.compare(p-getTask)); ComparatorPlan byDuration = Comparators.compare(p-getDuration));
  • 45.   !  Methods and Comparators can now be composed –  new Comparator method Collections.sort(planList, byTask.compose(byDuration)); And also planList.sort(byTask.compose(byDuration));
  • 46. How is lambda created?
  • 47.   !  Using an anonymous inner class?? problemMarathon.removeIf(new PredicateMarathon() { public boolean test(Marathon p) { return p.equals(problemMarathon) } }); !  Let the static compiler emit a declarative recipe for creating a lambda. !  Let the runtime execute that recipe however it deems best !  This is like a job for invokedynamic??
  • 48.  
  • 49.  
  • 50.  
  • 52.   !  The JVM has 4 bytecodes for method invocation : –  –  –  –  invokestatic for static methods. invokevirtual for class methods invokeinterface interface methods invokespecial for constructors, private methods and super calls. !  New Bytecode Tool – invokedynamic –  The JVM adds a fifth invocation mode: invokedynamic (indy) –  Behavior of invoke(virtual, static, interface) are fixed.
  • 53. New Bytecode Tool - invokedynamic
  • 54.   !  Any indy call site has three group of operands : –  A bootstrap method –  A static argument list –  A dynamic argument list !  We use indy to embed a recipe for constructing a lambda at the capture site. –  Desugared implementation method. –  Functional interface we are converting to. –  Values captured from lexical scope. !  The captured site is called lambda factory. –  Invoked with indy, returns an instance of functional interface
  • 56.   !  First we desugar the lambda to a method –  Signature matches functional interface method. –  Captured arguments prepended if any –  Simplest lambdas desugar to static methods. PredicatePerson olderThanK = p-p.getAge() = k; private static boolean lambda$1(int capturedK, person p) { return p.getAge() = capturedK; }
  • 57.  
  • 58.  
  • 59.  
  • 60.  
  • 61.  
  • 63.   !  We generate an indy call site, which returns the lambda. –  This is the lambda factory. –  Bootstrap for the lambda factory selects the translation strategy. Bootstrap is called the lambda metafactory. list.removeAll(p-p.getAge() = minAge); Predicate $p = indy[bootstrap=LambdaMetafactory, staticargs=[Predicate, lambda$1], dynargs=[minAge]]; list.removeAll($p); Private static boolean lambda$1(int capturedK, Person p) { return p.getAge() = capturedK; } –  Captured arguments passed to lambda factory.
  • 64.  
  • 66.