reactive meetup 0 copy

24
Reactive Programming Enthusiasts Denver Meetup Kickoff - “What is Reactive?” Patrick Charles

Upload: patrick-charles

Post on 10-May-2015

134 views

Category:

Technology


1 download

DESCRIPTION

Reactive Programming Enthusiasts Denver Meetup kickoff session presentation

TRANSCRIPT

Page 1: Reactive meetup 0 copy

Reactive Programming Enthusiasts Denver

Meetup Kickoff - “What is Reactive?”

Patrick Charles

Page 3: Reactive meetup 0 copy

Summary

• What/Why Reactive?

• Key Features

• Functional Languages

• Scala - actors, concurrency, message passing

• Code

Page 4: Reactive meetup 0 copy

What is Reactive?

"The world is concurrent. Things in the world don’t share data. Things communicate with

messages. Things fail."

- Joe Armstrong (Erlang co-creator)

Page 5: Reactive meetup 0 copy

Why Reactive?

• Complexity and Scale

• single/multicore -> thousands of nodes

• single/multiple users -> millions

• Kbps -> Gbps

• seconds -> nanoseconds

Page 6: Reactive meetup 0 copy

Key Features of Reactive

• 0: Asynchronous - nonblocking and event-driven

• 1: Loosely coupled - message passing w/o shared state

Page 7: Reactive meetup 0 copy
Page 8: Reactive meetup 0 copy

Reactive Manifesto• “Event-Driven” - asynchronous, communication

with message passing

• “Scalable” - loose coupling, event-driven, location transparency

• “Resilient” - able to recover from failures: isolation and supervision

• “Responsive” - responds in a meaningful and timely fashion

Page 9: Reactive meetup 0 copy

What happened?• Imperative Programming

• Thinly veiled abstractions of the underlying and pervasive computing architecture

• Shared state and serial execution of instructions

• Thank, and blame, Alan Turing (1936) and Jon Von Neumann (1945)

Page 10: Reactive meetup 0 copy

Functional vs. Imperative• Imperative

• focus on steps or instructions and associated states

• computation is statements that change state

• Functional

• focus on composition and arrangement of functions

• computation is mathematical functions

• avoids state and mutable data

Page 11: Reactive meetup 0 copy

Lambda Calculus

• Emphasis on functions or “software” independent of the underlying hardware

• Variable binding and substitution

• Computation by substitution and reduction

• Anonymous functions == lambda expressions

Page 12: Reactive meetup 0 copy

Common Features of Functional Languages

• Immutability

• Message Passing

• Actors and Concurrency

• Composition

Page 13: Reactive meetup 0 copy

Reactive Constructs in Scala

• “Event-Driven” - case classes, pattern matching

• “Scalable” - actors, promises, futures

• “Resilience” - futures (may never return or might return success/failure primitives), options (case object for non-existent values), supervisors (via Akka)

Page 14: Reactive meetup 0 copy

Fractals

• simple definitions

• infinitely complex

• detailed at arbitrary scales

• self-similar

Page 15: Reactive meetup 0 copy

Case Classes

• Definitions of data-holding objects

• Immutable and dependent on constructor args

• Decomposed using pattern matching

!

Page 16: Reactive meetup 0 copy

Actors

• Encapsulated units of consistency

• Operate asynchronously

• Communicate by message passing

• scala - Reactor Trait: act() react {

Page 17: Reactive meetup 0 copy
Page 18: Reactive meetup 0 copy

Traits• Interfaces

• Class definitions with method signatures

• Allow partial implementation

!

!

!

Page 19: Reactive meetup 0 copy

Code

Page 20: Reactive meetup 0 copy

Resources• http://zeroturnaround.com/rebellabs/what-is-

lambda-calculus-and-why-should-you-care/

• http://www.scala-lang.org/old/node/242

• http://www.reactivemanifesto.org/

• https://github.com/pchuck/fractactor

• Coursera: Principles of Scala and Reactive Programming in Scala

Page 21: Reactive meetup 0 copy

Summary• Software is used to model and solve real-world problems

• The world is infinitely complex and unpredictable

• Functional or imperative?

• “Reactive” can mean many things

• Programming Style

• Methodology

• Application Architecture

• General goal is to reduce side-effects, scale, deal rationally with non-determinism and failures

Page 22: Reactive meetup 0 copy

Definitions• Lambda Expressions: ~anonymous functions

• Currying: transformation/simplification of complex functions: f(x, y) = y/x -> f(2, y) = y/2

• Closures: separation of environment and control in evaluation of functions. A Lambda Expression with free variables that are closed or bound.

• Partial Function: f: X ↛ Y computed for X’, over f: X' → Y, where X’ is a subset of X

Page 23: Reactive meetup 0 copy

• Concepts and Theory

• Scala, w/o Akka, all computation, theory

• Real-world Application - Mark

Segue

Page 24: Reactive meetup 0 copy

Reactive Future (talks)• Reactive NoSQL - ReactiveMongo, MongoDB clusters and

replicasets

• Data Visualization - Reactive rendering of complex and dynamic datasets with Scala and D3

• Horizontal Scale - Reactive load balancing and fault tolerance with Amazon AWS and Elastic Load Balancing

• Reactive tools and techniques in imperative languages: Java or C#

• Reactive programming in other functional languages: Erlang, Haskell, Clojure, F#, Lisp

• Interest areas, suggestions?