Eric Siegel

The Stinky Programming Language



Welcome to Stinky, the language that can do fractals using only 4 commands, and make artistic doodles on your web page.

NOTE (11/02/06): You must use Mozilla Firefox browser -- At this time I am seeing the Java applets that make Stinky work no longer run on Explorer, but Firefox is showing them no problem.

Check out the Stinky Hall of Fame for award-winning student-made doodles.

Also check out some nice Stinky fractal demos.

Well, Stinky was this kid in high school who was bullied by the football team. They would force him to stand on the football field as they yelled out commands to him. "Hey Stinky," they would scream, "Take a step forward!" Then they'd tell him to do other things like turn right 30 degrees, and take another step forward. Stinky had to do exactly what they said, which was very humiliating.

However, Stinky was redeemed in two ways. First, he carried a huge felt-tip pen with him and drew lines with every step he took. As it turns out, the instructions provided by those football players actually caused Stinky to draw some pretty interesting patterns, if you climb up to the top of the flag pole to take a look at the football field from a bird's-eye view. These patterns are called Stinky doodles. Second, Stinky later changed his name to Bill Gates and now all the football players have to clean his pocket protectors and complement him on his brain size.

Well, that's not really a true story, but my high school buddy-turned-Java guru Alexander D. Chaffee maintains www.stinky.com, where you will find The Stinky Artists' Collective, which "is dedicated to promulgating and supporting the work of artists and writers who are truly stinky." Stinky doodles are now an official part of this archive.

There is nothing stinky about the Stinky programming language. A Stinky program is simply a list of commands seperated by spaces, such as "step right step". These commands control Stinky as he walks around your screen drawing a line. You are commanding him where to walk. On your screen you will not actually see Stinky himself, but you will see what he drew (he moves so fast you can't see him).

The only four commands that are absolutely needed are:

(Actually, since you can turn right 30 degrees by turning left 11 times, technically you only need three commands.)

Stinky starts at the upper-left hand corner (of the football field) facing to the right. The first command should normally be (at least one) reduce since otherwise his first step will be too big. Therefore, the program "reduce step right step" will cause Stinky to do the following:

Since each turn is 30 degrees, three turns in a row can make a 90 degree turn (i.e., a right angle). For example, the program " reduce reduce step right right right step left left left step" produces:

Here are some optional commands to help add variety to Stinky's world:

So here's a pretty complex example:

OK, the bad news is that writing "Stink" took me a lot of commands: "red reduce reduce reduce step right right right right right right step left left left step left left left step right right right step right right right step left left left left left left step toggle blue step toggle left left left step step left left left step right right right right right right step step right right right green step step left left left toggle step toggle left left left step step right right right right right step step left left left left left step step right right right toggle yellow step right right right toggle step step right right right right right right step right step right right right right right right step left left step step"

But the good news is that long is not necessarily difficult. First of all, it is long because every time I wanted to turn around 180 degrees I had to do 6 rights (or lefts) in a row. Second of all, I think you'll find it easier to design your own picture than trying to understand this one! The general strategy you will want to follow is start Stinky with a couple steps, see what the picture looks like, then add a few more commands, check it again, add some more, etc.

Keep in mind that if Stinky goes off the side of your window, he'll keep doing what he is told, but you will only see the results of what he does in his alloted space in your window. (If he goes off and then comes back on again, that will still work.)

Now you probably want to check out the instructions to create your own Stinky program.

Now, there is one more Stinky command, push. Note: this command is not needed for 1001 HW2 Part III.

The push command makes Stinky start the program over at the beginning, but with the current position, orientation and step size. After finishing, it will then come back and finish the current run of the program. In computer programming talk, this is called a recursive call. It is a very difficult advanced programming concept that will not be covered any further here.

With the addition of push we can create fractals such as:

This cool triangle thing (called "Sierpinsky's Triangle") was created with the following program: " cyan step right right right right blue step right right right right red step right right right right reduce push step push right right right right step left left left left push"

This program may look pretty long, but if you compare the number of commands to the number of lines that were drawn, you'll see that the program is actually relatively short!

booger@stinky.com
(Eric's other email address that actually works.)