A Modest Proposal – For preventing the technical debt of legacy development from being a burden to their developers or maintainers and for making them beneficial to the publick – Computing through time



A Modest Proposal – For preventing the technical debt of legacy development from being a burden to their developers or maintainers and for making them beneficial to the publick – Computing through time

0 0


a-modest-proposal-presentation

A presentation on the benefits of switching to Functional Reactive Programming

On Github ckknight / a-modest-proposal-presentation

A Modest Proposal

For preventing the technical debt of legacy development from being a burden to their developers or maintainers and for making them beneficial to the publick

Created by Cameron Knight / @ckknight

Computing through time

1950s

  • Single-user
  • Single-process
  • Non-networked
  • Completely synchronous
  • Very technical users
  • Default expectation is success
I predict that within 10 years, computers will be twice as powerful, ten thousand times larger, and so expensive that only the 5 richest kings of Europe will own them

2015

  • Multi-user
  • Multi-process
  • Highly-networked
  • Very asynchronous
  • Non-technical users
  • Unable to assume success

Asynchrony

Why is it important?

Common problems with Asynchrony

  • Memory Leaks
  • Race Conditions
  • Spaghetti Code
  • Complex State Machines
  • Callback Hell
  • Error Handling

Asynchrony is hard

Let's think about it differently

Some definitions

  • Immutable: Unable to be changed after creation
  • Mutable: Alterable after creation
  • Array: A collection of items in memory
  • Event: A collection of items over time
  • Functional Programming: a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.
  • Reactive Programming: a paradigm oriented around data flows and the propagation of change

Cause and effect

Proactive

Cause →         Effect

Reactive

Cause         → Effect

Cause and effect

Proactive

Cause →      (  Effect)

Reactive

Cause        (→ Effect)

Benefits of Reactive Programming

  • Similarity between synchronous and asynchronous collections
  • Rather than treating an HTTP request as different than a mouse drag, they can be seen as similar concepts.
  • 70+ easy utilities for managing observables
  • Mental manageability of complex events
  • Built-in concept of disposability, leading to easy memory management with minimal effort
  • Nice error handling with simple retry/throttle/abort semantics

An example

const searchResult$ = keyPress$
    .throttle(250)
    .map(event => event.target.value)
    .map(query => getJSON('/searchResults?q=' + query)
        .retry(3)
        .takeUntil(keyPress$))
    .switchLatest()

Testing

Summary

  • Avoid Memory Leaks
  • Completely Mitigate Race Conditions
  • Better Maintainability
  • State Machines are now just as simple as f(x) = y
  • Greatly Simplified Error Handling
We can rebuild him. We have the technology. We can make him better than he was. Better, stronger, faster.

Q & A

A Modest Proposal For preventing the technical debt of legacy development from being a burden to their developers or maintainers and for making them beneficial to the publick Created by Cameron Knight / @ckknight