Game of Life in Postscript
smashr writes "It never really occured to me that postscript could be used for something other than printing, until I came across this page. Evidently someone has written the classic 'Game of life' entirely in postscript. You can even send it to the printer and have it output every single iteration.. now that would be a fun prank."
Sad memories of being a nine year old loser are flooding my brain at the mere mention of "The Game of Life".
I find it impressive that a technology that's been around since 1985 is not only still usable, but it's used almost everywhere for printing and is also an extremely powerful language. If only more technology was created this way these days. Definitely a testament to the people who created postscript...
using namespace slashdot;
troll::post();
Didn't someone write a webserver in postscript?
:)
Anyway, most people know script it turing complete - this is hardly the greatest hack ever
But it's cool - i'm not being negative.
Ok, someone write an OS in it.
PS-HTTPD - a webserver in PostScript.
Marxism is the opiate of dumbasses
True. In fatc, it's a stack-oriented programming language (like Forth). When Apple released the original LaserWriter in the mid-80s, it was actually the most powerful *computer* they made at the time (next in line was the Mac Plus -- remember those?).
Time flies like an arrow. Fruit flies like a banana.
If you like this sort of thing, check out the PostScript Fractals page. You can print out very detailed images from tiny PostScript files.
%!PS-Adobe-1.0 EPSF-10. % PS GoBan (c) 1996 by Laurent DemaillyD /f{fill}D/S{setgray}D .5 M 1 0 arc gsave f R .5 S s c M e c M e .3 M 270 360 arc s R}D 0 0 x 2 M 1 0 arc .9 .7 .5 setrgbcolor f s 0 S c c x{d
%%BoundingBox: 0 0 150 150 % *** http://www.demailly.com/~dl/go/ ***
/D{def} def/d{dup}D/e{exch}D/s{stroke}D/l{lineto}D/M{mul}
/R{grestore}D/m{moveto}D/z 9 D/c 15 D/x z c M D/p{42 sub d z mod 1 add e z idiv
1 add gsave 1 index c M 1 index c M c
c
c m d x l d c e m x e l}for s(BeJR\\IHP>=6U){p}forall 1 S(?TS[QcGZFOC){p}forall
I've never used it, but you're talking about PS-HTTPD.
Pretty cool, eh?
--
the strongest word is still the word "free"
How about a PostScript ray tracer?
Since it's Turing-complete, technically you could port an x86 emulator to it, and boot Windows in Postscript. In practice, of course, it would be insanely slow, but on a fast enough machine you could play Doom or Quake. 60ppm printer -> 1 fps ;-)
Postscript isn't just used for printers, either. NeXT used Display Postscript for the GUI, so applications were truly WYSIWG: the printer and the screen were rendering precisely the same source! Apparently this was one of the NeXT features which was inherited by Mac OS X, in modified form: parts of the GUI use Display PDF in much the same way.
I wrote a program that substitutes occurances of one string with another one. You send it to the printer than laugh as everyone else's pages mysteriously have the word "this" replaced with "that". One time I loaded it on just before a friend printed his source code. He couldn't figure out for the life of him where his semicolons had gone! Ah... youth.
The best part is, the code stays resident until the printer is power cycled. This enables slightly more sinster uses for this sort of thing. One of my professors used to joke about using as program like this to change the numbers on his paycheck when it was being printed!
The code is still on my website near the bottom. It's called PSReplace.
As other people have pointed out, it's useful to have a fairly powerful language in a printer since it allows the printer to adapt the printed stuff to the paper size and so forth (no pun intended).
Another language that is very closely related is pdf; as I understand it, it's pretty much postscript with a few cludges on the side to make it run faster.
-WolfWithoutAClause
"Gravity is only a theory, not a fact!"- You can send the graphical data in a very compact form, vectors and compressed bitmaps (the Apple drivers could compress bitmaps in JPEG and would transmit a JPEG decompresser postscript program).
- You can transmit your own data format. Instead of transforming your data into "real" postscript, you send a set of postscript procedures that reproduce the behaviour of your graphic language. This was actually one of the primary requirements of postscript, something that could handle quickdraw (Apple's graphic language pre OS-X) reasonably well. DVI2PS does a similar trick.
- You can factorise out common data. For instance you could transmit a form once, and then only send the data to fill out multiple versions of the form.
- Pre-loading - you can upload common fonts to the printer, this saves you the time of including them in all jobs. Some high-end postscript printer even have hard drives to store those fonts.
- Precision handling - instead of calculating word justification on the computer, you send a procedure to calculate word positioning to the printer, this ensures that justification is done using the printer's font metrics and knowing the printer's resolution.
- Special handling and configuration. Special printer configuraton can be handled using postscript. For instance on certain printers, the user has to enter a PIN to trigger output. This is very usefull for sending sensitive documents to shared printers.
- On the fly reconfiguration - for instance you can reprogram the printer to do 2-up or 4-up printing quite easily.
This design made a lot of sense when postscript printers started, bandwidth to the printer was bad (serial, parrallel or localtalk) and processing power on the machines was low - in fact it was common to have a laserwriter II (68020) attached to a classic 9' macintosh (68000).Even nowadays this design makes sense for network attached shared printers - this ensures that page composition is not tied to the client machines. Also you have to realise the bitmap of printing page is quite large: an uncompressed A4 page 300 DPI black/white bitmap is around 15MB. Today's laser printer support 2400 DPI, that means nearly a Gigabyte per page.
Install Ghostscript first, then use GSView to open the .ps files.
By the mid-90s, Xerox had written what was basically a SmallTalk interpreter using GhostScript. It was called DocuScript.
With that, Xerox wrote all sorts of applications for hallway copiers, including web browsers, hang-man games, and image processing/manipulation applications.
Take a piece of paper with an image you want to copy. Circle the image. Scan it. Take a piece of paper that you want the image on. Mark where the image goes. Scan the paper. Output: new piece of paper with the image from the first on it and the other elements from the second piece.
Ooops, you dropped 200 pages of a paper on the floor, and you have gathered it up in the wrong order. Circle the page number on the first page of the paper. Scan the entire paper in. Output: your paper now resorted according page number.
Go to a hospital and triage yourself by taking a printed image of the human body and circling on the image where you hurt and scanning it in to the hallway copier.
Take your 100 page paper and scan it into the hallway copier. Get a one page token in return (containing, basically, an encoded URL) Fly across country to a conference holding only that one page token. At the conference scan in your token. Output your 100 page paper.
And then, being Xerox, they found they couldn't/wouldn't/didn't want to sell it. Talk about the Game of Life!
Conway's Game of Life is also turing complete; therefore, you can regard this PostScript hack as proof that PostScript is turing complete as well, since you could implement a turing machine on top of Life, on top of PostScript..... :)
pb Reply or e-mail; don't vaguely moderate.
...is anyone concerned about the image of the tech community and finding more realistic ways to demonstrate the creativity and resourcefulness of nerds?
I once spent a day with a guitarist of immense talent. He spent countless hours with his instrument, but not making music...it was all just pointless scales, arpeggios, chord progressions around the cycle of fifths...not one bit of actual music did he perform. Sure, it was amazing to watch, but I couldn't understand why he was wasting his immense muscial intellect with such mundane exercises.
I wonder where he got the talent. Must have been a gift from god. It surely couldn't be that tireless practice of one's art leads to mastery, and that anything that helps one make practice fun aids in one's journey towards eminence in one's field...nope, no way.
The "cue the foo posts in 3, 2, 1..." posts will commence with no subsequent foo posts in 3, 2, 1...
The best source about PostScript as a programming language is book "Thinking in PostScript" (http://www.rightbrain.com/pages/books.html).
I read it originally to learn PostScript from a printing perspective, which was somewhat futile. Very little of the book actually talks about printing or page layout at all.
Anyhow, a quick read of the table of contents would be enough to understand that the Game of Life in PostScript is neither difficult nor terribly interesting.
c.
Log in or piss off.