If you're a JavaScript developer, you're very
familiar with callbacks.
Yes, some people started moving towards promises
but, they're fundamentally just a wrap around
callbacks.
And callbacks are very primitive concurrency
system.
A problem you may run into is an ordering
of callbacks with the global state since pretty
much everything in JavaScript uses global
state in some way, shape or form.
The order in which callbacks execute can be
crucial.
The problem is if you have N callbacks, you
have 2^N orderings.
So if you have 10 callbacks, for example,
that could execute in an arbitrary order.
There are 1,024 possible ways that [inaudible
00:00:47] order and that grows exponentially,
so if you add a 11th, if you're having 1,024
you have 2,048.
As you can imagine, those orderings go up
real fast.
So, it's entirely possible that you could
have some issue that pops up in one specific
ordering.
Now, again, if you have 10 callbacks, you
have 1,024 possible orderings so it's possible
that, perhaps unlikely but possible, 1,023
of those orderings work fine, and the 1,024th
doesn't.
Problem is finding it.
And that's really hard.
There is no good way to do that beyond exhaustively
checking everything.
And even doing that is hard, because you need
to conspire to somehow force them into each
unique ordering.
This creates to what we refer to as a [Heisenbug
00:01:45] after the Heisenberg uncertainty
principle, which states that observing something
disrupts its behavior and often putting in
observation putting in observation code will
disrupt the ordering and fix your bug for
you until you take it out.
In Elm, we don't have callbacks.
What you have are events.
Now, events can still happen in arbitrary
order, [inaudible 00:02:09], but since the
global state can only change in constrained
ways, it makes things much simpler to debug.
So callbacks can be very tricky, especially
if you make some assumption about which order
they will happen in.
Because unless you explicitly create the order
of them, the order they happen in is effectively
random and unpredictable.
