4. Reactive programming is...
● Event-driven
● Scalable
● Resilient
● Responsive
(the definition via the manifesto, anyway)
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. 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. 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.
15. RxJava
“a library for composing asynchronous and
event-based programs using observable
sequences for the Java VM”
16. My translation:
RxJava
A library for composing behaviors
applied to event streams.
note: when I say behaviors, think
referentially-transparent functions.
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
29. Actors (the Actor model)
Defined by three traits
● a behavior (reacts to events)
● an state model
● send/receive (immutable) messages
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. Actor System
● actors interact
● actors exist together within an actor system
● the system defines the outermost bounds
32. Akka
● Scala-based actor model toolkit
● Provides a lot of extras
● We won’t be talking about those
33. Akka
● Supervisors
○ provide exception handling
○ “let it crash”
○ orthogonal to actor behavior
● Location transparency
○ abstracts the idea of “where” an actor lives
34. Akka
● Mailboxes
● Routing
○ e.g., round-robin, smallest mailbox, etc.
● Dispatching
○ essentially how to allocate thread resources