Introducing Typomatic

What is Typomatic?

Typomatic is a typographic automatic computer.

Huh?

Okay, bear with me here...

A quick intro to computation

What does it mean to compute something? Roughly speaking, it means to manipulate information by following a routine. That’s a pretty vague definition, but there are lots of ways to make it more concrete. One of the simplest ones was invented in the 1950s by a Russian mathematician named Andrey Markov Jr.

In Markov’s model, "information" means a string of symbols, like this:

oo<<

A "routine" is described by a table like this:

fromto
+<<+
o<<+o
<
o

Each line in the table describes a rule for manipulating the string. To apply a rule, you look through the string from left to right until you find a piece that matches the thing in the from column. Then, you replace that piece with the thing in the to column. Here’s how you’d apply the second rule in the table above to the string I mentioned earlier:

From this...to this!
oo<<o<+o<

Sometimes, of course, the thing in the from column doesn’t match any piece of the string. In that case, the rule can’t be applied.

To follow the routine described by a table of rules, you look through the table from top to bottom until you find a rule you can apply. Then you apply that rule, go back to the top of the table, and start again. Eventually, if you’re lucky, you’ll get to a point where none of the rules can be applied. Then you’re done!

Here’s what happens when you use the rule table above to manipulate the string I mentioned earlier. The first step should look familiar:

StepFrom this...to this!Rule
1oo<<o<+o<2
2o<+o<<+o+o<2
3<+o+o<<+o+<+o2
4<+o+<+o<+o<++o1
5<+o<++o<+<+o++o2
6<+<+o++o<<++o++o1
7<<++o++o<++o++o3
8<++o++o++o++o3
9++o++o++++o4
10++++o++++4

At this point, none of the rules can be applied, so you’re done! As you bask in the warm glow of accomplishment, however, you may begin to wonder what it is that you’ve accomplished. Literally speaking, all you’ve done is turn the string "oo<<" into the string "++++" by shuffling symbols around. When you look at it in a certain way, though, the game you just played takes on a deep significance.

I could tell you what that significance is, but it’s more fun if you figure it out for yourself. A good way to start is to see what happens when you use the rules above to manipulate the following nine strings:

o<o<<o<<<
oo<oo<<oo<<<
ooo<ooo<<ooo<<<

Unfortunately, all that symbol pushing is going to get tedious pretty quickly. It would be nice if you had a machine that would apply the rules for you, so you could concentrate on understanding what’s going on. That’s where Typomatic comes in.

Computing with Typomatic

Let’s use Typomatic to carry out the string manipulation we did by hand in the previous section.

First, we need to put our table of rules into a format Typomatic can understand. Make a text file containing the following four lines:

+<<+
o<<+o
<
o

Save the file as rules.typo, or something like that (the .typo extension isn’t necessary; I just use it to label Typomatic source files). Each line of the file describes a rule, with the from and to parts separated by a single tab or space character. You can use any Unicode character except tab and space in your rules. Blank lines and lines starting with two tabs in a row are ignored, giving you a way to break your code into sections and write comments.

Start Typomatic using the command

java -jar Typomatic.jar

(In some desktop environments, you may also be able to start Typomatic by double-clicking the file Typomatic.jar.)

There are two text boxes at the top of the Typomatic window, labeled Source and Input. Clicking the ... button to the right of the Source box will open a file chooser; use it to find the source file rules.typo. When you click Open, the message box at the bottom of the screen should say "New rules loaded." (You can also type the location of the source file directly into the source box, and load the file by pressing enter.)

Type the input string oo<< into the Input box and press enter. The input string will appear in big characters in the middle of the Typomatic window.

If you press the down arrow key, Typomatic will start manipulating the string in the middle of the window by applying the rules you loaded from the source file. If Typomatic gets to a point where none of the rules can be applied, it will stop automatically. You can stop Typomatic yourself by pressing the down arrow again. You can also use the right arrow to apply one rule at a time.

If Typomatic doesn’t seem to respond when you press an arrow key, try clicking on the string display in the middle of the Typomatic window to bring it into focus. If that doesn’t work, check the formatting of your input file: if a rule is formatted wrong, Typomatic won’t apply it in the way you expect. Finally, remember that string manipulation routines can be confusing. Make sure there really is a rule that ought to be applied!

Computing with Typomatic like a boss

Now that you’ve got the hang of Typomatic, let’s check out its wicked cool advanced features.

Stopping rules

You can use the kind of routine you’ve seen so far to do extraordinarily sophisticated computations, but some simple tasks are disconcertingly out of reach. For instance, there’s no routine that will turn whatever string you start with into the same string with a single & stuck on the front, and then stop. That’s because I forgot to tell you about a tiny but essential piece of Markov’s model of computation: stopping rules.

The table you use to describe a routine is allowed to have a third column, like this:

fromtostop?
~xx~
~oo~
~]%
[~
Every time you apply a rule, you check for a % mark in the stop? column. If you see one, you don’t bother going back to the top of the table and looking for another rule to apply. You’re done! A rule with a mark in the third column is called a “stopping rule,” and you can have as many of them as you want.

To mark a rule as a stopping rule in a Typomatic source file, just add a % character in a third column, separated from the to column by a single tab or space character. When Typomatic applies a stopping rule, it automatically stops running. You can start it again by pressing the down arrow or the right arrow. If you’re using the right arrow to apply one rule at a time, stopping rules won’t have any noticeable effect, because Typomatic would have stopped after one rule anyway.

Sounds and colors

Stopping is the most computationally important thing you can make Typomatic do when it applies a rule, but it isn’t the most entertaining. You can make Typomatic play a sound when it applies a rule by adding a fourth column with one of the six sound symbols:

. + / $ # *

You may have noticed that when Typomatic applies a rule, the piece of the string being replaced flashes white for a moment. You can make the flash a different color by adding a fifth column with one of the six color symbols:

p o y g b v

As usual, columns are separated by a single tab or space character. If you put two separators in a row, Typomatic reads a blank column in between.

Tempo control

Typomatic applies rules on a steady beat, at a default speed of 240 beats per minute. You can make it go faster or slower by pressing the arrows next to the Tempo box in the top right corner of the window. The tempo changes in increments of 60 bpm, up to a maximum of 480 bpm. If you change the tempo while Typomatic is running, Typomatic will stick to the tempo that was showing when you pressed the down arrow. You can make Typomatic switch to the new tempo by hitting the down arrow twice to stop it and start it again.

Fast mode

Someday, you’ll want to do a computation so long that even the maximum tempo feels glacial. When that day comes, it’s time for fast mode.

See that button to the right of the Tempo control? If you haven’t clicked it yet, it says >, which means you’re in slow mode. Load a fresh input string and click the slow mode indicator. The > will change to >>>, and the string display will be replaced by the number zero. You’re in fast mode.

The right arrow is now inoperative: you don’t go into fast mode to apply one rule at a time. Hit the down arrow instead. The number in the middle of the window will start scrolling upward: Typomatic is applying rules as fast as your CPU can manage, and counting how many rules it’s applied. As usual, Typomatic will stop automatically if it gets to a point where none of the rules can be applied, and you can stop it yourself by pressing the down arrow again.

Unless you’re doing a very long computation, however, you’ll never get a chance to stop Typomatic yourself: on typical hardware, Typomatic will often finish a hundred-step computation faster than your photoreceptors can even start reporting a flash of light. You’ll just see the counter jump to some number and stop there. To see what you’ve accomplished, click the >>> to switch back into slow mode. The string display will appear again, showing the result of your computation. While Typomatic is stopped, you can toggle between fast mode and slow mode as many times as you want; when you hit the down arrow again, Typomatic will pick up where it left off, using whatever mode it’s in. You can’t switch modes while a computation is running.

You can do anything

With Typomatic on your side, you can do any computation that can ever be done, and make silly noises while you’re at it. All you need is patience, practice, and a little ingenuity. Go crunch some strings!