The topic of State Machines is one of the most fascinating ever. It allows us to become better programmers by offering a simple but powerful way of th

Abdur-Rahmaan’s Substack

submited by
Style Pass
2023-03-17 10:00:02

The topic of State Machines is one of the most fascinating ever. It allows us to become better programmers by offering a simple but powerful way of thinking. It has always been (unfortunately) associated with compiler theory and is always learned in boring textbooks (and weird animals like dragons and tigers). This post provides a tangible example to understand the topic that can be followed by even a child. Promise.

You can also replace the head with you and a pencil at this point. You read the values, move the pencil and use it to modify values.

Using a piece of paper we can have instructions for the machine. For each scenario, we can think of what to do with the pencil when there is a particular symbol. What to do if there is a 1, what to do when there is a 0 or a blank, and where to move.

But then what? We are stuck. That’s why we also need to point out the next scenario so that we can get a continuous set of instructions.

Leave a Comment