SlideShare a Scribd company logo
1 of 21
FP in OOP
Lessons learned from Functional Programming applied
to Object Oriented Programming
Functional Programming: Why?
OOP was the great paradigm shift of the 90s
FP will be the next great paradigm shift
Excels at parallel and distributed computing
Background: Church-Turing Thesis
Anything that could possibly be computed, can
be computed using any of the following:
● A Turing machine
● The Lambda Calculus
● Recursion
See Google for more details!
/* Factorial in PHP */
function factorial($n)
{
$result = 1;
for ($c = 1; $c <= $n; $c++)
$result = $result * $c;
return $result;
}
The Imperative Way
The Functional Way
-- Factorial in Haskell
factorial 0 = 1
factorial n = n * factorial (n - 1)
Value Objects
Value objects
Immutable
Safe to compose
Easy to test
Use to express as much logic as possible
Value Objects
class Date {
private $day, $month, $year;
public function __construct($day, $month, $year) { ... }
public function isAfter(Date $other) { ... }
public function isBefore(Date $other) { ... }
public function isSame(Date $other) { ... }
}
class DateRange {
private $start, $end;
public function __construct(Date $start, Date $end) {
if ($start->isAfter($end)) {
throw new InvalidArgumentException(); }
}
public function contains(Date $day) {
return $day->isAfter($this->start) &&
$day->isBefore($this->end);
}}
Command/Query
Separation
Command/query separation
Isolates state-modifying logic
Queries are safe to reorder, easier to
optimize
Easier to test
Provides opportunity to use different
models for read and write operations
(CQRS)
Command/query separation
class ShoppingCart {
private $total = 0;
private $products = array();
public function calculateSubtotal() {
$subtotal = 0;
foreach ($this->products as $product) {
$subtotal += $product->getPrice();
}
return $subtotal;
}
public function calculateTax() {
return $this->total * 0.075;
}
public function addProduct($product) {
$this->products[] = $product;
}
public function updateTotal($amount) { $this->total = $amount;
Command/query separation
$product1 = new Product(25.00);
$product2 = new Product(10.00);
$cart = new ShoppingCart;
$cart->addProduct($product1);
$cart->addProduct($product2);
assert($cart->calculateSubtotal() == 35.00);
$cart->updateTotal($cart->calculateSubtotal());
assert($cart->getTotal() + $cart->calculateTax() ==
37.625);
assert($cart->calculateTax() + $cart->getTotal() ==
37.625);
$cart->updateTotal($cart->getTotal() + $cart-
>calculateTax());
Higher Order Functions
Higher-order functions
Let you parameterize behavior or
designate new behavior at runtime
OOP design patterns:
● Strategy pattern
● Visitor pattern
Strategy Example - PHP 1
abstract class PricingStrategy {
private $customer;
public function __construct($customer) { ... }
abstract public function calculatePrice($prodcut);
}
class GoldClubPricing extends PricingStrategy {
public function calculatePrice($prodcut) { ... }
}
class HighRiskPricing extends PricingStrategy {
public function calculatePrice($prodcut) { ... }
}
class LoyalCustomerPricing extends PricingStrategy {
public function calculatePrice($prodcut) { ... }
}
Strategy Example - PHP 2
class ShoppingCart {
private $products;
private $customer;
private function getPricingStrategy($customer) { ... }
public function calculateSubtotal() {
$subtotal = 0;
$pricingStrategy = $this->getPricingStrategy($this->customer);
foreach ($this->products as $product) {
$subtotal += $pricingStrategy->calculatePrice($product);
}
return $subtotal;
}
}
Strategy Example - Functional
goldClubPricing product = ...
highRiskPricing product = ...
loyalCustomerPricing product = ...
getPricingStrategy customer = ...
calculateSubtotal customer products = sum (map pricingStrategy products)
where pricingStrategy = getPricingStrategy customer
Other Techniques
Other techniques
Lazy evaluation
Map/Reduce (Folds)
Message passing concurrency and the Actor
model
Thank you!
Further Reading
Patterns of Enterprise Application Architecture -
Martin Fowler
Domain Driven Design - Eric Evans
A Functional Pattern System for Object-Oriented
Design - Thomas Kuhne
The Power of Value - Dan Johnsson
http://www.infoq.com/presentations/Value-Objects-Dan-Bergh-Johnsson
Objects, Anomalies, and Actors: The Next Revolution
http://www.infoq.com/presentations/Objects-Anomalies-and-Actors-The-Next-Revolution
Actor Model Concurrency - Jeff Darcy
http://pl.atyp.us/wordpress/index.php/2009/07/actor-model-concurrency

More Related Content

What's hot

Web app development_php_06
Web app development_php_06Web app development_php_06
Web app development_php_06
Hassen Poreya
 

What's hot (20)

Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
1
11
1
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
Web app development_php_06
Web app development_php_06Web app development_php_06
Web app development_php_06
 
C++ programs
C++ programsC++ programs
C++ programs
 
Formal methods Project Report for the support of slides uploaded
Formal methods Project Report for the support of slides uploaded Formal methods Project Report for the support of slides uploaded
Formal methods Project Report for the support of slides uploaded
 
Stl algorithm-Basic types
Stl algorithm-Basic typesStl algorithm-Basic types
Stl algorithm-Basic types
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
Function basics
Function basicsFunction basics
Function basics
 
week-11x
week-11xweek-11x
week-11x
 
week-1x
week-1xweek-1x
week-1x
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
6. function
6. function6. function
6. function
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Shan
ShanShan
Shan
 
Implementing stack
Implementing stackImplementing stack
Implementing stack
 

Similar to Lessons learned from functional programming

Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Mario Fusco
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOP
Wildan Maulana
 

Similar to Lessons learned from functional programming (20)

Why is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenariosWhy is crud a bad idea - focus on real scenarios
Why is crud a bad idea - focus on real scenarios
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
 
Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Migrating to dependency injection
Migrating to dependency injectionMigrating to dependency injection
Migrating to dependency injection
 
AngularJS Testing Strategies
AngularJS Testing StrategiesAngularJS Testing Strategies
AngularJS Testing Strategies
 
Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8
 
ZG PHP - Specification
ZG PHP - SpecificationZG PHP - Specification
ZG PHP - Specification
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension Methods
 
Thinking Functionally with JavaScript
Thinking Functionally with JavaScriptThinking Functionally with JavaScript
Thinking Functionally with JavaScript
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOP
 
DIG1108 Lesson 6
DIG1108 Lesson 6DIG1108 Lesson 6
DIG1108 Lesson 6
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mocking
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 

Lessons learned from functional programming

  • 1. FP in OOP Lessons learned from Functional Programming applied to Object Oriented Programming
  • 2. Functional Programming: Why? OOP was the great paradigm shift of the 90s FP will be the next great paradigm shift Excels at parallel and distributed computing
  • 3. Background: Church-Turing Thesis Anything that could possibly be computed, can be computed using any of the following: ● A Turing machine ● The Lambda Calculus ● Recursion See Google for more details!
  • 4. /* Factorial in PHP */ function factorial($n) { $result = 1; for ($c = 1; $c <= $n; $c++) $result = $result * $c; return $result; } The Imperative Way
  • 5. The Functional Way -- Factorial in Haskell factorial 0 = 1 factorial n = n * factorial (n - 1)
  • 7. Value objects Immutable Safe to compose Easy to test Use to express as much logic as possible
  • 8. Value Objects class Date { private $day, $month, $year; public function __construct($day, $month, $year) { ... } public function isAfter(Date $other) { ... } public function isBefore(Date $other) { ... } public function isSame(Date $other) { ... } } class DateRange { private $start, $end; public function __construct(Date $start, Date $end) { if ($start->isAfter($end)) { throw new InvalidArgumentException(); } } public function contains(Date $day) { return $day->isAfter($this->start) && $day->isBefore($this->end); }}
  • 10. Command/query separation Isolates state-modifying logic Queries are safe to reorder, easier to optimize Easier to test Provides opportunity to use different models for read and write operations (CQRS)
  • 11. Command/query separation class ShoppingCart { private $total = 0; private $products = array(); public function calculateSubtotal() { $subtotal = 0; foreach ($this->products as $product) { $subtotal += $product->getPrice(); } return $subtotal; } public function calculateTax() { return $this->total * 0.075; } public function addProduct($product) { $this->products[] = $product; } public function updateTotal($amount) { $this->total = $amount;
  • 12. Command/query separation $product1 = new Product(25.00); $product2 = new Product(10.00); $cart = new ShoppingCart; $cart->addProduct($product1); $cart->addProduct($product2); assert($cart->calculateSubtotal() == 35.00); $cart->updateTotal($cart->calculateSubtotal()); assert($cart->getTotal() + $cart->calculateTax() == 37.625); assert($cart->calculateTax() + $cart->getTotal() == 37.625); $cart->updateTotal($cart->getTotal() + $cart- >calculateTax());
  • 14. Higher-order functions Let you parameterize behavior or designate new behavior at runtime OOP design patterns: ● Strategy pattern ● Visitor pattern
  • 15. Strategy Example - PHP 1 abstract class PricingStrategy { private $customer; public function __construct($customer) { ... } abstract public function calculatePrice($prodcut); } class GoldClubPricing extends PricingStrategy { public function calculatePrice($prodcut) { ... } } class HighRiskPricing extends PricingStrategy { public function calculatePrice($prodcut) { ... } } class LoyalCustomerPricing extends PricingStrategy { public function calculatePrice($prodcut) { ... } }
  • 16. Strategy Example - PHP 2 class ShoppingCart { private $products; private $customer; private function getPricingStrategy($customer) { ... } public function calculateSubtotal() { $subtotal = 0; $pricingStrategy = $this->getPricingStrategy($this->customer); foreach ($this->products as $product) { $subtotal += $pricingStrategy->calculatePrice($product); } return $subtotal; } }
  • 17. Strategy Example - Functional goldClubPricing product = ... highRiskPricing product = ... loyalCustomerPricing product = ... getPricingStrategy customer = ... calculateSubtotal customer products = sum (map pricingStrategy products) where pricingStrategy = getPricingStrategy customer
  • 19. Other techniques Lazy evaluation Map/Reduce (Folds) Message passing concurrency and the Actor model
  • 21. Further Reading Patterns of Enterprise Application Architecture - Martin Fowler Domain Driven Design - Eric Evans A Functional Pattern System for Object-Oriented Design - Thomas Kuhne The Power of Value - Dan Johnsson http://www.infoq.com/presentations/Value-Objects-Dan-Bergh-Johnsson Objects, Anomalies, and Actors: The Next Revolution http://www.infoq.com/presentations/Objects-Anomalies-and-Actors-The-Next-Revolution Actor Model Concurrency - Jeff Darcy http://pl.atyp.us/wordpress/index.php/2009/07/actor-model-concurrency

Editor's Notes

  1. Welcome to ioXchange! Lead with title
  2. Slide first OOP is still the dominant paradigm FP makes it easier to deal with concurrent and distributed systems reliably Touch on some of the reasons why in this presentation Object Anomalies presentation linked at end
  3. Slide first All three are equivalent Turing machines work by modifying state and recording on tape Lambda Calculus/Recursion work by deriving state from expression evaluation
  4. Notes first PHP's syntax close enough to C so most people can follow it Explain slide Special case of factorial(0) is handled by side effect of for loop condition failing on the first iteration
  5. Typical FP: recursion instead of iteration Tail-call optimization used
  6. Came from SmallTalk community?
  7. Slide first Strings, Tuples, or other small values provided by the language
  8. Date business logic methods DateRange invariant enforced through Date methods DateRange composed of Date value objects Immutable - No access to change object state Safe to compose, re-order, pass around
  9. The Turing model can be dangerous sometimes
  10. Separates logic into commands and queries Queries - side effect free functions Commands - modify observable state, but don't return anything Explain slide Testing needs different approaches for commands vs queries Commands usually need more fixture setup Can be applied architecturally to extend benefits to whole system (Greg Young, CQRS)
  11. 3 queries, 2 commands
  12. Requires language to support functions as first-class values Explain slide
  13. Concrete Strategy implementations derived from an abstract base class defining the common interface
  14. The shopping cart picks which pricing strategy to apply based on who its customer is The pricing strategy is then used to calculate the adjusted price for each product in the shopping cart The adjusted prices are added up to produce the cart subtotal
  15. Slide First - brief; explain syntax after Higher order map takes a function value as an argument getPricingStrategy returns functions as first class values Shipping costs can be treated the same way
  16. Each point, one at a time Lazy Evaluation Defer evaluation until you really need the value Pulling rows from a result set Map/Reduce (Folds) One of the main ways to avoid iteration, besides recursion Stats over a list, string tokenization Testability/Composability of iterators, but can be distributed and/or parallelized - Hadoop Message passing Contrasts with shared-state concurrency Shared-state concurrency relies on locking and is easy to get wrong - deadlocks, lock releasing Simple mailbox metaphor, no shared state Local or remote, unlike shared-state Actor model Based on message passing, popularized by Erlang Processes that own the state, local or remote Valid messages form a protocol, little state machines
  17. FP techniques make systems: More scalable Easier to test/debug More future-proof