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."
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.
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.
%!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
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.
Another nice little postscript program can be found here
It's only about 10 lines long and creates a image with 2 bubbles and even reflections.
And if someone wants to learn Postscript:
A first Guide to Postscript
PostScript survived because of its imaging model, which was far better than anything else around at the time. The PostScript language only survived because of the imaging model; the language itself has required numerous workarounds, add-ons, and conventions to make its continued use in printing practical, making it a complicated mess that still doesn't really work all that well as a language.
Adobe has pretty much admitted as much with their creation of PDF. Apple also dumped PostScript for PDF, for the same reasons.
PostScript was an idea worth trying, but a few decades later, we really know that procedural languages do not make good page description languages. The future belongs to standards like PDF and SVG.
That's nothing! In college, my compiler writing course was changed (to help "discourage ``re-use'' of previous years students' code") to writing a C compiler which used *PostScript* as its target language instead of XYZ machine code for PDQ processor.
We took the output of our compiler and "ran" it with ghostscript. It was actually quite fun. One of the harder parts was writing a suitable "libc" to "link" in for basic stdio.
Postscript has an interesting story, actually. The man who invented it had, previously, designed the "language" to be used by Xerox's new laser printers. This was not a real programming language, but was simply a control language. Xerox was nevertheless entirely delighted with it, and paid him a fair amount of money for it. After he had finished this task for Xerox, he then decided to start from scratch and try to build a printer language that was more suited to his vision of what one should be. When he finished, he decided to notify Xerox of his new development (hoping, perhaps, to get another large paycheque from them), but Xerox declined to use it, wanting to stick with his first printer language that they were already beginning to use. He teamed up with someone else and founded the company Adobe, and they called the language "Postscript".
File under 'M' for 'Manic ranting'
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!