Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Reactive Programming
using RxJava & Akka Actors
Thomas Lockney (@tlockney)
PDXScala
June 14, 2014
What is reactive
programming?
Reactive programming is…
● A programming paradigm
● About data-flow
● Not really anything new
Reactive programming is...
● Event-driven
● Scalable
● Resilient
● Responsive
(the definition via the manifesto, anyway)
Reorganizing our thoughts a bit...
● Think in terms of discrete events
● Code in terms of behaviors
○ reacting to events
●...
A brief digression...
Amdahl’s law (paraphrased):
The maximum increase in speed of a program
is limited by the sequential ...
A brief digression...
Amdahl’s law (paraphrased):
If you have a program that runs for 4 hours, but
1 hour of runtime is ne...
Amdahl’s law
The thing about Amdahl’s law
This is death by a thousand cuts.
Every line of code is subject to this rule!
Some principles...
● Keep your data immutable
● Share nothing
● Blocking is bad!
Another brief digression...
● Immutable data structures
● Referential transparency
● First-class functions
… this gives you ...
Once you have:
Functional Programming
well...
Functional Programming
in the small
RxJava
“a library for composing asynchronous and
event-based programs using observable
sequences for the Java VM”
My translation:
RxJava
A library for composing behaviors
applied to event streams.
note: when I say behaviors, think
refer...
Marble Diagrams
Observable
● The “dual” of Iterable
● Or an Observer for sequences
● Somewhat similar to a Future
○ but, again, supports s...
Observable
Basic mechanics
● onNext()
● onError()
● onComplete()
Functional Composition
● map()
● flatMap()
● filter()
map()
flatMap()
filter()
Creating Observables
● Observable.from(...), Observable.just(...),
Observable.range(...), etc.
● Implement the Observable ...
Observer & Subscriber
Observer
● interface for handling Observables onNext,
onError, onComplete
Subscriber
● represents a ...
Demo time!
RxJava is Reactive
● event-based (data-flows)
● scalable*
● resilient* (???)
● responsive* (???)
* - requires some additio...
Akka
& the actor model
Actors (the Actor model)
Defined by three traits
● a behavior (reacts to events)
● an state model
● send/receive (immutabl...
Actors
● messages are processed sequentially
● multiple actors can be working at the same
time
● actors are not threads
● ...
Actor System
● actors interact
● actors exist together within an actor system
● the system defines the outermost bounds
Akka
● Scala-based actor model toolkit
● Provides a lot of extras
● We won’t be talking about those
Akka
● Supervisors
○ provide exception handling
○ “let it crash”
○ orthogonal to actor behavior
● Location transparency
○ ...
Akka
● Mailboxes
● Routing
○ e.g., round-robin, smallest mailbox, etc.
● Dispatching
○ essentially how to allocate thread ...
Demo time!
Akka is Reactive
● event-based
● resilient/fault-tolerant
● easily scalable*
● responsive*
* - requires some additional wo...
Reactive Streams
Reactive Streams
… I wish I had time … ;~)
Ha terminado este documento.
Descárguela y léala sin conexión.
Próximo SlideShare
Reactive Java (GeeCON 2014)
Siguiente
Próximo SlideShare
Reactive Java (GeeCON 2014)
Siguiente
Descargar para leer sin conexión y ver en pantalla completa.

Compartir

Reactive programming using rx java & akka actors - pdx-scala - june 2014

Descargar para leer sin conexión

Audiolibros relacionados

Gratis con una prueba de 30 días de Scribd

Ver todo

Reactive programming using rx java & akka actors - pdx-scala - june 2014

  1. 1. Reactive Programming using RxJava & Akka Actors Thomas Lockney (@tlockney) PDXScala June 14, 2014
  2. 2. What is reactive programming?
  3. 3. Reactive programming is… ● A programming paradigm ● About data-flow ● Not really anything new
  4. 4. Reactive programming is... ● Event-driven ● Scalable ● Resilient ● Responsive (the definition via the manifesto, anyway)
  5. 5. Reorganizing our thoughts a bit... ● Think in terms of discrete events ● Code in terms of behaviors ○ reacting to events ● The system state changes over time based on the flow of events
  6. 6. A brief digression... Amdahl’s law (paraphrased): The maximum increase in speed of a program is limited by the sequential portions of the code.
  7. 7. A brief digression... Amdahl’s law (paraphrased): If you have a program that runs for 4 hours, but 1 hour of runtime is necessarily serial, your program will have at most a 4x speedup with parallelization.
  8. 8. Amdahl’s law
  9. 9. The thing about Amdahl’s law This is death by a thousand cuts. Every line of code is subject to this rule!
  10. 10. Some principles... ● Keep your data immutable ● Share nothing ● Blocking is bad!
  11. 11. Another brief digression...
  12. 12. ● Immutable data structures ● Referential transparency ● First-class functions … this gives you ... Once you have:
  13. 13. Functional Programming
  14. 14. well... Functional Programming in the small
  15. 15. RxJava “a library for composing asynchronous and event-based programs using observable sequences for the Java VM”
  16. 16. My translation: RxJava A library for composing behaviors applied to event streams. note: when I say behaviors, think referentially-transparent functions.
  17. 17. Marble Diagrams
  18. 18. Observable ● The “dual” of Iterable ● Or an Observer for sequences ● Somewhat similar to a Future ○ but, again, supports sequences
  19. 19. Observable Basic mechanics ● onNext() ● onError() ● onComplete()
  20. 20. Functional Composition ● map() ● flatMap() ● filter()
  21. 21. map()
  22. 22. flatMap()
  23. 23. filter()
  24. 24. Creating Observables ● Observable.from(...), Observable.just(...), Observable.range(...), etc. ● Implement the Observable interface ○ explicit calls to onNext(), onError(), onComplete()
  25. 25. Observer & Subscriber Observer ● interface for handling Observables onNext, onError, onComplete Subscriber ● represents a subscription to an observable
  26. 26. Demo time!
  27. 27. RxJava is Reactive ● event-based (data-flows) ● scalable* ● resilient* (???) ● responsive* (???) * - requires some additional work on your end ??? - the story here is not entirely clear or potentially even available in current releases
  28. 28. Akka & the actor model
  29. 29. Actors (the Actor model) Defined by three traits ● a behavior (reacts to events) ● an state model ● send/receive (immutable) messages
  30. 30. Actors ● messages are processed sequentially ● multiple actors can be working at the same time ● actors are not threads ● an actor can block (but should avoid it) ● no shared state
  31. 31. Actor System ● actors interact ● actors exist together within an actor system ● the system defines the outermost bounds
  32. 32. Akka ● Scala-based actor model toolkit ● Provides a lot of extras ● We won’t be talking about those
  33. 33. Akka ● Supervisors ○ provide exception handling ○ “let it crash” ○ orthogonal to actor behavior ● Location transparency ○ abstracts the idea of “where” an actor lives
  34. 34. Akka ● Mailboxes ● Routing ○ e.g., round-robin, smallest mailbox, etc. ● Dispatching ○ essentially how to allocate thread resources
  35. 35. Demo time!
  36. 36. Akka is Reactive ● event-based ● resilient/fault-tolerant ● easily scalable* ● responsive* * - requires some additional work on your end
  37. 37. Reactive Streams
  38. 38. Reactive Streams … I wish I had time … ;~)
  • changhwanhan1

    Nov. 18, 2016
  • LoveHasija

    Sep. 28, 2016
  • vovche

    Nov. 17, 2015
  • DanielZhelyazkov1

    Nov. 2, 2015
  • alexeyshockov

    Oct. 15, 2015
  • ismailover

    Sep. 28, 2015
  • tvhung

    Sep. 24, 2015
  • BerndGtz

    Sep. 14, 2015
  • ClumsyShark

    Aug. 9, 2015
  • ziyasal

    Jul. 13, 2015
  • DejanIli

    Jun. 26, 2015
  • AlbertSerrallRos

    May. 12, 2015
  • yth1

    May. 10, 2015
  • mohanmca

    May. 5, 2015
  • kwangyongkim

    Apr. 21, 2015
  • MartinWeidner

    Apr. 6, 2015
  • unizune

    Feb. 22, 2015
  • joobn

    Feb. 13, 2015
  • tantrieuf31

    Feb. 5, 2015
  • bunkertor

    Feb. 5, 2015

Vistas

Total de vistas

8.966

En Slideshare

0

De embebidos

0

Número de embebidos

280

Acciones

Descargas

183

Compartidos

0

Comentarios

0

Me gusta

33

×