streaming text

Now we know how to represent text as marbles, let’s look at practically implementing it.

This board contains the string “yes” written left-to-right, top-to-bottom:

00/0000/00
loading…

yes static

This isn’t very practical — look how much space this takes up. Also, any device that takes in this data is going to need to be at least 5 cells wide as well.

Instead, we’re going to send the bits of our text as a stream.

00/0000/00
loading…

yes stream

Each marble or hole arrives one at a time. The text “flows” through our system like water through a pipe.

definition

A stream is a sequence of items (such as letters) that arrive one at a time.

We’ll use streams a lot in developing our devices. They have some features that make them perfect for :

  • They allow us to connect multiple devices together, like how plumbing lets water flow from a pump into a shower.
  • They’re compact. We don’t have to hold the whole stream at once — we can process each item one at a time, then throw it away to make space for the next one.
  • They allow parallel work. As soon as we receive the first item, we can start doing stuff with it. We don’t have to wait for the entire stream to finish before we can do anything.

This is the same principle as streaming video over the internet. Instead of sending the data all at once, it arrives bit by bit. This means you can start watching it without waiting for the entire thing to arrive, and your computer doesn’t ever have to store the entire video.

what’s next?

It’s time to recap our progress, and start looking at what else our computer needs.

continue