SlideShare una empresa de Scribd logo
1 de 34
λ Functional Programming
Who am I? Ryan Riley Catapult Systems Houston Blog: http://wizardsofsmart.net GitHub: http://github.com/panesofglass Twitter: @panesofglass
Agenda Functional Programming Concepts Func’y C# Resources
1. Functional Programming Concepts
Functional programming is just a style.
Treat functions as values.
What is a function? A function, as in math. (In particular, as in lambda calculus.) ((Ask Jeff Odell.))
Follow the Arrows add x y has a type of int -> int -> int In C#, this could be Func<int, int, int> (Actually, that’s Func<int,<Func<int, int>>>. We’ll see why in a moment….)
Functions are values, too. .NET 1.0 => delegates .NET 2.0 => anonymous delegates + generics .NET 3.0 => lambdas Higher-order functions accept a function as a parameter.
Immutability NO side effects! NO state! NO I/O! 	Functions take an input and return a result Image from One Year Bible Blog
Implications Recursion Persistent data structures
Paradigm-shift Declarative vs. Imperative What? How?
Advantages Very easy to reason about Concurrency friendly Easy to compose:doubleSq x = square(double(x))doubleSq = double . square Foundation of Domain Specific Languages
Disadvantages Too much recursion can overflow the stack (without tail-call optimization, or TCO) High memory consumption from creating so many objects …
However,
Referential transparency Replace a function with its value Efficiency with caching (a.k.a. memoization) Easier for programmers to understand ∴ Easier to reuse and test
So what? Moore’s Law is failing. Multiple CPUs / cores is the future. Controlling mutable state in concurrency is very hard …unless you have no mutable state!
Also, “Mock objects and dependency injection are just for people who don’t know math.”* ~ Erik Meijer, Microsoft * See the Silverlight Toolkit for test examples.
2. Play that Func’yMusic C#
Func & Action Define your functions. Generics are important. Type-safety over many types.
Lists everywhere! Functional languages like Lisp build entirely on lists and maps (i.e. Dictionaries). Feel like you’ve seen this before?
Also by Erik Meijer! LINQ! Implementation of common functional programming functions over lists via IEnumerable. Select => map Where => filter Aggregate => fold / reduce SelectMany => bind / fmap, or “map then flatten”
This means you are probably already using FP!
Take it further Functions as data Closures => Capture external state for later Currying + Partial application =>Reduce dependencies Memoization => Run it again later
Demo Currying and Partial application
Make it concurrent Task Parallel Library (PFx) Reactive Extensions (Rx) PLinq => Parallel LINQ
Demo Concurrency
What didn’t we cover? Many more functional operators (LINQ) Managing mutable state from the environment LINQ to Observables, Continuations, etc. The “M” word
3. Resources
Books ‘n Blogs Real-World Functional Programming PFx Team Blog Rx Team Blog Matthew Podwysocki’s Weblog
Libraries Functional C# Reactive Extensions (Rx)
Videos Functional Programming Fundamentals(Channel 9 Lecture Series)
Languages More F# => http://c4fsharp.groups.live.com More Clojure and IronScheme => http://hdlug.groups.live.com
Questions?

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

C# Generics
C# GenericsC# Generics
C# Generics
 
Interface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementationInterface in java ,multiple inheritance in java, interface implementation
Interface in java ,multiple inheritance in java, interface implementation
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
linked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutoriallinked list in Data Structure, Simple and Easy Tutorial
linked list in Data Structure, Simple and Easy Tutorial
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
Java threads
Java threadsJava threads
Java threads
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Python programming : Control statements
Python programming : Control statementsPython programming : Control statements
Python programming : Control statements
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Java 8 lambda
Java 8 lambdaJava 8 lambda
Java 8 lambda
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Exception handling
Exception handlingException handling
Exception handling
 
Break and continue
Break and continueBreak and continue
Break and continue
 
Python set
Python setPython set
Python set
 
Function
FunctionFunction
Function
 

Destacado

Klar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikation
Klar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikationKlar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikation
Klar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikation
Sense Communication
 
Lasi datawrangling
Lasi datawranglingLasi datawrangling
Lasi datawrangling
Tony Hirst
 
Learning R via Python…or the other way around
Learning R via Python…or the other way aroundLearning R via Python…or the other way around
Learning R via Python…or the other way around
Sid Xing
 
How to scraping content from web for location-based mobile app.
How to scraping content from web for location-based mobile app.How to scraping content from web for location-based mobile app.
How to scraping content from web for location-based mobile app.
Diep Nguyen
 
Web scraping for cms websites in Android Application
Web scraping for cms websites in Android ApplicationWeb scraping for cms websites in Android Application
Web scraping for cms websites in Android Application
webscraping
 
Functional Pattern Matching on Python
Functional Pattern Matching on PythonFunctional Pattern Matching on Python
Functional Pattern Matching on Python
Daker Fernandes
 
Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)
Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)
Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)
Sammy Fung
 

Destacado (20)

The Functional Web
The Functional WebThe Functional Web
The Functional Web
 
HTTP: the Other ESB
HTTP: the Other ESBHTTP: the Other ESB
HTTP: the Other ESB
 
Klar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikation
Klar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikationKlar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikation
Klar til 2014? Slib dine kompetencer med et skræddersyet kursus i kommunikation
 
Practical F#
Practical F#Practical F#
Practical F#
 
Knowledge extraction from the Encyclopedia of Life using Python NLTK
Knowledge extraction from the Encyclopedia of Life using Python NLTKKnowledge extraction from the Encyclopedia of Life using Python NLTK
Knowledge extraction from the Encyclopedia of Life using Python NLTK
 
Functional Programming With Python (EuroPython 2008)
Functional Programming With Python (EuroPython 2008)Functional Programming With Python (EuroPython 2008)
Functional Programming With Python (EuroPython 2008)
 
Lasi datawrangling
Lasi datawranglingLasi datawrangling
Lasi datawrangling
 
Learning R via Python…or the other way around
Learning R via Python…or the other way aroundLearning R via Python…or the other way around
Learning R via Python…or the other way around
 
Data Wrangling with dplyr and tidyr Cheat Sheet
Data Wrangling with dplyr and tidyr Cheat SheetData Wrangling with dplyr and tidyr Cheat Sheet
Data Wrangling with dplyr and tidyr Cheat Sheet
 
How to scraping content from web for location-based mobile app.
How to scraping content from web for location-based mobile app.How to scraping content from web for location-based mobile app.
How to scraping content from web for location-based mobile app.
 
Web scraping for cms websites in Android Application
Web scraping for cms websites in Android ApplicationWeb scraping for cms websites in Android Application
Web scraping for cms websites in Android Application
 
Thinking in Functions: Functional Programming in Python
Thinking in Functions: Functional Programming in PythonThinking in Functions: Functional Programming in Python
Thinking in Functions: Functional Programming in Python
 
Marrying models and data: Adventures in Modeling, Data Wrangling and Software...
Marrying models and data: Adventures in Modeling, Data Wrangling and Software...Marrying models and data: Adventures in Modeling, Data Wrangling and Software...
Marrying models and data: Adventures in Modeling, Data Wrangling and Software...
 
Functional Pattern Matching on Python
Functional Pattern Matching on PythonFunctional Pattern Matching on Python
Functional Pattern Matching on Python
 
Practical Crowdfunding for Arizona Entrepreneurs - Fall 2013
Practical Crowdfunding for Arizona Entrepreneurs - Fall 2013Practical Crowdfunding for Arizona Entrepreneurs - Fall 2013
Practical Crowdfunding for Arizona Entrepreneurs - Fall 2013
 
Python functional programming
Python functional programmingPython functional programming
Python functional programming
 
It's the end of design patterns as we know it (and i feel fine)
It's the end of design patterns as we know it (and i feel fine)It's the end of design patterns as we know it (and i feel fine)
It's the end of design patterns as we know it (and i feel fine)
 
How My Comic Book Obsession Birthed a New Functional Testing Tool
How My Comic Book Obsession Birthed a New Functional Testing ToolHow My Comic Book Obsession Birthed a New Functional Testing Tool
How My Comic Book Obsession Birthed a New Functional Testing Tool
 
Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)
Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)
Web scraping 1 2-3 with python + scrapy (Summer BarCampHK 2012 version)
 
An Introduction to the Zen of Python
An Introduction to the Zen of PythonAn Introduction to the Zen of Python
An Introduction to the Zen of Python
 

Similar a Functional Programming

Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
Talbott Crowell
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
Robert Pickering
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010
Skills Matter
 

Similar a Functional Programming (20)

F# and the DLR
F# and the DLRF# and the DLR
F# and the DLR
 
F# and functional programming
F# and functional programmingF# and functional programming
F# and functional programming
 
RomaFramework Tutorial Basics
RomaFramework Tutorial BasicsRomaFramework Tutorial Basics
RomaFramework Tutorial Basics
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
Functional Programming in Go
Functional Programming in GoFunctional Programming in Go
Functional Programming in Go
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
 
Python 1&2.pptx
Python 1&2.pptxPython 1&2.pptx
Python 1&2.pptx
 
Python 1&2.pptx
Python 1&2.pptxPython 1&2.pptx
Python 1&2.pptx
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
 
Beware of Pointers
Beware of PointersBeware of Pointers
Beware of Pointers
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]C++ [ principles of object oriented programming ]
C++ [ principles of object oriented programming ]
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Beyond the Style Guides
Beyond the Style GuidesBeyond the Style Guides
Beyond the Style Guides
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
About Functional Programming
About Functional ProgrammingAbout Functional Programming
About Functional Programming
 

Más de Ryan Riley (6)

A Brief History of OWIN
A Brief History of OWINA Brief History of OWIN
A Brief History of OWIN
 
F# on the Web
F# on the WebF# on the Web
F# on the Web
 
Test first
Test firstTest first
Test first
 
Introduction to F#x
Introduction to F#xIntroduction to F#x
Introduction to F#x
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
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
vu2urc
 

Último (20)

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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
[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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Functional Programming