My work, my ideas, my faith, my life

The Pebble, From My Hand Take, Grasshopper

My Programming Autobiography, Part 6

By Rex Goode

Philip Ahn as Master Kan

So, I grew up on the original Kung Fu series. I loved Masters Po and Kan, played respectively by Key Luke and the ever soft-spoken, Philip Ahn. We knew that young Kwai Chang was ready to leave the monastery when he could the pebble take from Master Kan’s hand.You are right if you recognized that I didn’t say that quite right. I started, as many human languages do, with the subject of the sentence, followed by the operation you want performed. Just as I loved C++ because it was a new paradigm in programming, Postscript was like that for me.

Postscript is not object-oriented, no not at all. Yet, it still held a fascination for me because you had to think just a little backwards about it. It is based on an idea called LIFO, which is short for “last-in, first out.” Liken it to a stack of plates in a plate dispenser. When you go to pork out at an all-you-can-eat buffet, you don’t take all of the plates out of the dispenser and choose the bottom one, do you? Hopefully not.

Plate Dispenser

Instead, you take the last one that was put in it, right off of the top. Then, you inspect it for dried-on food and set it aside so you can get the last one that was put in before that. OK, I digress.

Everything in Postscript is kind of like that. You put the data in a stack and then once in a while, you perform an operation that takes the last piece of data off of the stack and does something to it. If the operation needs to pieces of data to work on, as in adding two numbers, it takes the last number off of the stack and then takes the next last number off of the stack, adds them together and leaves the result on the top of the stack. You are confused, aren’t you? Admit it.

Here is an example from the language itself. If, in a language like BASIC, you wanted to represent the sum of 1 and 1, you would write it as:

1 + 1

In Postscript, y0u would write it as:

1 1 add

Please say that you get it.

Even more fun is if you wanted to add many 1’s to each other. In BASIC:

1 + 1 + 1 + 1 + 1

In Postscript:

1 1 1 1 1 add add add add

In both ways, it ends up with the value of 5.

Why in the world, you surely wonder, would you want to do it the latter way? Well, I’m sure there are many practical reasons. The only reason I can think of is because I like having my brain challenged.

Well, that isn’t the only reason. Another reason is that you can do some pretty awesome things with it, like the flyer I use for my social work job. Take a look at an image of it here or see the full PDF.

To be continued in If It’s Worth Doing, It’s Worth Doing.

Be the first to like.

3 Responses to “The Pebble, From My Hand Take, Grasshopper”

  1. Rex Goode » OOP’s! Did I do that?! said:

    […] be continued The Pebble, From My Hand Take, Grasshopper. Like Unlike Posted by Rex Goode under Creativity,Object-Oriented Programming,Software […]

  2. Steve said:

    Ha. Just last night I was writing a program to create these detailed record sheets and all kinds of printery fun stuff… in PostScript, of course.

    I just love the idea of a Turing-complete printer command language (which does far more than commanding printers, of course).

  3. Rex Goode said:

    Steve, I like creating monsters, a piece of this and a piece of that and have in create a program in yet another language. When I do that, if there is any visual aspect to at all, PostScript is bound to be one of the pieces. Of course, if any one that hires people is reading this, I promise I would only do it that way if it was the best way to do it. 🙂

Leave a Reply

If your comment is a support question, please post it at the forums.