Chapter 10. Battle of the paradigms
This chapter covers
- One example (drag-and-drop) in three paradigms
- Comparing the merits of classic static machine vs. FRP vs. actor model
- Adding a feature to see how each approach copes
As you may have gathered, FRP is awesome. But for some tasks, the level of awesome is more limited, and other paradigms do a better job.
Drag-and-drop is a common task that fits FRP pretty well, but two other paradigms—classic state machine and the actor model—also do a nice job of it, for different reasons. We want you to understand why this is so you can make the right choices in your code.
Figure 10.1 presents the same simple drag-and-drop example written in three different paradigms: classic state machine, FRP, and actor model. FRP and actor both require immutable data structures, but even when those aren’t required, they’re always a good idea. The polygons are called Elements, and you contain them in a Document.