Hacker News new | past | comments | ask | show | jobs | submit login
Learn PostScript by Doing (2005) [pdf] (uva.nl)
71 points by todsacerdoti on Nov 13, 2023 | hide | past | favorite | 18 comments



It is a pity that PostScript has to live such a dwindling life. It is a very fascinating language in itself. After Display PostScript disappeared, I think the only use is in printers nowadays. I once invested in a development environment for PostScript — psalter — where I could step through code and see contents on the various stacks. I used it when developing overlays on printouts of scanned images, as PostScript files with TIFF content was much smaller than print bitmaps from Windows and LANs weren’t faster than 10 MBit :) It made a huge difference in printout speeds.

I also found a bug in libtiff by studying produced PostScript. I don’t think anybody looks at this anymore.


The two reasons I don't use postscript directly are lack of alpha blending and no unicode support. Remapping the font to get characters beyond ASCII is too awkward.


If you specifically target Ghostscript, you do get alpha blending as an extension though, right?


I guess the closest thing is METAPOST?

Wishing I could find a more interactive environment for using it than a lualatex document open in a TeX IDE and getting a preview as a PDF which can't be interacted with.


Hey, that's a pretty handy document. Interesting to see it support PS in the context of LaTeX and Word.

I used to dream in PostScript I was coding in it so much -- the experience was dreaming about stack-oriented coding, as opposed to vector visuals, for clarity. I got started coding in PS on the NeXT in '91 doing data driven graph visualizations. PS was great for some algorithmically-generated logos too. Really fun were some fractals which strained the imagesetters and printers they ran on. Learning PS really paid off though when I ended up using it to create a database publishing engine for real-estate listings. It used Python for data wrangling and orchestration and then PostScript for the dynamic book generation and layout. It was used back when real estate agents relied on giant books printed daily, which this engine generated for dozens of markets across Western Canada. These documents were pretty gnarly too, including property-type-specific templates, various indexes, property images, market-specific variations, etc -- and doing all that with the absolute control which PostScript permitted was fantastic. It would have been nightmarish to try to do such things in LaTeX, Word or the DTP tools of the era. PDF rendering was automated with GhostView so the whole toolchain was open source.

I'd suggest that if extreme precision, detail and complexity are your requirements and especially if rendering to PDF and screen bitmaps are needed then PostScript is still very relevant. It's also quite fun as a developer.


I enjoy making obfuscated signatures in PostScript. The bottom of my home page reads:

If your browser can preview postscript, have a look at my signature https://tromp.github.io/img/sig.pdf :

    %!PS                            % -John Tromp http://tromp.github.io/
    42 42 scale 7 9 translate .07 setlinewidth .5 setgray/c{arc clip fill
    setgray}def 1 0 0 42 1 0 c 0 1 1{0 3 3 90 270 arc 0 0 6 0 -3 3 90 270
    arcn 270 90 c -2 2 4{-6 moveto 0 12 rlineto}for -5 2 5{-3 exch moveto
    9 0 rlineto}for stroke 0 0 3 1 1 0 c 180 rotate initclip}for showpage
(when using ghostview make sure to turn off Antialias under State/gv Options or the colors won't show correctly) or this one https://tromp.github.io/img/pinwheel.pdf :

    %!PS                           % -John Tromp http://tromp.github.io/
    /t{dup 1 sub gsave dup 0 gt{[.4 .2 -.2 .4 .4 .2]concat t currentgray
    .8 mul .2 add setgray -1 1 scale t -1 2 translate t 1 -1 scale t[0 1
    1 0 0 2]concat t pop}{0 moveto 1 0 lineto 0 2 lineto closepath clip
    fill}ifelse grestore}def 10 10 translate 600 600 scale 5 t showpage
The first is a logo for a Go club I co-founded in my home town, while the second shows an aperiodic tiling known as the https://en.wikipedia.org/wiki/Pinwheel_tiling


In the early 90s, I began my programming career by developing reporting solutions for a Construction Support System used in train and tram construction and assembly. This system ran on a VAX/VMS platform. My role involved creating custom reports which could be printed on the DEC laser printers. I programmed these solutions using FORTRAN and hand-written PostScript code, which I found enjoyable. To learn PostScript, I even invested in a set of PostScript books, including the well-known Red Book:

https://coding-and-computers.blogspot.com/2022/12/postscript...


About 1990 or so I learned PostScript to do development in NeWS using the PostScript books that shipped with Sun OpenWindows - the blue book is a really well written tutorial.


Is PostScript still used in printers?

Someone already mentioned NeXT and NeWS. I loved Solaris and NeXTSTEP when I was in college in the 1990's. At the time every computer lab had an HP printer with built in PostScript. When I got my first job after graduation in 1997 I convinced my new manager to spend $3000 on an HP 5 Si MX with built in PostScript. It was fast and the output looked great.

I've run Linux since 1994 and I remember most programs would create a .ps file but you could use the Red Hat printer config to automatically use GhostScript to convert it and print.

I assume GhostScript converted it to whatever format the cheap $100 printer needed because they couldn't afford PostScript and a separate processor to run it?

These days computers are so fast is there any need for PostScript inside printers?

I found this article saying its still in high end printers but I haven't printed anything at work in 5 years so I don't even know if ours supports it.

https://www.gohackworth.com/what-is-postscript-and-why-do-al...


And computing is so cheap that there wouldn't be much issue with including it in a networked printer. Or a multifunction printer. I'd expect more of a question of license cost. But if your printer is going to understand pdf out of the box, probably it understands postscript also.


PostScript is a fascinating programming language. Back in the 90s I wrote a program to filter Rich Text to PostScript. One of the formatting options is "full justification" which adjusts the width of inter-word spacing to achieve smooth left and right margins. The code to accomplish this is written in PostScript. https://github.com/excitom/rt2ps


Basically, if you're a coder and you make documents or images which are complicated, structured, data-driven or orderly enough to seem amenable to programmatic construction, then Postscript really is worth learning. It would be no problem to whack together an open source toolchain for making videos using postscript too, if you were trying to make programmatic 2D or 2.5D animations. Just sling ghostview and ffmpeg together and Robert is your parent's brother. Javascript with SVG or Canvas is certainly better if you need interactivity, soft realtime or web-only delivery though.


PostScript is still useful as a reporting output language (turned to pdf for end-user convenience these days) and for this I felt that the important parts were control of text rendering and placement, placement of blocks of content with respect to each other, and readability of the postscript itself (Because you rarely have a postscript environment that makes it easy to debug). 3 things missing from this tutorial. - but very achievable.


I've pulled together (yet another) list of useful various Postscript resources (books, tutorials, articles, etc) here: https://zzzoot.blogspot.com/2022/09/postscript-coding-resour...


Oh very good! Thank you! For people looking for a tutorial, this is a much better starting point.


I remember trying to learn Poscript to create fancy graphics (already knew some LaTeX basics to write document).

Then I gave up. Creating images in another tool like Visio/Powerpoint was much easier...


A resource which I found very helpful for this sort of thing is:

https://personal.math.ubc.ca/~cass/graphics/manual/


Ah looks very nice. More stuffs to play with on weekend :D




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: