COOPERATIVE MULTITASKING
WITH GENERATORS

(please sit up front)

Hi, I'm Chris

We spend a lot of time waiting...

...But we can write asynchronous code.

Arrays

Array-likes

Iterators

Talk about generators!

Reading files

Sorting

Pure functions are like

data tables...

a + b a - b
a = 5, b = 4 9 1
a = 10, b = 10 20 0
0 1 9 20
a = 5, b = 4 ... a - b a + b ...
a = 10, b = 10 a - b ... ... a + b

Task manager

Generators can be used as interruptible functions

Otherwise known as coroutines

Asynchronous architecture in about 65 lines of code

Meet AMPHP

amphp.org

Amp

Amp

Meet Recoil

github.com/recoilphp/recoil

Recoil

Async/await

Thanks

twitter.com/assertchris

slides.com/assertchris

joind.in/talk/80019

Cooperative Multitasking with Generators

By Christopher Pitt

Cooperative Multitasking with Generators

Have you ever used the yield keyword? It's the hidden-wardrobe-entrance into a magical world of generators. This magical world is inhabited by beings called iterators and coroutines. Roll some epic battle-music...

  • 1,640