SlideShare a Scribd company logo
1 of 38
Real World
Functional
Reactive Programming
Hello!
I am Eric Polerecky
You can find me at:
@detroitpro
Functional
Reactive
Programming
FRP is a HUGE topic; we are only going to scratch the surface. I’m not an expert in FRP
Is Rx (Reactive Extensions) right for me?
Rx (Rx.NET)
RxJs
Bacon.JS
Ruby
RxJava
RxCpp
Python
ReactiveCocoa
reactivex.io
rxmarbles.com
introtorx.com
The introduction to Reactive
Programming you've been
missing
Paul Betts - Introduction to
Rx
reactiveui.readthedocs.org
GitHub
NetFlix
Microsoft
Lets look a trivial example
DEM
O
OVERVIEW
DEMO TIME!
Define FRP
Quick overview of functional programming
Dive into reactive programming
Why?!?!?
DEMO TIME!
REACTIVE
Reactive programming is an emerging
discipline which combines concurrency
and event-based and asynchronous
systems.
- Wikipedia
REACTIVE
Reactive programming is programming
with asynchronous data streams.
- staltz
TODO: Drink some water
Get example of async data streams from audience
FUNCTIONAL
Lambda Calculus
Category Theory
Mondas
Functor
Parametric Polymorphism
FUNCTIONAL
Lambda Calculus
Category Theory
Mondas
Functor
Parametric Polymorphism
FUNCTIONAL
‘First Class’ Functions
Pass functions into function
Declarative Programming
Compose methods together to create higher abstraction
FRP uses come functional concepts but not all. FRP can be an introduction into functional
programming.
C# has functional concepts but is not a functional language.
FUNCTIONAL
var even = numberRepository()
.Select(x => x + 1)
.Where(x => x % 2 == 0)
.OrderByDescending(x=>x);
linq is functional in nature
pass functions into ‘functions’ operators
methods can be composed
FUNCTIONAL
‘First Class’ Functions
Pass functions into function
Declarative Programming
Compose methods together to create higher abstraction
Immutable Data
We don’t change data, we project (select) it into new formats
FRP only really uses a small subset of functional concepts. The reactive part of FRP is more more
complex and mind bending.
REACTIVE
Reactive programming is programming
with asynchronous data streams.
- staltz
TODO: Drink some water
Get example of async data streams from audience
REACTIVE
Click
Click: async - if it happens, it will happen in the future.
Examples of async data streams: click, message queue, mouse move.
FRP is CONSTRUCTS for programming with async data streams.
REACTIVE
variables
user input
properties
caches
lists
Things that are not async data streams; but should have been and can be made into async data
streams.
Anything that could change (mutate) it’s value
REACTIVE
twitter feed
directory
searching
web service calls
keyboard input
file changed
Twitter feed as data stream
When you start thinking about async data streams.
EVERYTHING BECOMES AN ASYNC DATA STREAM!
list scroll
video processing
mouse move
queues
messaging
REACTIVE
twitter feed
directory
searching
web service calls
keyboard input
file changed
This mental shift is the hardest part of FRP.
list scroll
video processing
mouse move
queues
messaging
REACTIVE
IObservable<T> and IObserver<T>
Sometime, in the future, someone is going to give me data, how do I reason about it
IEnumerable<T> and IEnumerable<T>
I want all the data now! or I’ll stand here and wait, no one can do anything until I get my
data!
REACTIVE
IObservable<T> and IObserver<T>
Sometime, in the future, someone is going to give me data, how do I reason about it
IEnumerable<T> and IEnumerable<T>
I want all the data now! or I’ll stand here and wait, no one can do anything until I get my
data!
REACTIVE
Events should have been lists
FRP is commonly called: Linq to events
REACTIVE
IObservable<T>
Linq to events
+ Time!
REACTIVE
Reactive programming is turning
everything into an asynchronous data
stream and programming with
asynchronous data streams.
- Eric Polerecky aka: detroitpro
TODO: Drink some water
Get example of async data streams from audience
WHY?
event soup
async / await everywhere!
test-ability
control time and space!
Lets look a non-trivial example
DEM
O
DECLARATIVE
PROGRAMMING
Higher abstraction, describe what you
want
Let’s talk about declarative programming
<h2>Hello</h2>
Let’s talk about declarative programming
var even = numberRepository()
.Select(x => x + 1)
.Where(x => x % 2 == 0)
.OrderByDescending(x=>x);
“
Expresses the logic of a
computation without describing its
control flow
=
Declarative Programming
What is a monad?
MyObservable //event args come in, I don’t care from where
.Select(x => x.FullPath) //transform data stream
.Do(ZipFile) //the business logic that needs to happen
.Catch<string,Exception>(...)
.Retry(3) //cross cutting concerns removed from logic
.Buffer(2) //bend time and space
.Subscribe(); //make it so
“
IObservable
=
Reversed IEnumerable + Time
“
Functional Reactive Programming
=
IObservable + Declarative
Programming
“
Functional Reactive Programming
is to events, lists and properties
what Inversion of Control is to
dependencies
WHEN
Lets understand when to use Functional
Reactive Programming
ALWAYS!
Just kidding...
Desktop/Mobile/UI
responsive UI
anywhere that is stateful
even the world wide web
Incoming Data
events (click events)
streams of data (sensors)
http
file system
Let’s review what we learned about FRP
■ Reverse the flow of data
■ Declarative (higher level abstraction)
■ Linq to events
■ Good for when you would work with events
■ Good for when you have state (not request-response)
■ Reactive libraries are available in every language
■ Rx is on nuget (Rx-Main)
Thanks!
Any questions?
You can find me at:
@detroitpro

More Related Content

What's hot

What's hot (20)

The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFutures
 
Avoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.jsAvoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.js
 
Non Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJavaNon Blocking I/O for Everyone with RxJava
Non Blocking I/O for Everyone with RxJava
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in'tScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
ScalaSwarm 2017 Keynote: Tough this be madness yet theres method in't
 
rx-java-presentation
rx-java-presentationrx-java-presentation
rx-java-presentation
 
Javascript Promises/Q Library
Javascript Promises/Q LibraryJavascript Promises/Q Library
Javascript Promises/Q Library
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
Javascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and GulpJavascript TDD with Jasmine, Karma, and Gulp
Javascript TDD with Jasmine, Karma, and Gulp
 
Reactive Java (33rd Degree)
Reactive Java (33rd Degree)Reactive Java (33rd Degree)
Reactive Java (33rd Degree)
 
Async and Await on the Server
Async and Await on the ServerAsync and Await on the Server
Async and Await on the Server
 
Concurrent Programming in Java
Concurrent Programming in JavaConcurrent Programming in Java
Concurrent Programming in Java
 
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
 
RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]RxJava applied [JavaDay Kyiv 2016]
RxJava applied [JavaDay Kyiv 2016]
 
Streams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to RxStreams, Streams Everywhere! An Introduction to Rx
Streams, Streams Everywhere! An Introduction to Rx
 
Callbacks and control flow in Node js
Callbacks and control flow in Node jsCallbacks and control flow in Node js
Callbacks and control flow in Node js
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Reactive Java (GeeCON 2014)
Reactive Java (GeeCON 2014)Reactive Java (GeeCON 2014)
Reactive Java (GeeCON 2014)
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Reactive Thinking in Java
Reactive Thinking in JavaReactive Thinking in Java
Reactive Thinking in Java
 

Viewers also liked (11)

Işveren işlemleri ve denetmen semineleri
Işveren işlemleri ve denetmen  semineleriIşveren işlemleri ve denetmen  semineleri
Işveren işlemleri ve denetmen semineleri
 
Gebeurtenis
GebeurtenisGebeurtenis
Gebeurtenis
 
Işyeri işveren il müdürlüğü
Işyeri işveren il müdürlüğüIşyeri işveren il müdürlüğü
Işyeri işveren il müdürlüğü
 
Coastal citizenship
Coastal citizenship Coastal citizenship
Coastal citizenship
 
Beginning Site Design
Beginning Site DesignBeginning Site Design
Beginning Site Design
 
Borcu yoktur
Borcu yokturBorcu yoktur
Borcu yoktur
 
Iş kolu değişiklikleri
Iş kolu değişiklikleriIş kolu değişiklikleri
Iş kolu değişiklikleri
 
Contents
ContentsContents
Contents
 
Iz imhai
Iz imhaiIz imhai
Iz imhai
 
Heat transfer brochure
Heat transfer brochureHeat transfer brochure
Heat transfer brochure
 
Al-Ándalus: Segundo de Bachiller, PAU
Al-Ándalus: Segundo de Bachiller, PAUAl-Ándalus: Segundo de Bachiller, PAU
Al-Ándalus: Segundo de Bachiller, PAU
 

Similar to Real world functional reactive programming

Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009
pauldix
 
Apps thatworkandflow
Apps thatworkandflowApps thatworkandflow
Apps thatworkandflow
Koen Handekyn
 

Similar to Real world functional reactive programming (20)

PHP Reactive Programming at Medan Tech Day 2018
PHP Reactive Programming at Medan Tech Day 2018PHP Reactive Programming at Medan Tech Day 2018
PHP Reactive Programming at Medan Tech Day 2018
 
A general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4JA general introduction to Spring Data / Neo4J
A general introduction to Spring Data / Neo4J
 
Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009
 
Data Streaming Technology Overview
Data Streaming Technology OverviewData Streaming Technology Overview
Data Streaming Technology Overview
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
 
Apps thatworkandflow
Apps thatworkandflowApps thatworkandflow
Apps thatworkandflow
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Not only SQL
Not only SQL Not only SQL
Not only SQL
 
FRP with Ractive and RxJS
FRP with Ractive and RxJSFRP with Ractive and RxJS
FRP with Ractive and RxJS
 
PWA to React Native migration
PWA to React Native migrationPWA to React Native migration
PWA to React Native migration
 
OpenFaaS KubeCon Zero to Serverless in 60 seconds anywhere
OpenFaaS KubeCon Zero to Serverless in 60 seconds anywhereOpenFaaS KubeCon Zero to Serverless in 60 seconds anywhere
OpenFaaS KubeCon Zero to Serverless in 60 seconds anywhere
 
Lambda Jam 2015: Event Processing in Clojure
Lambda Jam 2015: Event Processing in ClojureLambda Jam 2015: Event Processing in Clojure
Lambda Jam 2015: Event Processing in Clojure
 
Rx Swift
Rx SwiftRx Swift
Rx Swift
 
Yahoo compares Storm and Spark
Yahoo compares Storm and SparkYahoo compares Storm and Spark
Yahoo compares Storm and Spark
 
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-TestingJava Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
 
How to debug slow lambda response times
How to debug slow lambda response timesHow to debug slow lambda response times
How to debug slow lambda response times
 
Real-World Pulsar Architectural Patterns
Real-World Pulsar Architectural PatternsReal-World Pulsar Architectural Patterns
Real-World Pulsar Architectural Patterns
 
LarKC Tutorial at ISWC 2009 - Introduction
LarKC Tutorial at ISWC 2009 - IntroductionLarKC Tutorial at ISWC 2009 - Introduction
LarKC Tutorial at ISWC 2009 - Introduction
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Real world functional reactive programming

Editor's Notes

  1. FRP is not pure functional programming. Functional programming in C# is not pure functional programming.
  2. Show a directory searcher with retry and junk. https://gist.github.com/detroitpro/204b9874c07817fd2bea
  3. Pass functions into functions Compose/chain functions
  4. Pass functions into functions Compose/chain functions
  5. Pass functions into functions Compose/chain functions
  6. Show a directory searcher with retry and junk. https://gist.github.com/detroitpro/204b9874c07817fd2bea
  7. focused on describing how a program operates.
  8. HTML (and XAML) is an example of declarative programming, we describe what we want, the rendering engine is responsible for display/layout.
  9. We reverse the flow of the caller, decouple the side-effects
  10. We build up a linq query, but nothing happens until the console.writeline. If we remove the foreach and console.writeline no items are pulled out of the enumerable.range. This (building up monads) is a concept from functional programming. This (passing lambdas) is also a concept from functional programming. GetEnumerator is called on the list of items until it is complete. What we have here is a pull based system. Our programming is pulling items out of the list, filtering on them (that’s cool) and acting on some of them.