Slashdot Mirror


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."

18 of 265 comments (clear)

  1. Webserver by JohnFluxx · · Score: 4, Interesting

    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.

  2. Re:Is it really a game? by Anonymous Coward · · Score: 2, Interesting

    actually, there are versions off it were you can win. its the same as the normal game of life, but 2 players control 2 'species'. each turn they can either place or remove any field, and the one survives wins.

  3. Re:Duh by Captain+Lobotomy · · Score: 5, Interesting

    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.
  4. Go Game in 5 lines of PostScript by _dl_ · · Score: 5, Interesting

    %!PS-Adobe-1.0 EPSF-10. % PS GoBan (c) 1996 by Laurent Demailly
    %%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}D /f{fill}D/S{setgray}D
    /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 .5 M 1 0 arc gsave f R .5 S s c M e c M e
    c .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
    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

    1. Re:Go Game in 5 lines of PostScript by _dl_ · · Score: 3, Interesting
      That is the most obfuscated program I think I have ever seen.
      Thanks ! I'll take this as a compliment because that was the point then: I created this about 7 years ago for a .signature, it shows that PS is a pretty neat programing language and you can express things very compactly. This progam basically can draw any goban and encodes positions of black and white stones on a single character... (See my outdated Go page for other versions)
  5. Ray Tracer by CaseyB · · Score: 4, Interesting

    How about a PostScript ray tracer?

  6. Re:Duh by Cyberdyne · · Score: 4, Interesting
    Postscript is a programming language - so you can 'program' in it... whatever you want. Even something like the game of life. Crazy huh? That's technology for you.

    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.

  7. Raytracing in Postscript by Xonea · · Score: 3, Interesting

    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

  8. Re:Duh by javiercero · · Score: 2, Interesting

    Well, I still do not know why you used Touring completness for your example... I assume you are just reading about it in school, eh? Anyhow, not only NeXT, but the old NEWS distributed windows systems proposed by SUN did infact used postscrip. I believe SGI also implemented a NEWS server... it was overshadowed by X. Although I believe both SGI and SUN did merge X and NEWS together in their display servers....

  9. Re:Wow. by g4dget · · Score: 4, Interesting

    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.

  10. No why? by Anonymous Coward · · Score: 2, Interesting

    I can't believe that tons of people asked why someone would write an HTML browser in Java, but hardly anyone asked why someone would do this?

    Are you guys living in the real world? :)

  11. That's nothing .... by jreynold · · Score: 3, Interesting

    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.

  12. Re:Wow. by mark-t · · Score: 5, Interesting
    Definitely a testament to the people who created postscript
    Person, actually. Postscript was invented by one man.

    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".

  13. Xerox, Copiers with SmallTalk via GhostScript by jerryasher · · Score: 4, Interesting


    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!

    1. Re:Xerox, Copiers with SmallTalk via GhostScript by jerryasher · · Score: 2, Interesting

      Yes and no. I was a bit lazy with that. The URL is apparently the only piece of it easily available through google these days.

      DataGlyphs were the key behind the implementation of many of the features I described.

      For instance if you scanned your 100 page paper in, and got a token back, but what that token was was the URL printed out in nice easily read text as well as easily machine read dataglyphs.

      The hangman game printed out looking like a hangman game complete with head, noose, whatever, but there were also identifying dataglyphs to help the machine recognize this was a hangman game, and which particular hangman game it was.

      There used to be more, including a FLASH presentation, but I can't easily find that through google now.

    2. Re:Xerox, Copiers with SmallTalk via GhostScript by leighklotz · · Score: 4, Interesting

      >And then, being Xerox, they found they couldn't/wouldn't/didn't want to sell it.

      Actually, Xerox did sell it, in Japan, as the DocuStation IM 200. When Java came out, we and otehrs worked with Sun to add the image processing features that were necessary (which became java2d) it was re-written in Java and sold again as FlowPort, and is still sold.

      At the time the choice was made, we were examining Scheme, but felt a lot of resistance from the industrial engineering community we were targeting. So, although I helped develop 6.001 and the book "Structure and Interpretation of Computer Programs" that introduced Scheme, we abandoned that approach and looked for a language that would be more palatable to the printer and copier engineers. The system was written in PostScript because it was an interpreted language that was capable of running inside hardware such as copies, scanners, and printers. There were hired industry pundits who had suggested that we use Visual Basic, but that was even harder to fit into a copier in 1991, so PostScript it was.

      Just as we were making the decision, I saw on alt.sources a new small object-oriented language announced and tried it out, but it had absolutely no class libraries, and no tools, and nobody had hever heard about it before (some guy named Guido) so we passed up on Python...

      The goal was to make paper be the universal access portal to information, and to piggyback on images as the universal information transfer medium. We did hyperlinks on paper, used dialup modems for transferring information, etc. Basically it was the web and web forms on paper. Now the focus is on capturing paper documents and their metadata and making them first-class citizens in the office network.

      The DocuScript language was actually much more like Java than like Smalltalk. It did have an object-oriented database, which Java lacks, but consider the following:

      • Much of the PostScript code was written in PdB, a C++-like language compiled to PostScript. PdB was written at The Turing Institute by Arthur van Hoff, who later went on to write the first Java compiler, with a remarkably similar syntax. So, the system was written in a precursor to Java with GS as the virtual machine.
      • Herb Jellinek worked on the "configurable desktop universal browser" part of the project at PARC. He left and went to Sun to work on Oak and in the meantime, WWW happened and became the protocol for the "universal browser", and he wrote HotJava, which was the web browser that kicked off the Java revolution.
      • The Paper User Interface forms were all done as small PostScript programs that, depending on which set of definitions was loaded into the environment, either rendered a printable image to the image buffer, or read the scanned image from the image buffer and read the checkboxes. The layout decisions were all done with PostScript routines.

        So, in that sense, the layout was like LaTex, where the formatting commands are actually short programs or macros that bottom out into an implementation of primitive operations. After the product was launched, Larry Masinter of PARC convinced me that the LaTex-programmmatic approach was wrong, and that we needed to use a static description language, a path I had resisted because there were no good ones. But in the interim, again WWW had hit, and HTML seemed good. We did a Paper User Interface version of the WWW (now going full circle from our original idea of paper access to information to paper being a proexy for access to information via the WWW) and we made a tool to print Paper UI on any web page.

        Initially we did this as well in PostScript, but found that we needed something faster for the HTML parsing and layout, so we got a company called Universal Access to do that for us. They had a tool they were developing, and they prototyped it for us, and their other customer was a company called Unwired Planet that wanted to make a transcoder to convert HT

  14. Re:Duh by Cyberdyne · · Score: 2, Interesting
    Well, I still do not know why you used Touring completness for your example...

    Example? Turing completeness is pretty significant.

    I assume you are just reading about it in school, eh?

    Then you assume wrongly.

    Anyhow, not only NeXT, but the old NEWS distributed windows systems proposed by SUN did infact used postscrip. I believe SGI also implemented a NEWS server... it was overshadowed by X. Although I believe both SGI and SUN did merge X and NEWS together in their display servers....

    NeXT is the nearest to a mainstream example; while NeWS was derived from Postscript (predating Display Postscript), it was never a compliant Postscript implementation, ruling out the big screen<->printer WYSIWYG advantage. Irix 4 introduced Display Postscript support, used by Impressario, but NeWS was dropped after Irix 3.

    The key difference is, IMO, NeWS was a dead-end, replaced entirely by X - NeXT's Display Postscript lives on, as Display PDF in Quartz.

  15. Re:So why is this a good thing? by Anonymous Coward · · Score: 2, Interesting

    The most valuable difference between PDF and Postcript is that page breaks are set in stone in PDF, which is not the case in PS. Thus, if you save your work in PS, it is possible sometimes to get a tiny amount of stuff hanging off onto the last page by itself due to subtle metrics differences between printer fonts and screen fonts, roundoff errors, etc. PDF prevents this.