Chapter 5. New concepts

 

This chapter covers

  • The von Neumann machine: a stored program computer architecture
  • Compositionality—what it is and why it’s important
  • Immutable values and immutable data structures
  • Clarity of intent
  • Cheap abstraction

You’ve seen a practical example done in FRP style. In chapter 1, we said that a new way of thinking will help you get the most out of FRP. In this chapter, we’ll continue breaking that down.

5.1. In search of the mythical von Neumann machine

In this section, we’ll explain what the von Neumann machine is and why it’s the source of some assumptions that not only are unhelpful in programming but also turn out to be largely false. The “stored program” computer architecture (see figure 5.1) has served us well since John von Neumann described it in 1945. It’s the basis for the modern computer: the processor reads the program instructions from memory and executes them, giving rise to the manipulation of data in memory. The memory and processor are separate entities, connected by a bus.

Figure 5.1. von Neumann “stored program” hardware architecture

Now we’re going to demonstrate some performance characteristics of a machine that don’t quite fit the von Neumann picture. A singly linked list is a sequence of nodes where each item contains a reference to the next item in the list. Many languages provide linked lists as part of their standard library. We’ll give the example in C because it’s close to the underlying machine instructions.

5.2. Compositionality

5.3. Lack of compositionality illustrated

5.4. Compositionality: eliminating whole classes of bugs

5.5. Don’t pull out the rug: use immutable values

5.6. Clarity of intent

5.7. The consequences of cheap abstraction

5.8. Summary