data When one thing changes, the programmer must update everything that depends on it. Done by hand, this is a tedious and error-prone task. Long story…
imperative operations in response to events. Coordination within the resulting “callback soup” can be difficult, since numerous isolated code fragments end up manipulating the same data. Long story…
a list of the squares of sequential integers starting at 1 you can replace the words in that sentence with their definitions, and not change the meaning
and how to track changes in state. What information is desired and what transformations are required. State changes Important Non-existent. Order of execution Important Low importance. Primary flow control Loops, conditionals, and function (method) calls. Function calls, including recursion. Primary manipulation unit Instances of structures or classes. Functions as first-class objects and data collections
and how to track changes in state. What information is desired and what transformations are required. State changes Important Non-existent. Order of execution Important Low importance. Primary flow control Loops, conditionals, and function (method) calls. Function calls, including recursion. Primary manipulation unit Instances of structures or classes. Functions as first-class objects and data collections
Increased readability and maintainability -> each function is designed to accomplish a specific task given its arguments. The function does not rely on any external state. • Easier reiterative development -> the code is easier to refactor • Easier testing -> pure functions can more easily be tested in isolation, you can write test code that calls the pure function with typical values, valid edge cases, and invalid edge cases.
(callbacks/listeners) • A composable, modular way to code event-driven logic. • A way to bring order to the management of program state • A different way of thinking: The program is expressed as a reaction to its inputs, or as a flow of data.
composable, modular way to code event-driven logic. • A way to bring order to the management of program state • A different way of thinking: The program is expressed as a reaction to its inputs, or as a flow of data. What it IS what’s wrong with this?
order in which events are received can depend on the order you registered the listeners in. FRP makes the order not matter in most cases, and it makes it predictable in the rest. • Missed first event -> It can be difficult to guarantee that you have registered your listeners before you send the first event. FRP is transactional, so it is possible to provide this guarantee. • Messy state -> Callbacks push your code into a traditional state machine style, which gets messy fast. FRP brings order. • Threading issues -> Attempting to make listeners thread-safe can lead to deadlocks. FRP eliminates this issue. • Accidental recursion -> The order in which you update local state and notify listeners can be critical, and it's easy to make mistakes. FRP eliminates this issue.
on flat pasta on cheese sauce on bolognese on flat pasta on cheese sauce on bolognese on flat pasta on cheese sauce baked for 45 minutes. • Bolognese is onion and oil fried until golden mixed with ground beef mixed with tomato simmered for 20 minutes. • Cheese sauce is milk and cheese added progressively to roux while frying it until the sauce thickens. • Roux is flour and butter fried briefly. • Baked is put in an oven dish in a hot oven. • Fried is put in a pan on high and mixed frequently. • Simmered is put in a pan on low and mixed infrequently. The a-ha! moment
on flat pasta on cheese sauce on bolognese on flat pasta on cheese sauce on bolognese on flat pasta on cheese sauce baked for 45 minutes. • Bolognese is onion and oil fried until golden mixed with ground beef mixed with tomato simmered for 20 minutes. • Cheese sauce is milk and cheese added progressively to roux while frying it until the sauce thickens. • Roux is flour and butter fried briefly. • Baked is put in an oven dish in a hot oven. • Fried is put in a pan on high and mixed frequently. • Simmered is put in a pan on low and mixed infrequently. The a-ha! moment