Game of Life in Postscript 274
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."
wow (Score:5, Funny)
Wow. (Score:5, Insightful)
don't exaggerate (Score:4, Informative)
But to call the language itself "extremely powerful" is an exaggeration. As a programming language it is quite primitive and incomprehensible, compared to more powerful languages such as C++, java, ML, yes even forth.
Re:don't exaggerate (Score:2, Insightful)
Calling PostScript "primitive" is a joke as well. Learn about the language. Read the PS Language Reference. Look at some of its more complex features.
Re:don't exaggerate (Score:2)
Really? It's fairly easy to test a printer by banging out a line or two...
echo '/Times-Roman findfont 72 scalefont setfont 1 72 mul 9 72 mul moveto (This is a test) show showpage' >/dev/lp0
I wouldn't call that incomprehensible. It loads 72-point Times Roman, moves to a point 1" to the right and 9" from the bottom, renders "This is a test", and tells the rendering device to print (or otherwise finalize) the page.
Po
Re:Wow. (Score:5, Interesting)
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.
Re:Wow. (Score:5, Interesting)
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".
Re:Wow. (Score:2)
Re:Wow. (Score:2)
Webserver (Score:5, Interesting)
Anyway, most people know script it turing complete - this is hardly the greatest hack ever
But it's cool - i'm not being negative.
Re:Webserver (Score:5, Informative)
It must be used with inetd though, because postscript doesn't support sockets...
Ray Tracer (Score:5, Interesting)
Re: Easy (Score:2, Funny)
Now write a towers of hanio program utilizing the n-1 algorithm.
Using the 3 or more poles you created to move all the discs from smallest to largest from pole1 to polex (x being the greatest number or the opposite pole). Use the second pole as a temporary holding area.
yes, and... (Score:5, Insightful)
Re:Webserver (Score:2)
It would be cooler if... (Score:2, Funny)
OS (Score:4, Funny)
Re:OS (Score:3, Informative)
Almost - was called "DisplayPostScript" (Score:2)
those guys knew their eggs but Windows had the muscle
Re:OS (Score:2)
Not that it would necessarily be easy, but it could be done.
Re:OS (Score:4, Funny)
Much cooler PS hack (Score:5, Informative)
And I thought it meant... (Score:4, Funny)
So why is this a good thing? (Score:2)
Shouldn't the actual processing of data be solely handled by the computer? I mean, this article clearly says that it can tie up the printer for a long time if you actually try this.
Re:So why is this a good thing? (Score:2)
Kolmogorov encoding (Score:3, Insightful)
to the printer is an important consideration.
Coding a page as the shortest computer
program that can generate the page is "the
best you can do". Of course, whether or not
dvips is generating the optimal program is
another issue entirely.
Re:Kolmogorov encoding (Score:2)
Re:Kolmogorov encoding (Score:2)
Re:Kolmogorov encoding (Score:2)
It is for this reason that postscript prologs quite often redefine all common postscript commands into one or two letter equivalents (which also renders the postscript practically illegible).
We used t
Re:Kolmogorov encoding (Score:2)
Re:Kolmogorov encoding (Score:2)
You could plug a SCSI hard drive into a LaserWriter; it was used (IIRC) mainly for font storage. Instead of having to send all of the fonts across the network (which at LocalTalk's 230.4 kbps could be slow), all of the fonts an office used regularly could be dumped onto the hard drive and retrieved by the printer as needed.
Re:Kolmogorov encoding (Score:2)
Re:So why is this a good thing? (Score:5, Informative)
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.
Re:So why is this a good thing? (Score:2, Interesting)
Re:So why is this a good thing? (Score:2)
It's funny how many people in the Unix world seem to have this thing against PDF, and keep insisting that PS is better. PDF is better, because:
Re:So why is this a good thing? (Score:2)
Well, it's more than that -- for example, practically every scientific journal these days distributes the papers as PDF files, not because they are scanned, but because HTML still has a long ways to go in representing equations and figures (including links to non-scalable bitmaps hardly counts).
Re:So why is this a good thing? (Score:2)
a) its better for handing off documentation to customers in an unmodifiable form, especially project plans
b) its MUCH better for handing off documentation when you use document linking and dynamic charts since you don't have to hand over all of the linked documents, and the raw data behind the charts if you don't want to
c) you can freeze-dry your dynamic documentation at various checkpoints
d) I also use it to print web receipts to files (eBay
Re:So why is this a good thing? (Score:2)
Re:So why is this a good thing? (Score:5, Informative)
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.
Re:So why is this a good thing? (Score:2)
Apple also wrote an Imagewriter emulator in PostScript...the intended purpose was to enable 8-bit Apple II software to print to Lase
Re:So why is this a good thing? (Score:2)
The printer can't do more than 1 bpp, though...for a given pixel, either it puts down ink/toner or it doesn't (unless you're talking about dye-sublimation printers). That's why you can get good results printing photos at 100-150 dpi. The rasterizer will convert continuous-tone images to halftone images...that's part of its job description. T
Re:So why is this a good thing? (Score:2)
Can't print every iteration (Score:2, Informative)
Re:Can't print every iteration (Score:3, Insightful)
It's not a bug it's a feature!
Re:Can't print every iteration (Score:2)
PostScript Fractals (Score:5, Informative)
Re:PostScript Fractals (Score:2, Funny)
Go Game in 5 lines of PostScript (Score:5, Interesting)
%%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
Re:Go Game in 5 lines of PostScript (Score:4, Funny)
Is that a postscript or perl program?
That is the most obfuscated program I think I have ever seen.
Re:Go Game in 5 lines of PostScript (Score:3, Interesting)
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 [demailly.com] for other versions)
Raytracing in Postscript (Score:3, Interesting)
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 [indiana.edu]
stupid postscript tricks (Score:5, Funny)
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 [cyll.org] near the bottom. It's called PSReplace.
Re:stupid postscript tricks (Score:2, Funny)
Now, however, everybody will know Duane Bailey has forged his/her own paychecks.
Re:stupid postscript tricks (Score:2)
Re:stupid postscript tricks (Score:2, Funny)
Re:stupid postscript tricks (Score:2, Informative)
ftp://ftp.tekcolor.com/ftp_dir/ALL/W9NT2000/NA/Fi
But... (Score:2, Insightful)
Seriously, I have seen enough stuff being printed around the office and then trashed, this would be like an evolution of paper wastage to the next level.
Especially if someone posts a story on slashdot about it and every coder out there has a go.... oh wait...
This isn't news. (Score:2)
It's still cool, though.... very high nerd factor.
Re:This isn't news. (Score:4, Funny)
You're new here, aren't you?
um (Score:3, Funny)
No... Not really...
Please forgive me (Score:3, Funny)
There are two other times when I came to the realization that the tech community was sometimes way lost beyond the boundaries of practicality in addition to this latest thing. Once upon touring MIT and seeing the amazing amount of intellect dedicated towards uber mundane pursuits such as remotely identifying the inventory of a coke machine, and another situation at Siggraph seeing tens of millions of dollars wasted on research projects that had a snowball's chance in hell of developing practical applications for the findings.
Now I can appreciate the pursuit of a tech solution to something that's of interest, and I understand that things like Star Wars in ASCII are projects borne of love, but at the same time, I wonder, do tech people every try to achieve both in the same breath? Yes, you can add an ant farm to your PC case. But if you ever wonder why the mainstream looks at tech types as total weirdos, it's because they love to use as an example, these weird manifestations of our ability, when we all know, these are more the exception than the rule. Or are they?
So my question is, aside from the arguments where someone draws a reasoned path explaining how a tennis shoe with voice recognition will change society, is anyone concerned about the image of the tech community and finding more realistic ways to demonstrate the creativity and resourcefulness of nerds?
Re:Please forgive me (Score:2)
Who gives a shit what people will think? If something turns you on and it doesn't hurt anyone, by all means do it. If it's a time-waster, so is watching TV.
On the other hand, as someone already pointed out, this is really old news. When Postscript was new, people were doing tons of these things (cute Postscript hacks).
Re:Please forgive me (Score:2)
is anyone concerned about the image of the tech community and finding more realistic ways to demonstrate the creativity and resourcefulness of nerds?
I can only speak for myself in this respect, but no. Why would I be bothered about how the mainstream view the "tech community" - if we all started worrying about how others see us, would the world be a better place? Would it be fun, being drones dedicated to furthering what you, or some other person, see as worthwhile projects?
explai
Re:Please forgive me (Score:2)
That's a good question. Normally I'd be right with you and say screw the mainstream.
But who here really feels that the mainstream's idea of innovation and efficiency is even remotely accurate? How many people get frustrated when they see some marketing guy take a great idea and pervert it into something that is sad? Hasn't the tech community's indifference contributed to this problem? Yea, playing the game is demoralizing,
Re:Please forgive me (Score:4, Insightful)
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.
Re:Please forgive me (Score:2)
No why? (Score:2, Interesting)
Are you guys living in the real world?
Mohammed Saeed al-Sahhaf on Java (Score:4, Funny)
There is no such thing as bytecode. These "registers" are lies. There is no runtime stack. The javac executable is really a wrapper around gzip. This "JVM" is a fabrication concocted by the infidel authors of GWBASIC and does not exist. These cowards have no morals. I blame Al-Jazeera- they are marketing for Sun. God will roast their stomachs in hell. They are not in control of anything- they don't even control their own code! Be assured, our CPUs are safe and protected from compressed interpreted source code. We have placed their threads in a quagmire from which they can never emerge unless they throw an exception. Java is a snake and we will cut it in pieces!
That's nothing .... (Score:3, Interesting)
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.
Re:That's nothing .... (Score:2)
Re: Sending each iteration to the printer (Score:3, Funny)
Other way around (Score:2)
Actually, I don't know of any working Turing machine or lambda-calculus implementations in Life, but I believe it is thought possible.
Easy to view postscript files (Score:4, Informative)
Xerox, Copiers with SmallTalk via GhostScript (Score:5, 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!
Re:Xerox, Copiers with SmallTalk via GhostScript (Score:2)
Re:Xerox, Copiers with SmallTalk via GhostScript (Score:3, Interesting)
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 wer
Re:Xerox, Copiers with SmallTalk via GhostScript (Score:5, 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 [mit.edu] 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:
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
Re:Xerox, Copiers with SmallTalk via GhostScript (Score:2)
Thanks Leigh, it's good to hear what happened to that.
Re:Xerox, Copiers with SmallTalk via GhostScript (Score:2)
Uh-oh, I've got a scheme a brewin' (Score:2)
Haven't read much by Don Lancaster, have you? (Score:2)
Was I the only one.... (Score:2, Funny)
Thinking in PostScript (Score:5, Informative)
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.
Postscript is and always has been... (Score:2)
I even heard that someone wrote a fully functional program to pull ANY file on a machine with DPS set to public.
Scary.. and very cool.
Later, GJC
One word: Kinko's (Score:2)
Damn, I wish I were 14 and irresponsible again. Now I'm just irresponsible.
Re:Is it really a game? (Score:2, Interesting)
Lifewar (Score:2)
Re:Is it really a game? (Score:2, Insightful)
Tetris ending (Score:2, Informative)
(Context: debating an assertion that Conway's Game of Life has no end condition; therefore, it's not a game. wo1verin3 brings an analogy to Tetris brand games.)
do you know anyone who has "finished" Tetris?
Some falling tetramino games, including Tetris brand games, display fireworks and credits after the player has completed specific objectives. For example, in The New Tetris for N64, it's 500,000 lines summed over all games played.
Re:Duh (Score:5, Interesting)
Re:Duh (Score:5, Interesting)
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.
Re:Duh (Score:2, Interesting)
Re:Duh (Score:3, Interesting)
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
Re:Duh (Score:2)
On the NeXT running with "public windowserver" was considered a security risk (and rightly so) though I never saw an 'sploit that used this.
Programming PostScript is a similar mind bending experience to programming Forth.
The new Mac windowserver is much faster than the one on the NeXT but being PDF based has similar "look Ma, no extra code" prin
Re:Duh (Score:2)
Apple dropped Quartz [apple.com]?!
Programming PostScript is a similar mind bending experience to programming Forth.
Yes, programming it's a pretty tough job; bear in mind it's not really supposed to be used like that - when you use it as a printer control language, it seems a lot nicer. Genuinely programming it, like the Postscript webserver, is a neat hack
PS-HTTPD (Score:4, Informative)
Pretty cool, eh?
Re:Making use of this... (Score:2)
Re:Life Shmife... (Score:2)
Sort of an object tree (Score:2)
At the end you have a map of the various objects, it's a pain in the ass to read, but at least Adobe lets you download the reference manual for free.
Some of the commands and concepts are similar to PostScript, and some of the commands are 2-3 character version of the 8 character PS commands.
Re:Handcrafting PS (Score:2)
I did much the same with a magazine article I wrote a while back, because I was too cheap to use a "real" drawing program.
Speaking of stupid PostScript tricks, in a past life at a company that did prepress software and printing hardware (lots of PostScript - 500 MB was nothing) I amused myself by coding the Towers of Hanoi in PostS