SlideShare a Scribd company logo
1 of 13
Download to read offline
functional programmingand
Java 8
Ender Aydın Orak
elron.co
“Every problem in computer science can be solved
by adding another level of indirection.”
- David Wheeler
Programming Paradigms
• Machine Code
• Procedural Languages
• Object Oriented Languages
• Functional Languages
• Domain Specific Languages
What is FP ?
In computer science, functional programming is a
programming paradigm—a style of building the structure and
elements of computer programs—that treats computation as
the evaluation of mathematical functions and avoids
changing-state and mutable data.
Origins
• Lambda Calculus (A.Church, 1930s)
• Combinatory Logic (H.Curry, 1930s)
• LISP (J.McCarthy, 1960s)
• ML (1970s)
• OCaml (1996)
• …
FP: Why Now ?
• Moore’s Law runs out (in terms of CPU speeds)
• Increasing need for;
• Concurrency & Parallelism
• Distributed Computing
• Scalability
Benefits of FP
• Concurrency/Parallelism without tears
• Succinct, concise, understandable programming model
• Different programming perspective
• Reusability, testability
• Becoming more accessible
Functional Languages
• Haskell *
• Clean *
• Lisp/Scheme
• ML/OCaml
• F#
• Erlang
• Java
• Scala
• C++ (11+)
• JavaScript
* Pure
Sample:
Imperative Approach
class Player { String name; int score; Player(..){..} }
void declareWinner(Player p) {
System.out.println(p.name + “ is the winner! ”);
}
void winner(Player p1, Player p2) { // Impure
if(p1.score > p2.score)
declareWinner(p1);
else
declareWinner(p2);
}
winner(new Player(“Ram”, 10), new Player(“John”, 20));
Sample:
Functional Core + Impure Layers
class Player { String name; int score; Player(..){..} }
void declareWinner(Player p) {
System.out.println(p.name + “ is the winner! ”);
}
Player maxScore(Player p1, Player p2) {
return p1.score > p2.score ? p1 : p2;
}
Player winner(Player p1, Player p2) {
declareWinner(maxScore(p1, p2));
}
winner(new Player(“Ram”, 10), new Player(“John”, 20));
Sample:
Reuse
List<Player> players = List(Player("Ram", 10),
Player("John", 15),
Player("Hari", 20),
Player("Krishna", 17));
System.out.println(players.stream().reduce(Play::maxScore));
Hands on examples
Ender Aydın Orak
elron.co
Done. (for now)
Ender Aydın Orak
elron.co

More Related Content

Viewers also liked

Design Patterns & JDK Examples
Design Patterns & JDK ExamplesDesign Patterns & JDK Examples
Design Patterns & JDK ExamplesEnder Aydin Orak
 
PATTERNS05 - Guidelines for Choosing a Design Pattern
PATTERNS05 - Guidelines for Choosing a Design PatternPATTERNS05 - Guidelines for Choosing a Design Pattern
PATTERNS05 - Guidelines for Choosing a Design PatternMichael Heron
 
Factory design pattern
Factory design patternFactory design pattern
Factory design patternFarhad Safarov
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - IntroductionMudasir Qazi
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternMudasir Qazi
 
Floor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye angaFloor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye angaSotonye anga
 
Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...
Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...
Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...Uğur Eskici
 
Rulesimple Hizmetlerimiz
Rulesimple HizmetlerimizRulesimple Hizmetlerimiz
Rulesimple HizmetlerimizCan Taner
 
Syllabus ref02
Syllabus ref02Syllabus ref02
Syllabus ref02SongTu
 
2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?
2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?
2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?James Coplien
 
Cooking an ontology-based spoken dialogue system
Cooking an ontology-based spoken dialogue systemCooking an ontology-based spoken dialogue system
Cooking an ontology-based spoken dialogue systemJoana Paulo Pardal
 
Selendroid in Action
Selendroid in ActionSelendroid in Action
Selendroid in ActionDominik Dary
 
IEEE Day 2013 Oracle Database 12c: new features for developers
IEEE Day 2013 Oracle Database 12c: new features for developersIEEE Day 2013 Oracle Database 12c: new features for developers
IEEE Day 2013 Oracle Database 12c: new features for developersRamin Orujov
 
The importance of internet usage as a marketing tool in the studies of sports...
The importance of internet usage as a marketing tool in the studies of sports...The importance of internet usage as a marketing tool in the studies of sports...
The importance of internet usage as a marketing tool in the studies of sports...Merve Aydogan
 
Great Pyramid of Giza and Golden Section Transform Preview
Great Pyramid of Giza and Golden Section Transform PreviewGreat Pyramid of Giza and Golden Section Transform Preview
Great Pyramid of Giza and Golden Section Transform PreviewJason Li
 

Viewers also liked (20)

Design Patterns & JDK Examples
Design Patterns & JDK ExamplesDesign Patterns & JDK Examples
Design Patterns & JDK Examples
 
SlideShare 101
SlideShare 101SlideShare 101
SlideShare 101
 
PATTERNS05 - Guidelines for Choosing a Design Pattern
PATTERNS05 - Guidelines for Choosing a Design PatternPATTERNS05 - Guidelines for Choosing a Design Pattern
PATTERNS05 - Guidelines for Choosing a Design Pattern
 
Factory design pattern
Factory design patternFactory design pattern
Factory design pattern
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Floor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye angaFloor plan for cashew factory by sotonye anga
Floor plan for cashew factory by sotonye anga
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...
Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...
Startup'tan E-ticaret Devi Olmak: SEO Altyapısını Oluştururken Google'ı Doğru...
 
Rulesimple Hizmetlerimiz
Rulesimple HizmetlerimizRulesimple Hizmetlerimiz
Rulesimple Hizmetlerimiz
 
Syllabus ref02
Syllabus ref02Syllabus ref02
Syllabus ref02
 
Introduction
IntroductionIntroduction
Introduction
 
Kullanıcı Deneyimi & Kullanılabilirlik
Kullanıcı Deneyimi & KullanılabilirlikKullanıcı Deneyimi & Kullanılabilirlik
Kullanıcı Deneyimi & Kullanılabilirlik
 
2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?
2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?
2013 Scrum Gathering Keynote: Buy or build — where did your agile come from?
 
Pruebas exploratorias
Pruebas exploratoriasPruebas exploratorias
Pruebas exploratorias
 
Cooking an ontology-based spoken dialogue system
Cooking an ontology-based spoken dialogue systemCooking an ontology-based spoken dialogue system
Cooking an ontology-based spoken dialogue system
 
Selendroid in Action
Selendroid in ActionSelendroid in Action
Selendroid in Action
 
IEEE Day 2013 Oracle Database 12c: new features for developers
IEEE Day 2013 Oracle Database 12c: new features for developersIEEE Day 2013 Oracle Database 12c: new features for developers
IEEE Day 2013 Oracle Database 12c: new features for developers
 
The importance of internet usage as a marketing tool in the studies of sports...
The importance of internet usage as a marketing tool in the studies of sports...The importance of internet usage as a marketing tool in the studies of sports...
The importance of internet usage as a marketing tool in the studies of sports...
 
Great Pyramid of Giza and Golden Section Transform Preview
Great Pyramid of Giza and Golden Section Transform PreviewGreat Pyramid of Giza and Golden Section Transform Preview
Great Pyramid of Giza and Golden Section Transform Preview
 

Similar to Functional Programming and Java8

Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...InfinIT - Innovationsnetværket for it
 
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...KRamasamy2
 
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...VAISHNAVI MADHAN
 
2. Evolution of the Major Programming Languages.pdf
2. Evolution of the Major Programming Languages.pdf2. Evolution of the Major Programming Languages.pdf
2. Evolution of the Major Programming Languages.pdfHILALJAMIRUDDINABDUL
 
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...Jose Quesada (hiring)
 
Designing Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache SparkDesigning Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache SparkDatabricks
 
The Challenges of Bringing Machine Learning to the Masses
The Challenges of Bringing Machine Learning to the MassesThe Challenges of Bringing Machine Learning to the Masses
The Challenges of Bringing Machine Learning to the MassesAlice Zheng
 
Imperative and-functional-programming
Imperative and-functional-programmingImperative and-functional-programming
Imperative and-functional-programmingrameses francia
 
Research article
Research article Research article
Research article RASHID ALI
 
Apache Arrow: Leveling Up the Analytics Stack
Apache Arrow: Leveling Up the Analytics StackApache Arrow: Leveling Up the Analytics Stack
Apache Arrow: Leveling Up the Analytics StackWes McKinney
 
Exploring metaprogramming using Ruby language
Exploring metaprogramming using Ruby languageExploring metaprogramming using Ruby language
Exploring metaprogramming using Ruby languageHarshal Hayatnagarkar
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"GlobalLogic Ukraine
 
Parallelization using open mp
Parallelization using open mpParallelization using open mp
Parallelization using open mpranjit banshpal
 

Similar to Functional Programming and Java8 (20)

Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
 
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
 
Paradigms
ParadigmsParadigms
Paradigms
 
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
Floating Point Operations , Memory Chip Organization , Serial Bus Architectur...
 
2. Evolution of the Major Programming Languages.pdf
2. Evolution of the Major Programming Languages.pdf2. Evolution of the Major Programming Languages.pdf
2. Evolution of the Major Programming Languages.pdf
 
Evolution of Programming Languages.pdf
Evolution of Programming Languages.pdfEvolution of Programming Languages.pdf
Evolution of Programming Languages.pdf
 
Evolution of Programming Languages.pdf
Evolution of Programming Languages.pdfEvolution of Programming Languages.pdf
Evolution of Programming Languages.pdf
 
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
A full Machine learning pipeline in Scikit-learn vs in scala-Spark: pros and ...
 
Evalution about programming language part 2
Evalution about programming language part 2Evalution about programming language part 2
Evalution about programming language part 2
 
Designing Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache SparkDesigning Distributed Machine Learning on Apache Spark
Designing Distributed Machine Learning on Apache Spark
 
The Challenges of Bringing Machine Learning to the Masses
The Challenges of Bringing Machine Learning to the MassesThe Challenges of Bringing Machine Learning to the Masses
The Challenges of Bringing Machine Learning to the Masses
 
Imperative and-functional-programming
Imperative and-functional-programmingImperative and-functional-programming
Imperative and-functional-programming
 
Research article
Research article Research article
Research article
 
Iwesep19.ppt
Iwesep19.pptIwesep19.ppt
Iwesep19.ppt
 
Hpc 3
Hpc 3Hpc 3
Hpc 3
 
Apache Arrow: Leveling Up the Analytics Stack
Apache Arrow: Leveling Up the Analytics StackApache Arrow: Leveling Up the Analytics Stack
Apache Arrow: Leveling Up the Analytics Stack
 
Exploring metaprogramming using Ruby language
Exploring metaprogramming using Ruby languageExploring metaprogramming using Ruby language
Exploring metaprogramming using Ruby language
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Parallelization using open mp
Parallelization using open mpParallelization using open mp
Parallelization using open mp
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 

Functional Programming and Java8

  • 2. “Every problem in computer science can be solved by adding another level of indirection.” - David Wheeler
  • 3. Programming Paradigms • Machine Code • Procedural Languages • Object Oriented Languages • Functional Languages • Domain Specific Languages
  • 4. What is FP ? In computer science, functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.
  • 5. Origins • Lambda Calculus (A.Church, 1930s) • Combinatory Logic (H.Curry, 1930s) • LISP (J.McCarthy, 1960s) • ML (1970s) • OCaml (1996) • …
  • 6. FP: Why Now ? • Moore’s Law runs out (in terms of CPU speeds) • Increasing need for; • Concurrency & Parallelism • Distributed Computing • Scalability
  • 7. Benefits of FP • Concurrency/Parallelism without tears • Succinct, concise, understandable programming model • Different programming perspective • Reusability, testability • Becoming more accessible
  • 8. Functional Languages • Haskell * • Clean * • Lisp/Scheme • ML/OCaml • F# • Erlang • Java • Scala • C++ (11+) • JavaScript * Pure
  • 9. Sample: Imperative Approach class Player { String name; int score; Player(..){..} } void declareWinner(Player p) { System.out.println(p.name + “ is the winner! ”); } void winner(Player p1, Player p2) { // Impure if(p1.score > p2.score) declareWinner(p1); else declareWinner(p2); } winner(new Player(“Ram”, 10), new Player(“John”, 20));
  • 10. Sample: Functional Core + Impure Layers class Player { String name; int score; Player(..){..} } void declareWinner(Player p) { System.out.println(p.name + “ is the winner! ”); } Player maxScore(Player p1, Player p2) { return p1.score > p2.score ? p1 : p2; } Player winner(Player p1, Player p2) { declareWinner(maxScore(p1, p2)); } winner(new Player(“Ram”, 10), new Player(“John”, 20));
  • 11. Sample: Reuse List<Player> players = List(Player("Ram", 10), Player("John", 15), Player("Hari", 20), Player("Krishna", 17)); System.out.println(players.stream().reduce(Play::maxScore));
  • 12. Hands on examples Ender Aydın Orak elron.co
  • 13. Done. (for now) Ender Aydın Orak elron.co