SlideShare una empresa de Scribd logo
1 de 13
Functional Programming
for OO programmers

1 July 2013
Martin Škurla
Agenda
•Functional programming (what and why)
•The basic concepts of functional programming:
• Immutability
• Memoization
• Recursion, Tail recursion
• Higher-order functions
• Currying and Partial application

• Pattern matching

2 | Functional Programming | 1 July 2013
Functional programming (what and why)
•What:
• no strict definition as opposed to OOP
• programming without mutable
variables, assignments, conditions, loops and other imperative
control structures
• functions should have no side-effects
• “Functions as primary building blocks” (first-class functions)
•Why:
• simpler reasoning principles (data abstraction, concurrency)
• better modularity
• much easier to exploit parallelism for multicore and cloud
computing
3 | Functional Programming | 1 July 2013
Immutability
•“No notion of mutation and variables”
• variable as memory cell
• rather variable bindings
•Consequences:
• different programming style with collections (Cons Nil lists)
• usually more complicated collection implementation
• knowledge of implementation details of the underlying collection is
essential
• sometimes even necessary to refactor the code/algorithm when
switching to different collection implementation
•Datomic

• immutable internal database model
4 | Functional Programming | 1 July 2013
Memoization
•“Function scope caching”
•Purely mathematical definition of a function
•Implementation details:
• hashmap-like data structure (Scala)
• not changing the value, but rather a reference (Racket, Clojure)
•Consequences:
• can lead to exponentially faster programs for recursive functions

• memory tradeoff

5 | Functional Programming | 1 July 2013
Recursion, tail recursion
•“When a function calls even indirectly itself”
•Call stacks and stack frames
•

java.lang.StackOverflowError

•“If a function calls itself as its last action, the function’s stack frame
can be reused”
•Consequences:
• JVM does not directly support tail-call optimizations
• Scala & @tailrec annotation, Clojure & recur form
• algorithms to convert recursive calls to tail recursive calls (e.g.
accumulation)
•Scala example

6 | Functional Programming | 1 July 2013
Higher-order functions
•“Passing or returning code/function as argument”
•Functions as first-class values
•OOP comparison:
• pretty much every OOP developer is doing “higher-order”
programming
• design patterns: Strategy, Observer, ...
• practical reasons because of JVM design
•Scala example

7 | Functional Programming | 1 July 2013
Currying and Partial application
•“The act of transforming a function of several arguments into a chain
of functions of one argument that will yield the same result when called
in sequence with the same arguments”
•f(x,y,z) = g(x)(y)(z)
•Consequences:
• functions because of currying can be partially applied
• language runtimes can be easier (Haskell)
•Scala example

8 | Functional Programming | 1 July 2013
Pattern matching
•“Decomposing data structures and ADTs”
• Abstract Data Types (tuples)
• data structures (Cons Nil lists)
•Nothing to do with switch statement
• constant-time runtime lookup over constants
•Consequences:
• no missing cases

• no exceptions for wrong variants
•SML example

9 | Functional Programming | 1 July 2013
Wrap up
•Functional programming is not only, but also about:
• Immutability
• Memoization
• Recursion, Tail recursion
• Higher-order functions
• Currying and Partial application
• Pattern matching

10 | Functional Programming | 1 July 2013
Functional programming is much more stuff…
•Influential people:
• Alonso Church
• Haskell Curry
• John McCarthy
•More advanced concepts:
• composition, functors, monads, ...
•Tons of languages:

• Clojure, F#, Lisp, OCaml, Python, Racket, Scala, Scheme, SML

11 | Functional Programming | 1 July 2013
Thank you for attention
Functional programming rocks
Disclaimer
CONFLICTS OF INTEREST BARCLAYS IS A FULL SERVICE INVESTMENT BANK. In the normal course of offering investment banking products and services to clients.
Barclays may act in several capacities (including issuer, market maker, underwriter, distributor, index sponsor, swap counterparty and calculation agent) simultaneously with
respect to a product, giving rise to potential conflicts of interest which may impact the performance of a product.
NOT RESEARCH This document is from a Barclays Trading and/or Distribution desk and is not a product of the Barclays Research department. Any views expressed may
differ from those of Barclays Research.
BARCLAYS POSITIONS Barclays, its affiliates and associated personnel may at any time acquire, hold or dispose of long or short positions (including hedging and trading
positions) which may impact the performance of a product.
FOR INFORMATION ONLY
NOT BINDING.

THIS DOCUMENT IS PROVIDED FOR INFORMATION PURPOSES ONLY AND IT IS SUBJECT TO CHANGE. IT IS INDICATIVE ONLY AND IS

NO OFFER Barclays is not offering to sell or seeking offers to buy any product or enter into any transaction. Any transaction requires Barclays’ subsequent formal agreement
which will be subject to internal approvals and binding transaction documents.
NO LIABILITY Barclays is not responsible for the use made of this document other than the purpose for which it is intended, except to the extent this would be prohibited by
law or regulation.
NO ADVICE OBTAIN INDEPENDENT PROFESSIONAL ADVICE BEFORE INVESTING OR TRANSACTING. Barclays is not an advisor and will not provide any advice
relating to a product. Before making an investment decision, investors should ensure they have sufficient information to ascertain the legal, financial, tax and regulatory
consequences of an investment to enable them to make an informed investment decision.

THIRD PARTY INFORMATION

Barclays is not responsible for information stated to be obtained or derived from third party sources or statistical services.

PAST & SIMULATED PAST PERFORMANCE

Any past or simulated past performance (including back-testing) contained herein is no indication as to future performance.

OPINIONS SUBJECT TO CHANGE All opinions and estimates are given as of the date hereof and are subject to change. Barclays is not obliged to inform investors of any
change to such opinions or estimates.
NOT FOR RETAIL

This document is being directed at persons who are professionals and is not intended for retail customer use.

IMPORTANT DISCLOSURES
are unable to access.

For important regional disclosures you must read, click on the link relevant to your region. Please contact your Barclays representative if you

EMEA EMEA Disclosures APAC APAC Disclosures U.S. US Disclosures
IRS CIRCULAR 230 DISCLOSURE: Barclays does not provide tax advice. Please note that (i) any discussion of US tax matters contained in this communication (including any
attachments) cannot be used by you for the purpose of avoiding tax penalties; (ii) this communication was written to support the promotion or marketing of the matters addressed
herein; and (iii) you should seek advice based on your particular circumstances from an independent tax advisor.
CONFIDENTIAL

This document is confidential and no part of it may be reproduced, distributed or transmitted without the prior written permission of Barclays.

ABOUT BARCLAYS Barclays Bank PLC offers premier investment banking products and services to its clients through Barclays Bank PLC. Barclays Bank PLC is authorised
by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority and is a member of the London Stock Exchange.
Barclays Bank PLC is registered in England No. 1026167 with its registered office at 1 Churchill Place, London E14 5HP.

COPYRIGHT

© Copyright Barclays Bank PLC, 2014 (all rights reserved).

13 | Functional Programming | 1 July 2013

Más contenido relacionado

Similar a Functional programming

Informix REST API Tutorial
Informix REST API TutorialInformix REST API Tutorial
Informix REST API TutorialBrian Hughes
 
Twin Cities Salesforce.com Developer User Group Presentation April 2012
Twin Cities Salesforce.com Developer User Group Presentation April 2012Twin Cities Salesforce.com Developer User Group Presentation April 2012
Twin Cities Salesforce.com Developer User Group Presentation April 2012Developer Force - Force.com Community
 
Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719
Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719
Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719BingWang77
 
ODA Right to use program - Optimalizace IT investice
ODA Right to use program - Optimalizace IT investiceODA Right to use program - Optimalizace IT investice
ODA Right to use program - Optimalizace IT investiceMarketingArrowECS_CZ
 
Oracle Fusion Payments
Oracle Fusion Payments Oracle Fusion Payments
Oracle Fusion Payments Berry Clemens
 
Oracle purchasing cloud ds
Oracle purchasing cloud dsOracle purchasing cloud ds
Oracle purchasing cloud dsmshabrawi
 
Oracle Fusion Applications Accounts Payables
Oracle Fusion Applications Accounts PayablesOracle Fusion Applications Accounts Payables
Oracle Fusion Applications Accounts PayablesBerry Clemens
 
Oracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer IntroductionOracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer IntroductionJeffrey T. Pollock
 
Getting started-oracle-analytics-cloud
Getting started-oracle-analytics-cloudGetting started-oracle-analytics-cloud
Getting started-oracle-analytics-cloudapnambiar
 
#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...
#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...
#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...Reedy Feggins Jr
 
ECAD 231 Functional Overview
ECAD 231 Functional OverviewECAD 231 Functional Overview
ECAD 231 Functional OverviewZero Wait-State
 
The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...
The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...
The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...Adrian Jones
 
Disciplined agile business analysis
Disciplined agile business analysisDisciplined agile business analysis
Disciplined agile business analysisScott W. Ambler
 
Oracle Fusion Financials Overview
Oracle Fusion Financials OverviewOracle Fusion Financials Overview
Oracle Fusion Financials OverviewBerry Clemens
 
Best Practices for Team Development in a Single Org
Best Practices for Team Development in a Single OrgBest Practices for Team Development in a Single Org
Best Practices for Team Development in a Single OrgSalesforce Developers
 
Polymorphic Table Functions: The Best Way to Integrate SQL and Apache Spark
Polymorphic Table Functions: The Best Way to Integrate SQL and Apache SparkPolymorphic Table Functions: The Best Way to Integrate SQL and Apache Spark
Polymorphic Table Functions: The Best Way to Integrate SQL and Apache SparkDatabricks
 

Similar a Functional programming (20)

Pandoc
PandocPandoc
Pandoc
 
Informix REST API Tutorial
Informix REST API TutorialInformix REST API Tutorial
Informix REST API Tutorial
 
Twin Cities Salesforce.com Developer User Group Presentation April 2012
Twin Cities Salesforce.com Developer User Group Presentation April 2012Twin Cities Salesforce.com Developer User Group Presentation April 2012
Twin Cities Salesforce.com Developer User Group Presentation April 2012
 
Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719
Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719
Apex Enterprise Patterns Galore - Boston, MA dev group meeting 062719
 
Orchestration, the conductor's score
Orchestration, the conductor's scoreOrchestration, the conductor's score
Orchestration, the conductor's score
 
ODA Right to use program - Optimalizace IT investice
ODA Right to use program - Optimalizace IT investiceODA Right to use program - Optimalizace IT investice
ODA Right to use program - Optimalizace IT investice
 
Oracle Fusion Payments
Oracle Fusion Payments Oracle Fusion Payments
Oracle Fusion Payments
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Oracle purchasing cloud ds
Oracle purchasing cloud dsOracle purchasing cloud ds
Oracle purchasing cloud ds
 
Oracle Fusion Applications Accounts Payables
Oracle Fusion Applications Accounts PayablesOracle Fusion Applications Accounts Payables
Oracle Fusion Applications Accounts Payables
 
Oracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer IntroductionOracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer Introduction
 
Getting started-oracle-analytics-cloud
Getting started-oracle-analytics-cloudGetting started-oracle-analytics-cloud
Getting started-oracle-analytics-cloud
 
#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...
#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...
#IBMInterConnect - DCB-3094 Scaling Agile - Launching an Agile Release Train ...
 
ECAD 231 Functional Overview
ECAD 231 Functional OverviewECAD 231 Functional Overview
ECAD 231 Functional Overview
 
The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...
The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...
The Agile Drupalist - Methodologies & Techniques for Running Effective Drupal...
 
Disciplined agile business analysis
Disciplined agile business analysisDisciplined agile business analysis
Disciplined agile business analysis
 
Oracle Fusion Financials Overview
Oracle Fusion Financials OverviewOracle Fusion Financials Overview
Oracle Fusion Financials Overview
 
Best Practices for Team Development in a Single Org
Best Practices for Team Development in a Single OrgBest Practices for Team Development in a Single Org
Best Practices for Team Development in a Single Org
 
Polymorphic Table Functions: The Best Way to Integrate SQL and Apache Spark
Polymorphic Table Functions: The Best Way to Integrate SQL and Apache SparkPolymorphic Table Functions: The Best Way to Integrate SQL and Apache Spark
Polymorphic Table Functions: The Best Way to Integrate SQL and Apache Spark
 
Security Boundaries in Apex
Security Boundaries in ApexSecurity Boundaries in Apex
Security Boundaries in Apex
 

Más de Martin Skurla

2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdfMartin Skurla
 
2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdf2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdfMartin Skurla
 
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdfMartin Skurla
 
Exploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical DilemmasExploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical DilemmasMartin Skurla
 
Interpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis PsychotherapyInterpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis PsychotherapyMartin Skurla
 
ESET 3 internship protocol
ESET 3 internship protocolESET 3 internship protocol
ESET 3 internship protocolMartin Skurla
 
Mastering Redecision Therapy
Mastering Redecision TherapyMastering Redecision Therapy
Mastering Redecision TherapyMartin Skurla
 
The Vital Skill of Clinical Assessment
The Vital Skill of Clinical AssessmentThe Vital Skill of Clinical Assessment
The Vital Skill of Clinical AssessmentMartin Skurla
 
Psychotherapy from the clients perspective
Psychotherapy from the clients perspectivePsychotherapy from the clients perspective
Psychotherapy from the clients perspectiveMartin Skurla
 
There's No Place Like Home
There's No Place Like HomeThere's No Place Like Home
There's No Place Like HomeMartin Skurla
 
Advanced Counselling Skills
Advanced Counselling SkillsAdvanced Counselling Skills
Advanced Counselling SkillsMartin Skurla
 
CATA conference 2023.pdf
CATA conference 2023.pdfCATA conference 2023.pdf
CATA conference 2023.pdfMartin Skurla
 
UKATA Conference 2023
UKATA Conference 2023UKATA Conference 2023
UKATA Conference 2023Martin Skurla
 
Applied TA in clinical practice
Applied TA in clinical practiceApplied TA in clinical practice
Applied TA in clinical practiceMartin Skurla
 
Intensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cardsIntensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cardsMartin Skurla
 
Personality Focused Treatment
Personality Focused TreatmentPersonality Focused Treatment
Personality Focused TreatmentMartin Skurla
 
Advanced training in Transanctional analysis
Advanced training in Transanctional analysisAdvanced training in Transanctional analysis
Advanced training in Transanctional analysisMartin Skurla
 
Magdalena internship protocol
Magdalena internship protocolMagdalena internship protocol
Magdalena internship protocolMartin Skurla
 
PPP internship protocol
PPP internship protocolPPP internship protocol
PPP internship protocolMartin Skurla
 

Más de Martin Skurla (20)

2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
2024-03-07 - Berne Institute - Neurodiversity Awareness Training.pdf
 
2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdf2024-03-03 - Chairwork - Beyond the Basics.pdf
2024-03-03 - Chairwork - Beyond the Basics.pdf
 
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
2024-02-20 - Berne Institute - Mental Health Familiarisation.pdf
 
Exploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical DilemmasExploring Relational Practice Through Clinical Dilemmas
Exploring Relational Practice Through Clinical Dilemmas
 
Interpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis PsychotherapyInterpretive Dynamic Transactional Analysis Psychotherapy
Interpretive Dynamic Transactional Analysis Psychotherapy
 
ESET 3 internship protocol
ESET 3 internship protocolESET 3 internship protocol
ESET 3 internship protocol
 
Mastering Redecision Therapy
Mastering Redecision TherapyMastering Redecision Therapy
Mastering Redecision Therapy
 
Life Script
Life ScriptLife Script
Life Script
 
The Vital Skill of Clinical Assessment
The Vital Skill of Clinical AssessmentThe Vital Skill of Clinical Assessment
The Vital Skill of Clinical Assessment
 
Psychotherapy from the clients perspective
Psychotherapy from the clients perspectivePsychotherapy from the clients perspective
Psychotherapy from the clients perspective
 
There's No Place Like Home
There's No Place Like HomeThere's No Place Like Home
There's No Place Like Home
 
Advanced Counselling Skills
Advanced Counselling SkillsAdvanced Counselling Skills
Advanced Counselling Skills
 
CATA conference 2023.pdf
CATA conference 2023.pdfCATA conference 2023.pdf
CATA conference 2023.pdf
 
UKATA Conference 2023
UKATA Conference 2023UKATA Conference 2023
UKATA Conference 2023
 
Applied TA in clinical practice
Applied TA in clinical practiceApplied TA in clinical practice
Applied TA in clinical practice
 
Intensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cardsIntensive course - Working with therapeutic cards
Intensive course - Working with therapeutic cards
 
Personality Focused Treatment
Personality Focused TreatmentPersonality Focused Treatment
Personality Focused Treatment
 
Advanced training in Transanctional analysis
Advanced training in Transanctional analysisAdvanced training in Transanctional analysis
Advanced training in Transanctional analysis
 
Magdalena internship protocol
Magdalena internship protocolMagdalena internship protocol
Magdalena internship protocol
 
PPP internship protocol
PPP internship protocolPPP internship protocol
PPP internship protocol
 

Último

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
🐬 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
 
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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 

Último (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
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...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 

Functional programming

  • 1. Functional Programming for OO programmers 1 July 2013 Martin Škurla
  • 2. Agenda •Functional programming (what and why) •The basic concepts of functional programming: • Immutability • Memoization • Recursion, Tail recursion • Higher-order functions • Currying and Partial application • Pattern matching 2 | Functional Programming | 1 July 2013
  • 3. Functional programming (what and why) •What: • no strict definition as opposed to OOP • programming without mutable variables, assignments, conditions, loops and other imperative control structures • functions should have no side-effects • “Functions as primary building blocks” (first-class functions) •Why: • simpler reasoning principles (data abstraction, concurrency) • better modularity • much easier to exploit parallelism for multicore and cloud computing 3 | Functional Programming | 1 July 2013
  • 4. Immutability •“No notion of mutation and variables” • variable as memory cell • rather variable bindings •Consequences: • different programming style with collections (Cons Nil lists) • usually more complicated collection implementation • knowledge of implementation details of the underlying collection is essential • sometimes even necessary to refactor the code/algorithm when switching to different collection implementation •Datomic • immutable internal database model 4 | Functional Programming | 1 July 2013
  • 5. Memoization •“Function scope caching” •Purely mathematical definition of a function •Implementation details: • hashmap-like data structure (Scala) • not changing the value, but rather a reference (Racket, Clojure) •Consequences: • can lead to exponentially faster programs for recursive functions • memory tradeoff 5 | Functional Programming | 1 July 2013
  • 6. Recursion, tail recursion •“When a function calls even indirectly itself” •Call stacks and stack frames • java.lang.StackOverflowError •“If a function calls itself as its last action, the function’s stack frame can be reused” •Consequences: • JVM does not directly support tail-call optimizations • Scala & @tailrec annotation, Clojure & recur form • algorithms to convert recursive calls to tail recursive calls (e.g. accumulation) •Scala example 6 | Functional Programming | 1 July 2013
  • 7. Higher-order functions •“Passing or returning code/function as argument” •Functions as first-class values •OOP comparison: • pretty much every OOP developer is doing “higher-order” programming • design patterns: Strategy, Observer, ... • practical reasons because of JVM design •Scala example 7 | Functional Programming | 1 July 2013
  • 8. Currying and Partial application •“The act of transforming a function of several arguments into a chain of functions of one argument that will yield the same result when called in sequence with the same arguments” •f(x,y,z) = g(x)(y)(z) •Consequences: • functions because of currying can be partially applied • language runtimes can be easier (Haskell) •Scala example 8 | Functional Programming | 1 July 2013
  • 9. Pattern matching •“Decomposing data structures and ADTs” • Abstract Data Types (tuples) • data structures (Cons Nil lists) •Nothing to do with switch statement • constant-time runtime lookup over constants •Consequences: • no missing cases • no exceptions for wrong variants •SML example 9 | Functional Programming | 1 July 2013
  • 10. Wrap up •Functional programming is not only, but also about: • Immutability • Memoization • Recursion, Tail recursion • Higher-order functions • Currying and Partial application • Pattern matching 10 | Functional Programming | 1 July 2013
  • 11. Functional programming is much more stuff… •Influential people: • Alonso Church • Haskell Curry • John McCarthy •More advanced concepts: • composition, functors, monads, ... •Tons of languages: • Clojure, F#, Lisp, OCaml, Python, Racket, Scala, Scheme, SML 11 | Functional Programming | 1 July 2013
  • 12. Thank you for attention Functional programming rocks
  • 13. Disclaimer CONFLICTS OF INTEREST BARCLAYS IS A FULL SERVICE INVESTMENT BANK. In the normal course of offering investment banking products and services to clients. Barclays may act in several capacities (including issuer, market maker, underwriter, distributor, index sponsor, swap counterparty and calculation agent) simultaneously with respect to a product, giving rise to potential conflicts of interest which may impact the performance of a product. NOT RESEARCH This document is from a Barclays Trading and/or Distribution desk and is not a product of the Barclays Research department. Any views expressed may differ from those of Barclays Research. BARCLAYS POSITIONS Barclays, its affiliates and associated personnel may at any time acquire, hold or dispose of long or short positions (including hedging and trading positions) which may impact the performance of a product. FOR INFORMATION ONLY NOT BINDING. THIS DOCUMENT IS PROVIDED FOR INFORMATION PURPOSES ONLY AND IT IS SUBJECT TO CHANGE. IT IS INDICATIVE ONLY AND IS NO OFFER Barclays is not offering to sell or seeking offers to buy any product or enter into any transaction. Any transaction requires Barclays’ subsequent formal agreement which will be subject to internal approvals and binding transaction documents. NO LIABILITY Barclays is not responsible for the use made of this document other than the purpose for which it is intended, except to the extent this would be prohibited by law or regulation. NO ADVICE OBTAIN INDEPENDENT PROFESSIONAL ADVICE BEFORE INVESTING OR TRANSACTING. Barclays is not an advisor and will not provide any advice relating to a product. Before making an investment decision, investors should ensure they have sufficient information to ascertain the legal, financial, tax and regulatory consequences of an investment to enable them to make an informed investment decision. THIRD PARTY INFORMATION Barclays is not responsible for information stated to be obtained or derived from third party sources or statistical services. PAST & SIMULATED PAST PERFORMANCE Any past or simulated past performance (including back-testing) contained herein is no indication as to future performance. OPINIONS SUBJECT TO CHANGE All opinions and estimates are given as of the date hereof and are subject to change. Barclays is not obliged to inform investors of any change to such opinions or estimates. NOT FOR RETAIL This document is being directed at persons who are professionals and is not intended for retail customer use. IMPORTANT DISCLOSURES are unable to access. For important regional disclosures you must read, click on the link relevant to your region. Please contact your Barclays representative if you EMEA EMEA Disclosures APAC APAC Disclosures U.S. US Disclosures IRS CIRCULAR 230 DISCLOSURE: Barclays does not provide tax advice. Please note that (i) any discussion of US tax matters contained in this communication (including any attachments) cannot be used by you for the purpose of avoiding tax penalties; (ii) this communication was written to support the promotion or marketing of the matters addressed herein; and (iii) you should seek advice based on your particular circumstances from an independent tax advisor. CONFIDENTIAL This document is confidential and no part of it may be reproduced, distributed or transmitted without the prior written permission of Barclays. ABOUT BARCLAYS Barclays Bank PLC offers premier investment banking products and services to its clients through Barclays Bank PLC. Barclays Bank PLC is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and the Prudential Regulation Authority and is a member of the London Stock Exchange. Barclays Bank PLC is registered in England No. 1026167 with its registered office at 1 Churchill Place, London E14 5HP. COPYRIGHT © Copyright Barclays Bank PLC, 2014 (all rights reserved). 13 | Functional Programming | 1 July 2013