Hard Tweets Explained: Finite State Machine

Let’s start with a literal interpretation. If the continent could produce states forever, it would be an infinite producer of states. So it would be an infinite state-making machine. But eventually we used up all the space, so it was a finite state-making machine, or finite state machine.

The reason this is ahem “funny” is because Finite State Machine is a term of art in computer science. That is, it is computer jargon for a particular way of writing a computer program. You model the behavior of the system by listing all the states that it might be in. There is a limited number of these, and hence, “finite.” Then you work out under what conditions it will transition from one state to another.

For example, suppose you are writing a program that scans a text file line by line, and prints any section bounded by a three dashes. This program would start in a state “looking for dashes”. When you are in this state if you see the dashes, you transition to the state “printing stuff”. When you are in this state you print each line you see, and check to see if you see dashes again. When you see the dashes, you transition to back to the “looking for dashes” state. There are just those two states in this machine.

FSM for your Vibrator

FSM for your Vibrator

Finite State Machines (often abbreviated FSMs) are useful for building programs that are extremely robust. Often you can represent the states as rows in a table, and the inputs as columns, and the transitions in the cells of the table. That allows you to write a very simple program and then do all your programming by filling in the table. It’s easier to be certain that a table is correct than it is to get that certainty about a program, so this technique is often used in systems that are mission-critical like your car stereo or the microcontroller in that fancy three-speed vibrator you just bought.

Homework: Try to reach orgasm with your vibrator while simultaneously thinking about the fact that there is a FSM micro controller program involved.


Hard Tweets Explained: Nature Boy

This is one of a series of tweets I did experimenting with pseudocode poetry. That is, poetry written in the language we use to define computer programs. You’ve probably heard of programs referred to as “code.” Pseudocode is the same idea, except we aren’t writing in any particular computer language.

When you think about it, pseudocode is a really weird idea. It would be like writing the first draft of your essay in a made-up language, and then translating it to English to polish it up. It isn’t like that, actually. It is exactly that. Computer Scientists are a weird lot.

So anyway, I was thinking it might be fun to try to write poems in pseudocode. I thought the freedom from syntax and language might be liberating. To work through the experiment, I picked a poem that had already been written. It is the lyric to a song called Nature Boy.

The greatest thing
You’ll ever learn
Is just to love
And be loved In return.

I’m not sure that’s actually true. I think the greatest thing you’ll ever learn is probably the exact location of, and optimal stimulation for, all of your partner’s erogenous zones. But this love thing is probably a close second.

nature_boy ::= this funny equals sign is a pretty common pseudocode way of saying “is defined to be.” So we are defining nature_boy, which you recall was the name of the song.

learn > x ∀ x That upside-down A is the formal logic symbol for “for all values of.” So the right side of this inequality says “x for all values of x.” Which is a silly way to say “everything.” So learn greater than everything. That must make learn very large indeed. Perhaps the greatest learn there is.

→ ∃ love The arrow is the formal logic symbol for implies. The backward E is the formal logic symbol for “there exists.” So this says implies there exists love. Which is a peculiar way of saying “is just to love.”

∩ return(love) The upside-down U is the logic symbol for intersection. Intersection in Boolean logic is also the “and” operation. Finally, we have the return statement of the function. This is what the algorithm should emit to the caller, and of course, what we want to emit is love. So this is my way of expressing “and get loved returned.”

Homework: Go visit delict.us/alfageeek and search for pseudocode. See if you agree that this pseudocode poetry idea was a really bad one. Hey, if all our experiments succeeded, we wouldn’t be doing science, would we?