SlideShare a Scribd company logo
FUNCTIONAL
PROGRAMMING (FP)
Prateek Jain
(prateekjainaa@gmail.com)
Is OOPs, oops?
• NullPointer problems
• Inheritance issues
• “new” operator issues
Is OOPs, oops?
• NullPointer problems
• Inheritance issues
• “new” operator issues
Is OOPs, oops?
• NullPointer problems
• Inheritance issues
• “new” operator issues
Why FP?
• I Have to Be Good at Writing Concurrent Programs
• Most Programs Are Just Data Management Problems

(why ORM?)
• More Modular
• I Have to Work Faster and Faster
• Code is written once, but read many times
Why FP?
• I Have to Be Good at Writing Concurrent Programs
• Most Programs Are Just Data Management Problems

(why ORM?)
• More Modular
• I Have to Work Faster and Faster
• Code is written once, but read many times
Why FP?
• I Have to Be Good at Writing Concurrent Programs
• Most Programs Are Just Data Management Problems

(why ORM?)
• More Modular
• I Have to Work Faster and Faster
• Code is written once, but read many times
Why FP?
• I Have to Be Good at Writing Concurrent Programs
• Most Programs Are Just Data Management Problems

(why ORM?)
• More Modular
• I Have to Work Faster and Faster
• Code is written once, but read many times
Why FP?
• I Have to Be Good at Writing Concurrent Programs
• Most Programs Are Just Data Management Problems

(why ORM?)
• More Modular
• I Have to Work Faster and Faster
• Code is written once, but read many times
What is FP?
• RECURSION
• ABSTRACTION
• HIGHER ORDER FUNCTIONS
• IMPACT MOST PROGRAMMING LANGUAGES
PROGRAMS AS FUNCTIONS
• PROGRAM = DESCRIPTION OF A SPECIFIC

COMPUTATION
• Y = F(X)
• F: X ->Y

• MATHEMATICS
• VARIABLES = ACTUAL VALUES
• NO MEMEORY ALLOCATION CONCEPT
• IMPERATIVE LANGUAGE
• VARIABLES = MEMORY LOCATIONS + VALUES
PROGRAMS AS FUNCTIONS
• NO LOOPS BUT RECURSION
• NO VARIABLE EXCEPT AS A NAME FOR A VALUE
• NO ASSIGNMENT OPERATION (x = x+1 ,

MEANINGLESS)
• ONLY CONSTANTS, PARAMETERS AND VALUES
imperative

functional

EXAMPLE
Void GCD (int u, int v, int* x) {
Int y, t, z;
z = u;
y = v;
While (y!=0) {
…
…
}
…
}

Void GCD(int u, int v) {
if(v==0)
return u;
else
return GCD(v, u%v);
}
NO VARIABLES, NO ASSIGNMENT
• No notion of the internal state of a function.
• Referential Transparency.
• Value Semantics.
FP vs Others
• Recursions instead of loops
• Pattern matching instead of “if”
• Pattern matching instead of state machines
• Information transformation instead of sequence of tasks
FP vs Others
• Persistent data structures
• Powerful concurrency constructs : Actors
• Software transactional memory
• Avoid “Null”
What it really means?
• Immutability is good
What it really means?
• Immutability is good
• No bugs (due to nasty side effects)
What it really means?
• Immutability is good
• No bugs (due to nasty side effects)
• Benefits from concurrency
What it really means?
• Immutability is good
• No bugs (due to nasty side effects)
• Benefits from concurrency
• No more messy loops
What it really means?
• Immutability is good
• No bugs (due to nasty side effects)
• Benefits from concurrency
• No more messy loops
• Lazy evaluation
FP Examples
• Erlang, Haskell, Clojure
• F#
• JAVA 8 (prject lambda), Scala, Groovy
• R, Mathematica etc. (specialized languages)
CAUTION CAUTION
Maintaining, Maintainability
• Use functional style wheretill it makes the intent more

readable.
Sort(extract(filter(having(on(Pet.class).getSpecies(), is(Dog)), pets,
on(Pet.class).getName()), on(String.class));

List<Pet> dogs =
filter(having(on(Pet.class).getSpecies(), is(Dog)), pets);
List<String> dogNames = extract(dogs, on(Pet.class).getName());
List<String> sortedDogNames = sort(dogNames, on(String.class));
Maintaining, Maintainability

• One liners are always not better.

Convert(pets, new Convert<Pet, VetStay>() {
@override public VetStay converter(Pet pet) {
return new VetStay(pet, new Date(), “….”);
}});

Private Converter<Pet, VetStay> toVetStay () {
@override public VetStay converter(Pet pet) {
return new VetStay(pet, new Date(), “….”);
}});
Convert(pets, toVetStay());
FP - Adoption
• Facebook (tchat), Linkedin uses Erlang
• Twitter, UBS, Credit Suisse uses Scala
QUESTIONS?
Questions?
FEEDBACK
Feedback

More Related Content

Viewers also liked

Interactive Scientific Image Analysis using Spark
Interactive Scientific Image Analysis using SparkInteractive Scientific Image Analysis using Spark
Interactive Scientific Image Analysis using Spark
Kevin Mader
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming Fundamentals
Shahriar Hyder
 
Functional programming
Functional programmingFunctional programming
Functional programming
edusmildo
 
Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey
Hakka Labs
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis Atencio
Luis Atencio
 
The Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScriptThe Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScript
Norman Richards
 
Machine Learning with Apache Mahout
Machine Learning with Apache MahoutMachine Learning with Apache Mahout
Machine Learning with Apache Mahout
Daniel Glauser
 
Modeling with Hadoop kdd2011
Modeling with Hadoop kdd2011Modeling with Hadoop kdd2011
Modeling with Hadoop kdd2011
Milind Bhandarkar
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
Prashant Kalkar
 
Predictive Analytics Project in Automotive Industry
Predictive Analytics Project in Automotive IndustryPredictive Analytics Project in Automotive Industry
Predictive Analytics Project in Automotive Industry
Matouš Havlena
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScriptIntroduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
tmont
 

Viewers also liked (11)

Interactive Scientific Image Analysis using Spark
Interactive Scientific Image Analysis using SparkInteractive Scientific Image Analysis using Spark
Interactive Scientific Image Analysis using Spark
 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming Fundamentals
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey Lambda Calculus by Dustin Mulcahey
Lambda Calculus by Dustin Mulcahey
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis Atencio
 
The Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScriptThe Lambda Calculus and The JavaScript
The Lambda Calculus and The JavaScript
 
Machine Learning with Apache Mahout
Machine Learning with Apache MahoutMachine Learning with Apache Mahout
Machine Learning with Apache Mahout
 
Modeling with Hadoop kdd2011
Modeling with Hadoop kdd2011Modeling with Hadoop kdd2011
Modeling with Hadoop kdd2011
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
Predictive Analytics Project in Automotive Industry
Predictive Analytics Project in Automotive IndustryPredictive Analytics Project in Automotive Industry
Predictive Analytics Project in Automotive Industry
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScriptIntroduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
 

Similar to Functional programming

Introduction to Functional Programming
Introduction to Functional ProgrammingIntroduction to Functional Programming
Introduction to Functional Programming
Dave Fancher
 
A (very brief) into to Functional Programming
A (very brief) into to Functional ProgrammingA (very brief) into to Functional Programming
A (very brief) into to Functional Programming
Brooklyn Zelenka
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)
Omar Abdelhafith
 
Logic programming in python
Logic programming in pythonLogic programming in python
Logic programming in python
Pierre Carbonnelle
 
Oop is not Dead
Oop is not DeadOop is not Dead
Oop is not Dead
Hernan Wilkinson
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
Clay Helberg
 
Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...
Danny Mulligan
 
Craft of coding
Craft of codingCraft of coding
Craft of coding
Justin Weinberg
 
Fp for the oo programmer
Fp for the oo programmerFp for the oo programmer
Fp for the oo programmer
Shawn Button
 
Introduction to functional programming with JavaScript
Introduction to functional programming with JavaScriptIntroduction to functional programming with JavaScript
Introduction to functional programming with JavaScript
Farzaneh Orak
 
Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
Ron Barabash
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented Programmers
Diego Freniche Brito
 
Become Jythonic in FDMEE (KSCOPE15)
Become Jythonic in FDMEE (KSCOPE15)Become Jythonic in FDMEE (KSCOPE15)
Become Jythonic in FDMEE (KSCOPE15)
Francisco Amores
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devops
Rob Kinyon
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
jamesmarken1
 
Babysitting your orm essenmacher, adam
Babysitting your orm   essenmacher, adamBabysitting your orm   essenmacher, adam
Babysitting your orm essenmacher, adam
Adam Essenmacher
 
Php
PhpPhp
Php
PhpPhp
Php
PhpPhp
Functional Programming #FTW
Functional Programming #FTWFunctional Programming #FTW
Functional Programming #FTW
Adriano Bonat
 

Similar to Functional programming (20)

Introduction to Functional Programming
Introduction to Functional ProgrammingIntroduction to Functional Programming
Introduction to Functional Programming
 
A (very brief) into to Functional Programming
A (very brief) into to Functional ProgrammingA (very brief) into to Functional Programming
A (very brief) into to Functional Programming
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)
 
Logic programming in python
Logic programming in pythonLogic programming in python
Logic programming in python
 
Oop is not Dead
Oop is not DeadOop is not Dead
Oop is not Dead
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
 
Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...
 
Craft of coding
Craft of codingCraft of coding
Craft of coding
 
Fp for the oo programmer
Fp for the oo programmerFp for the oo programmer
Fp for the oo programmer
 
Introduction to functional programming with JavaScript
Introduction to functional programming with JavaScriptIntroduction to functional programming with JavaScript
Introduction to functional programming with JavaScript
 
Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented Programmers
 
Become Jythonic in FDMEE (KSCOPE15)
Become Jythonic in FDMEE (KSCOPE15)Become Jythonic in FDMEE (KSCOPE15)
Become Jythonic in FDMEE (KSCOPE15)
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devops
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
 
Babysitting your orm essenmacher, adam
Babysitting your orm   essenmacher, adamBabysitting your orm   essenmacher, adam
Babysitting your orm essenmacher, adam
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Functional Programming #FTW
Functional Programming #FTWFunctional Programming #FTW
Functional Programming #FTW
 

Recently uploaded

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 

Recently uploaded (20)

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 

Functional programming

  • 2. Is OOPs, oops? • NullPointer problems • Inheritance issues • “new” operator issues
  • 3. Is OOPs, oops? • NullPointer problems • Inheritance issues • “new” operator issues
  • 4. Is OOPs, oops? • NullPointer problems • Inheritance issues • “new” operator issues
  • 5. Why FP? • I Have to Be Good at Writing Concurrent Programs • Most Programs Are Just Data Management Problems (why ORM?) • More Modular • I Have to Work Faster and Faster • Code is written once, but read many times
  • 6. Why FP? • I Have to Be Good at Writing Concurrent Programs • Most Programs Are Just Data Management Problems (why ORM?) • More Modular • I Have to Work Faster and Faster • Code is written once, but read many times
  • 7. Why FP? • I Have to Be Good at Writing Concurrent Programs • Most Programs Are Just Data Management Problems (why ORM?) • More Modular • I Have to Work Faster and Faster • Code is written once, but read many times
  • 8. Why FP? • I Have to Be Good at Writing Concurrent Programs • Most Programs Are Just Data Management Problems (why ORM?) • More Modular • I Have to Work Faster and Faster • Code is written once, but read many times
  • 9. Why FP? • I Have to Be Good at Writing Concurrent Programs • Most Programs Are Just Data Management Problems (why ORM?) • More Modular • I Have to Work Faster and Faster • Code is written once, but read many times
  • 10. What is FP? • RECURSION • ABSTRACTION • HIGHER ORDER FUNCTIONS • IMPACT MOST PROGRAMMING LANGUAGES
  • 11. PROGRAMS AS FUNCTIONS • PROGRAM = DESCRIPTION OF A SPECIFIC COMPUTATION • Y = F(X) • F: X ->Y • MATHEMATICS • VARIABLES = ACTUAL VALUES • NO MEMEORY ALLOCATION CONCEPT • IMPERATIVE LANGUAGE • VARIABLES = MEMORY LOCATIONS + VALUES
  • 12. PROGRAMS AS FUNCTIONS • NO LOOPS BUT RECURSION • NO VARIABLE EXCEPT AS A NAME FOR A VALUE • NO ASSIGNMENT OPERATION (x = x+1 , MEANINGLESS) • ONLY CONSTANTS, PARAMETERS AND VALUES
  • 13. imperative functional EXAMPLE Void GCD (int u, int v, int* x) { Int y, t, z; z = u; y = v; While (y!=0) { … … } … } Void GCD(int u, int v) { if(v==0) return u; else return GCD(v, u%v); }
  • 14. NO VARIABLES, NO ASSIGNMENT • No notion of the internal state of a function. • Referential Transparency. • Value Semantics.
  • 15. FP vs Others • Recursions instead of loops • Pattern matching instead of “if” • Pattern matching instead of state machines • Information transformation instead of sequence of tasks
  • 16. FP vs Others • Persistent data structures • Powerful concurrency constructs : Actors • Software transactional memory • Avoid “Null”
  • 17. What it really means? • Immutability is good
  • 18. What it really means? • Immutability is good • No bugs (due to nasty side effects)
  • 19. What it really means? • Immutability is good • No bugs (due to nasty side effects) • Benefits from concurrency
  • 20. What it really means? • Immutability is good • No bugs (due to nasty side effects) • Benefits from concurrency • No more messy loops
  • 21. What it really means? • Immutability is good • No bugs (due to nasty side effects) • Benefits from concurrency • No more messy loops • Lazy evaluation
  • 22. FP Examples • Erlang, Haskell, Clojure • F# • JAVA 8 (prject lambda), Scala, Groovy • R, Mathematica etc. (specialized languages)
  • 24. Maintaining, Maintainability • Use functional style wheretill it makes the intent more readable. Sort(extract(filter(having(on(Pet.class).getSpecies(), is(Dog)), pets, on(Pet.class).getName()), on(String.class)); List<Pet> dogs = filter(having(on(Pet.class).getSpecies(), is(Dog)), pets); List<String> dogNames = extract(dogs, on(Pet.class).getName()); List<String> sortedDogNames = sort(dogNames, on(String.class));
  • 25. Maintaining, Maintainability • One liners are always not better. Convert(pets, new Convert<Pet, VetStay>() { @override public VetStay converter(Pet pet) { return new VetStay(pet, new Date(), “….”); }}); Private Converter<Pet, VetStay> toVetStay () { @override public VetStay converter(Pet pet) { return new VetStay(pet, new Date(), “….”); }}); Convert(pets, toVetStay());
  • 26. FP - Adoption • Facebook (tchat), Linkedin uses Erlang • Twitter, UBS, Credit Suisse uses Scala