際際滷

際際滷Share a Scribd company logo
I WROTE A
FUNCTION, AM I A
FUNCTIONAL PROGRAMMING
FUNCTIONAL PROGRAMMING
DEVSPACE WOULD LIKE TO THANK OUR
SPONSORS
FUNCTIONAL PROGRAMMING
ROBERTO LOPEZ
Over 20 Years in IT
Started as a Help Desk technician
11 years ago started RHLopez Consulting, Inc.
Primarily work with Microsoft .Net and .Net Core
Application Development, Software Architecture, Systems Integration, Database Design, Report Writing
Manufacturing, Financial, Management, Higher Education, E-commerce, Media Sectors
Learning Haskell, Elm
E-mail: roberto@rhlopez.com
Twitter: @ralmlopez
Phone: 615-604-0813
FUNCTIONAL PROGRAMMING
MOTIVATION
 Teach to learn
 First conference talk
 Helping others through my experience
FUNCTIONAL PROGRAMMING
Why should I care?
What is it?
Characteristics
Learning
Resources
OVERVIEW
FUNCTIONAL PROGRAMMING
WHY SHOULD I
CARE?
 A different way of thinking / solving a problem
 Less typing (succint)
 Higher levels of abstraction
 Easier to reason about a program
 Less bugs - no nulls, sum types
FUNCTIONAL PROGRAMMING
WHAT IS IT?
Functional programming is so called because its fundamental operation is
the application of functions to arguments
John Hughes, Why Functional Programming Matters
FUNCTIONAL PROGRAMMING
WHAT IS IT?
Functional programming is a computer programming paradigm that relies
on functions modeled on mathematical functions. The essence of functional
programming is that programs are a combination of expressions. 
Haskel Programming from First Principles, Chris Allen and Julie Moronuki
8
FUNCTIONAL PROGRAMMING
WHAT IS IT?
 Based on lambda calculus - Alonzo Church 1930s
 Turing complete
 了x.(x + 1) => 了x.(x + 1) 3 => [x := 3] => 3 + 1 => 4
 Expressions, variables, and abstractions
 Expressions = variables | abstractions
 Abstractions = functions
9
FUNCTIONAL PROGRAMMING
CHARACTERISTICS
 Functions are First-Class, Higher-Order
 Pure Functions (No Side-Effects)
 Referential Transparency
 Immutability
 Currying
 Partial Application
 Recursion
 Lazy
FUNCTIONAL PROGRAMMING
CHARACTERISTICS -
FUNCTIONS FIRST-CLASS
 Functions treated as first-class variables
 Can be passed to functions as parameters
 Can be returned from functions
 Functions that take or return functions are called higher-order
functions
FUNCTIONAL PROGRAMMING
CHARACTERISTICS - PURE
FUNCTIONS
 Functions only operate on the inputs given
 No side-effects
12
FUNCTIONAL PROGRAMMING
CHARACTERISTICS -
REFERENTIAL TRANSPARENCY
 Functions yield the same result for a given input
FUNCTIONAL PROGRAMMING
CHARACTERISTICS -
IMMUTABILITY
 Data is immutable, it cannot be changed once declared
 Functions return a copy of the data with the new changes
14
FUNCTIONAL PROGRAMMING
CHARACTERISTICS -
CURRYING
 Functions take one argument and return one result
FUNCTIONAL PROGRAMMING
CHARACTERISTICS - PARTIAL
APPLICATION
 Fix a number of arguments to a function to produce another function
of smaller arity
FUNCTIONAL PROGRAMMING
CHARACTERISTICS -
RECURSION
 Heavily used and often the only way to iterate
FUNCTIONAL PROGRAMMING
CHARACTERISTICS - LAZY
 Since functions are pure and have referential integrity they can be
called at any time and yield the same result
 This makes it possible to delay computation until needed
FUNCTIONAL PROGRAMMING
HASKELL TYPES
 No Nulls
 Sum Types
I call it my billion-dollar mistake. It was the invention of the null reference
in 1965.  This has led to innumerable errors, vulnerabilities, and system
crashes, which have probably caused a billion dollars of pain and damage
in the last forty years.
Tony Hoare
19
FUNCTIONAL PROGRAMMING
LEARNING
 Can be frustrating
 Pure functional vs hybrid languages
 Some pure languages: Haskell, Elm, Idris, PureScript
 .Net - F#
 Java - Clojure and Scala
 Erlang and Elixir
 Javascript
 Python
FUNCTIONAL PROGRAMMING
RESOURCES
 Haskell Programming from first principles - Chris Allen and Julie
Moronuki
 Programming Elm - Jeremy Fairbank
 Haskell Weekly
 Elm Town, Javascript to Elm
 Functional Geekery
 Lambda Cast
WHACK A BUG
QUESTIONS?
THANK YOU

More Related Content

Functional Programming Introduction