SlideShare une entreprise Scribd logo
1  sur  15
Hidetomo Moriomoto
http://github.com/mocchidesu
2014/05/05
* Brief history of Java
*What's new in Java 8
*Why Lambda?
* Sample Program &&
Bench mark
James Gosling: Father of Java
Date Version Highlights
1991 Oak by James Gosling@Sun
Microsystems
Named after oak tree stood
outside his office. For small
PDA device. Slight flavor of C
1996 Jan 23 JDK 1.0 “Oak” sounds similar to “awk”?
1997 Java 1.1 JDBC, reflection, JIT compiler
1998 Java2 (J2SE) Collection framework,
Swing(GUI)API
2000 Java 1.3 JNDI, RMI
2002 Feb. Java 1.4 Regex, JAXP
2004 Sept. Java 1.5 Generics, annotation, enum,
concurrency, varargs
2006 Dec. Java 1.6 Performance tune, JDBC4
2011 July Java 1.7 JVM support dynamic language
Features
DateTime API (no more new Date(), Calendar.getInstance()!)
Nashborn JavaScript engine ($JAVA_HOME/bin/jjs)
Default method in Interface / Improved concurrent package /
Optional
Lambda expressions
@FunctionalInterface annotations
Method Reference
java.util.Stream package
Backward Compatibility
Binary compatibility && Behavioral compatibility - Excellent
Source compatibility - Good
Lambda is a syntax that produces instance of
Functional Interface.
Functional Interface is:
Interface that has exactly one abstract method
- Runnable ( run() )
- Comparator (compare() )
See
@FunctionalInterface (java.lang.annotation)
List of interface under java.util.function package
You can define your own interface, of course.
 Leap to functional language (Haskell, Erlang,
JavaScript, Lisp, Scala, Ocaml, etc.)
 Single-method interface (syntax sugar)
 Provide a path to multicore (stream vs.
parallel stream) -> see demo.
 No more for loop (internal loop vs. external
loop)
In short … function is the 1st level Object
/*
* JavaScript can pass method as a parameter.
*/
var doSomething = function(name){
console.log(name + "is going to do something someday");
}
function useSomething(func, param){
func(param);
}
Event handler
(parameter) -> { // do something} ; // that’s it!
Further simplify with “Type interface” - best guess
@FunctionalInterface
private interface HelloWorld{
public String hello(String name);
}
Old anonymous class
HelloWorld hello = new HelloWorld() {
@Override
public String hello(String name) {
return "Hello, " + name;
}
};
Ex 1) -> Get Simplified with Lambda (You don’t need to specify method name)
(String name) -> { return “Hello “+name + “!!”; };
Ex 2) Remove String -> JVM best guess – type interface
(name) -> { return “Hello “+name+”!!”; };
Ex 3) Remove return – type interface
(name) -> { “Hello “+name+”!!”; };
Ex 4) Remove brackets for single implementation.
(name) -> “Hello “+name+”!!”;
Ex 5) Remove () if parameter is one
name -> “Hello “+name+”!!”;
(name -> “Hello “+name+”!!”;
 Start with .stream(), chain with intermediate
operators, end with terminal operator.
 IntermediateOperator
(filter, map, sorted, distinct, limit)
 Terminal Operator
(forEach, collect, reduce, iterator)
 listOfSomething.stream()
.filter( element -> element.age > 30) //
.map( ) // not evaluated
.sorted() // not evaluated
.limit() // not evaluated
….
.collect( Collectors.toList() );  Finally evaluate
Sample Code (Run com.hidetomo.Java8StreamBench.main)
https://github.com/mocchidesu/Java8sample.git
Input: 100,000 last name from HSA
Do:
Filter: Last name start with ‘m’
Map: (Brace each name with [] bracket)
Sort: Reverse order
Dedupe
Limit to top 2 results
Loop 1000 times.
Traditional Java7 For Loop approach vs. Sequential
Lambda vs. Parallel Lambda. -> IntelliJ13
 Java 8 is backward compatible in binary level
 Lambda is not only a syntax sugar
 It’s a new era of Java
 Performance gain?Will be improved. Stay
tuned.
 When use? NOW
Everything about Java 8
http://www.techempower.com/blog/2013/03/26/everything-about-java-8/
Oracle Compatibility Guide for JDK 8
http://www.oracle.com/technetwork/java/javase/8-compatibility-guide-
2156366.html
Lambda Peek under the Hood by Brian Goetz - Java One 2013
http://www.slideshare.net/jaxlondon2012/lambda-a-peek-under-the-hood-brian-
goetz
10 Example of Lambda Expressions and Streams in Java 8
http://javarevisited.blogspot.com/2014/02/10-example-of-lambda-expressions-in-
java8.html
 Github.com/hidetomo/java8sample.git
 Slideshare /hidetomomorimoto

Contenu connexe

Tendances

ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overviewhesher
 
ES6 in Production [JSConfUY2015]
ES6 in Production [JSConfUY2015]ES6 in Production [JSConfUY2015]
ES6 in Production [JSConfUY2015]Guillermo Paz
 
Clojure and the Web
Clojure and the WebClojure and the Web
Clojure and the Webnickmbailey
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracerrahulrevo
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습DoHyun Jung
 
JSR 172: XML Parsing in MIDP
JSR 172: XML Parsing in MIDPJSR 172: XML Parsing in MIDP
JSR 172: XML Parsing in MIDPJussi Pohjolainen
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Anton Arhipov
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeCory Forsyth
 
Ruby on Rails Oracle adaptera izstrāde
Ruby on Rails Oracle adaptera izstrādeRuby on Rails Oracle adaptera izstrāde
Ruby on Rails Oracle adaptera izstrādeRaimonds Simanovskis
 
ゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクトゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクトRyuichi ITO
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perltypester
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM ProfilingAndrei Pangin
 

Tendances (20)

ORMs in Golang
ORMs in GolangORMs in Golang
ORMs in Golang
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
ES6 in Production [JSConfUY2015]
ES6 in Production [JSConfUY2015]ES6 in Production [JSConfUY2015]
ES6 in Production [JSConfUY2015]
 
Clojure and the Web
Clojure and the WebClojure and the Web
Clojure and the Web
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracer
 
Seeking Clojure
Seeking ClojureSeeking Clojure
Seeking Clojure
 
Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011Nick Sieger JRuby Concurrency EMRubyConf 2011
Nick Sieger JRuby Concurrency EMRubyConf 2011
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
 
JSR 172: XML Parsing in MIDP
JSR 172: XML Parsing in MIDPJSR 172: XML Parsing in MIDP
JSR 172: XML Parsing in MIDP
 
NIO and NIO2
NIO and NIO2NIO and NIO2
NIO and NIO2
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
What`s new in Java 7
What`s new in Java 7What`s new in Java 7
What`s new in Java 7
 
Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012Mastering Java Bytecode With ASM - 33rd degree, 2012
Mastering Java Bytecode With ASM - 33rd degree, 2012
 
Explaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to ComeExplaining ES6: JavaScript History and What is to Come
Explaining ES6: JavaScript History and What is to Come
 
Ruby on Rails Oracle adaptera izstrāde
Ruby on Rails Oracle adaptera izstrādeRuby on Rails Oracle adaptera izstrāde
Ruby on Rails Oracle adaptera izstrāde
 
ゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクトゼロから始めるScalaプロジェクト
ゼロから始めるScalaプロジェクト
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
 
Shell script-sec
Shell script-secShell script-sec
Shell script-sec
 

En vedette

En vedette (10)

Web quest final
Web quest finalWeb quest final
Web quest final
 
Silabo abril agosto 2016 sicoa 2
Silabo abril agosto 2016 sicoa 2Silabo abril agosto 2016 sicoa 2
Silabo abril agosto 2016 sicoa 2
 
Her Hyundai has 5 seats. 2 in the front, 3 in the back.
Her Hyundai has 5 seats. 2 in the front, 3 in the back.Her Hyundai has 5 seats. 2 in the front, 3 in the back.
Her Hyundai has 5 seats. 2 in the front, 3 in the back.
 
Orient localiz
Orient localizOrient localiz
Orient localiz
 
9
99
9
 
12
1212
12
 
Nodejs on 02/22/2012
Nodejs on 02/22/2012Nodejs on 02/22/2012
Nodejs on 02/22/2012
 
13
1313
13
 
7
77
7
 
Aspectos preliminares
Aspectos preliminaresAspectos preliminares
Aspectos preliminares
 

Similaire à Java 8 briefing

JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Java Intro
Java IntroJava Intro
Java Introbackdoor
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpathLyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpathAlexis Hassler
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath Alexis Hassler
 
A brief tour of modern Java
A brief tour of modern JavaA brief tour of modern Java
A brief tour of modern JavaSina Madani
 
Xml Java
Xml JavaXml Java
Xml Javacbee48
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
Модерни езици за програмиране за JVM (2011)
Модерни езици за програмиране за JVM (2011)Модерни езици за програмиране за JVM (2011)
Модерни езици за програмиране за JVM (2011)Bozhidar Batsov
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RaceBaruch Sadogursky
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lispelliando dias
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Java 7 Language Enhancement
Java 7 Language EnhancementJava 7 Language Enhancement
Java 7 Language Enhancementmuthusvm
 
From Java To Clojure (English version)
From Java To Clojure (English version)From Java To Clojure (English version)
From Java To Clojure (English version)Kent Ohashi
 

Similaire à Java 8 briefing (20)

JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Java Intro
Java IntroJava Intro
Java Intro
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpathLyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
 
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath LyonJUG : Comment Jigsaw est prêt à tuer le classpath
LyonJUG : Comment Jigsaw est prêt à tuer le classpath
 
A brief tour of modern Java
A brief tour of modern JavaA brief tour of modern Java
A brief tour of modern Java
 
55 New Features in Java 7
55 New Features in Java 755 New Features in Java 7
55 New Features in Java 7
 
Xml Java
Xml JavaXml Java
Xml Java
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Модерни езици за програмиране за JVM (2011)
Модерни езици за програмиране за JVM (2011)Модерни езици за програмиране за JVM (2011)
Модерни езици за програмиране за JVM (2011)
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
Project Coin
Project CoinProject Coin
Project Coin
 
Pure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools RacePure Java RAD and Scaffolding Tools Race
Pure Java RAD and Scaffolding Tools Race
 
Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Scala
ScalaScala
Scala
 
Java 7 Language Enhancement
Java 7 Language EnhancementJava 7 Language Enhancement
Java 7 Language Enhancement
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
 
From Java To Clojure (English version)
From Java To Clojure (English version)From Java To Clojure (English version)
From Java To Clojure (English version)
 

Dernier

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Dernier (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Java 8 briefing

  • 2. * Brief history of Java *What's new in Java 8 *Why Lambda? * Sample Program && Bench mark James Gosling: Father of Java
  • 3. Date Version Highlights 1991 Oak by James Gosling@Sun Microsystems Named after oak tree stood outside his office. For small PDA device. Slight flavor of C 1996 Jan 23 JDK 1.0 “Oak” sounds similar to “awk”? 1997 Java 1.1 JDBC, reflection, JIT compiler 1998 Java2 (J2SE) Collection framework, Swing(GUI)API 2000 Java 1.3 JNDI, RMI 2002 Feb. Java 1.4 Regex, JAXP 2004 Sept. Java 1.5 Generics, annotation, enum, concurrency, varargs 2006 Dec. Java 1.6 Performance tune, JDBC4 2011 July Java 1.7 JVM support dynamic language
  • 4. Features DateTime API (no more new Date(), Calendar.getInstance()!) Nashborn JavaScript engine ($JAVA_HOME/bin/jjs) Default method in Interface / Improved concurrent package / Optional Lambda expressions @FunctionalInterface annotations Method Reference java.util.Stream package Backward Compatibility Binary compatibility && Behavioral compatibility - Excellent Source compatibility - Good
  • 5. Lambda is a syntax that produces instance of Functional Interface.
  • 6. Functional Interface is: Interface that has exactly one abstract method - Runnable ( run() ) - Comparator (compare() ) See @FunctionalInterface (java.lang.annotation) List of interface under java.util.function package You can define your own interface, of course.
  • 7.  Leap to functional language (Haskell, Erlang, JavaScript, Lisp, Scala, Ocaml, etc.)  Single-method interface (syntax sugar)  Provide a path to multicore (stream vs. parallel stream) -> see demo.  No more for loop (internal loop vs. external loop)
  • 8. In short … function is the 1st level Object /* * JavaScript can pass method as a parameter. */ var doSomething = function(name){ console.log(name + "is going to do something someday"); } function useSomething(func, param){ func(param); } Event handler
  • 9. (parameter) -> { // do something} ; // that’s it! Further simplify with “Type interface” - best guess @FunctionalInterface private interface HelloWorld{ public String hello(String name); } Old anonymous class HelloWorld hello = new HelloWorld() { @Override public String hello(String name) { return "Hello, " + name; } }; Ex 1) -> Get Simplified with Lambda (You don’t need to specify method name) (String name) -> { return “Hello “+name + “!!”; }; Ex 2) Remove String -> JVM best guess – type interface (name) -> { return “Hello “+name+”!!”; }; Ex 3) Remove return – type interface (name) -> { “Hello “+name+”!!”; }; Ex 4) Remove brackets for single implementation. (name) -> “Hello “+name+”!!”; Ex 5) Remove () if parameter is one name -> “Hello “+name+”!!”; (name -> “Hello “+name+”!!”;
  • 10.  Start with .stream(), chain with intermediate operators, end with terminal operator.  IntermediateOperator (filter, map, sorted, distinct, limit)  Terminal Operator (forEach, collect, reduce, iterator)
  • 11.  listOfSomething.stream() .filter( element -> element.age > 30) // .map( ) // not evaluated .sorted() // not evaluated .limit() // not evaluated …. .collect( Collectors.toList() );  Finally evaluate
  • 12. Sample Code (Run com.hidetomo.Java8StreamBench.main) https://github.com/mocchidesu/Java8sample.git Input: 100,000 last name from HSA Do: Filter: Last name start with ‘m’ Map: (Brace each name with [] bracket) Sort: Reverse order Dedupe Limit to top 2 results Loop 1000 times. Traditional Java7 For Loop approach vs. Sequential Lambda vs. Parallel Lambda. -> IntelliJ13
  • 13.  Java 8 is backward compatible in binary level  Lambda is not only a syntax sugar  It’s a new era of Java  Performance gain?Will be improved. Stay tuned.  When use? NOW
  • 14. Everything about Java 8 http://www.techempower.com/blog/2013/03/26/everything-about-java-8/ Oracle Compatibility Guide for JDK 8 http://www.oracle.com/technetwork/java/javase/8-compatibility-guide- 2156366.html Lambda Peek under the Hood by Brian Goetz - Java One 2013 http://www.slideshare.net/jaxlondon2012/lambda-a-peek-under-the-hood-brian- goetz 10 Example of Lambda Expressions and Streams in Java 8 http://javarevisited.blogspot.com/2014/02/10-example-of-lambda-expressions-in- java8.html