Yes, PostScript is a great general purpose high level programming language, kind of like a cross between Forth and Lisp, but a lot more like Lisp, with its polymorphic homoiconic data structures that were essentially JSON.
https://news.ycombinator.com/item?id=41962062
>PostScript is kind of like a cross between Forth and Lisp, but a lot more like Lisp actually. And its data structures, which also represent its code, are essentially s-expressions or JSON (polymorphic dicts, arrays, numbers, booleans, nulls, strings, names (interned strings), operators (internal primitives), etc.)
https://news.ycombinator.com/item?id=21968175
>Kragen is right that PostScript is a lot more like Lisp or Smalltalk than Forth, especially when you use Owen Densmore's object oriented PostScript programming system (which NeWS was based on). PostScript is semantically very different and much higher level that Forth, and syntactically similar to Forth but uses totally different names (exch instead of swap, pop instead of drop, etc).
https://news.ycombinator.com/item?id=21968842
>You're welcome! OOPS (Object Oriented PostScript ;), I meant to say that PostScript and Lisp are homoiconic, but Forth is not. The PSIBER paper on medium goes into that (but doesn't mention the word homoiconic, just describes how PS data structures are PS code, so a data editor is a code editor too).
The Shape of PSIBER Space: PostScript Interactive Bug Eradication Routines — October 1989:
https://donhopkins.medium.com/the-shape-of-psiber-space-octo...
The Story of Sun Microsystems PizzaTool: How I accidentally ordered my first pizza over the internet.
https://donhopkins.medium.com/the-story-of-sun-microsystems-...
PizzaTool Source Code (in object oriented NeWS PostScript using Owen Densmore's "class.ps"):
https://www.donhopkins.com/home/archive/NeWS/pizzatool.txt
NeScheme and Schlumberger's LispScript:
https://donhopkins.com/home/archive/NeWS/NeScheme.txt
>PostScript is often compared to Forth, but what it lacks in relation to Forth is a user-extensible compiler. You can write your own PostScript control structures and whatnot, like case and cond, to which you pass procedures as arguments on the stack, but the PostScript scanner is not smart -- but there is no preprocessing done to the PostScript text being read in, like the way immediate words in Forth can take control and manipulate the contents of the dictionary and stack while the text source is being read in and compiled, or like the way Lisp macros work. This is one of the things I would like to be able to do with something like LispScript.
>"Lisp is the language for people who want everything, and are willing to pay for it." -Russell Brand (the old school Lisp hacker "wuthel" from MIT, not the crazy MAGA rapist)
If you want to efficiently implement a PostScript interpreter with rendering in the web browser (or node), you just have to reach for the canvas 2d rendering context, which is essentially the full PostScript stencil/paint imaging model upgraded to the Porter/Duff compositing model with alpha channels, but without the user defined font rendering and halftoning machinery (which you could implement on top of it).
https://keithp.com/~keithp/porterduff/p253-porter.pdf
PostScript has always had the black and white "image" and "imagemask" operators, but they are clumsy, don't support any kind of image processing, and you have to use "readhexstring" to read hex images, but later versions support color images.
NeWS has "readcanvas" to directly read binary Sun raster files (including color) from files and over the network. It also had memory mapped canvases, which I used for the HyperLook version of SimCity so the C simulator engine could efficiently render the tiles and map views with overlays into memory, and NeWS could scale and render them quickly. I also used memory mapped canvases for my NeWS/HyperLook cellular automata machine, which was implemented in C and scaled and rendered and had a real time painting UI implemented in NeWS PostScript (the client and server took turns "owning" the pixels by ping-ponging messages over the localhost network, so each could draw into the cells in turn, and you could render PostScript directly into the 8-bit color cells for interesting effects, melt people's faces, and clip them on the screen to a window in the shape of a lava lamp).
http://www.art.net/~hopkins/Don/hyperlook/HyperLook-SimCity....
http://www.art.net/~hopkins/Don/art/cam-screen.gif
http://www.art.net/~hopkins/Don/art/RoyalPineAura.gif
The Apple PostScript printer drivers used (and Adobe's Blue Book documented) an indirect but efficient hack that tricked the custom halftone rendering machinery into performing a perfect pattern fill (so you could print MacDraw files, etc).
https://news.ycombinator.com/item?id=22570865
DonHopkins on March 13, 2020 | parent | context | favorite | on: Finding Mona Lisa in the Game of Life
Error diffusion dithering would work very well as initial conditions for many cellular automata rules like Life, especially counting rules (which life is) that stay alive with intermediate numbers of neighbors.
Conway's Life stays alive with 2 or 3 neighbors out of 9, or 2/9 .. 3/9, so gray scales between 22% .. 33% would be the most active.
Halftone screens would have different results, but their regularity might work well with certain CA rules and screens.
PostScript gives you a lot of control over the halftone screen definition.
Halftone screens can use any kind of repeating pattern, there just has to be the proper ratio of white to black pixels to make it look the right brightness. You could even design a set of halftone screen patterns that were precisely matched with a particular cellular automata rule to produce interesting fertile or static patterns. And you can even use any arbitrary pattern for each level, even if they aren't the right brightness, for aesthetic reasons.
The original PostScript LaserWriter was able to efficiently perform pattern fills to print tiled MacDraw images, by defining a custom halftone screen for each tile pixel pattern, that printed precisely the right pixels when you set just the right gray level: the ratio of on pixels to the total number of pixels in the tile. The spot function basically tells the halftone screen machinery what order to turn the dots on as the gray level goes from 1 to 0 (which results is seamless tiling with nearby gray tiles). Take a look at the PostScript header of an old MacDraw file some time to see the really bizarre code that does that by abusing the "setscreen" operator with a contrived spot function. (That was extremely tricky and gave GhostScript problems for years. The trick is documented in Program 15 page 193 of the awesome PostScript "Blue Book", and it uses a lot of memory! It's one of the coolest tricky PostScript hacks I've ever seen!)
https://web.archive.org/web/20210303050038/https://www.adobe...
https://melusine.eu.org/syracuse/postscript/bluebook/?opt=ep...
https://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF
>This program demonstrates how to fill an area with a bitmap pattern using the POSTSCRIPT halftone screen machinery. The setscreen operator is intended for halftones and a reasonable default screen is provided by each POSTSCRIPT implementation. It can also be used for repeating patterns but the device dependent nature of the setscreen operator can produce different results on different printers. As a solution to this problem the procedure, ‘‘setuserscreen,’’ is defined to provide a device independent interface to the device dependent setscreen operator.
>IMPLEMENTATION NOTE: Creating low frequency screens (below 60 lines per inch in device space) may require a great deal of memory. On printing devices with limited memory, a limitcheck error occurs when storage is exceeded. To avoid this error, it is best to minimize memory use by specifying a repeating pattern that is a multiple of 16 bits wide (in the device x-direction) and a screen angle of zero
https://www.grymoire.com/Postscript/Halftones.html
https://en.wikipedia.org/wiki/Halftone#Digital_halftoning
Here is what happened when I mixed PostScript and cellular automata (and HyperLook, like a PostScript version of HyperCard):
Fun with Cellular Automata [...more at https://news.ycombinator.com/item?id=22570865 and http://www.art.net/~hopkins/Don/art/cell.html ...]