# Build a PostScript interpreter in a few lines of JavaScript

Original title: Let's Write a PostScript Interpreter

> Hacker News story 50478632 · language: en · submitted 2026-11-13
> Web version: https://zeli.app/story/50478632
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 131 · by [RebelPotato](<https://news.ycombinator.com/user?id=RebelPotato>) · 💬 22
[original](<https://beyondloom.com/blog/postscript.html>) · [HN discussion](<https://news.ycombinator.com/item?id=50478632>)

## Summary

A brisk, hands-on walkthrough of implementing a working subset of PostScript in concise, Forth-inspired JavaScript. It covers tokenizing programs, mapping PostScript types onto JavaScript values, and driving an operand stack and dictionary stack with a small set of primitive operators. The result runs as a REPL and handles examples like `[10 20 30] {2 mul} forall` identically to Ghostscript, with exercises for extending the operator set.

## Key quote

> I think the most trustworthy programming languages are those which are human-scale: languages which a single user could reasonably write from scratch on some readily-available computational substrate.

## HN discussion (22 comments)

### [glkindlmann](<https://news.ycombinator.com/item?id=50496878>)

> I tried to write (in C) a PostScript byte compiler for a grad school project.  It is a very appealing language to work with, with the simplicity of stack machine. And like with this post, I didn't get into the graphical elements that make PostScript useful.
>
> Mainly I learned that Ghostscript is doing a lot to make its PostScript interpreter fast: with the non-graphical test programs I could think up, GhostScript was many times faster interpreting the program (even computationally intensive ones) than my runtime (called "egon") could execute the byte-compiled PostScript.  So it was a computation fail but still a pedagogy win.
>
> I've always been meaning to learn more about how Ghostscript is engineered.

### [Renina](<https://news.ycombinator.com/item?id=50478813>)

> Writing a tiny interpreter is one of those exercises that teaches you more about programming languages than months of just using them

### [TacticalCoder](<https://news.ycombinator.com/item?id=50496979>)

> I still mess with PostScript once in a while. For example I generate little puzzles for my daughter/nephews (words to find in an hexagonal grid, where each hexagon contains one letter): wrote that in Clojure but it generates PostScript (nowadays I could ask a LLM to write the whole thing for me though as the potential for disaster is limited).
>
> Then there's that one utility company who screws up my montly invoice and so, invariably, when I need to do KYC for whatever bullshit-state-surveillance reason (which, invariably, happens all the time), KYC fails for my official address doesn't match the technical address the utility company is using on my invoices.
>
> So the PDF gets converted to PostScript, I edit the PostScript, and convert back to PDF. Nowadays I take it I could also have a LLM do it all for me but the thing is: I don't want my PDF to look like a PDF which has been tempered with (which it definitely has been, but fuck KYC and screw that utility company for not using my proper official address). So I like the PDF to PostScript to edit back to PDF cycle.

---

## Cite

- Page: https://zeli.app/story/50478632
- Date: 2026-11-13
- Source: beyondloom.com (https://beyondloom.com/blog/postscript.html)
- Hacker News: https://news.ycombinator.com/item?id=50478632

## Other languages

- zh: https://zeli.app/zh/story/50478632 · markdown: https://zeli.app/zh/story/50478632.md
- ja: https://zeli.app/ja/story/50478632 · markdown: https://zeli.app/ja/story/50478632.md
- ko: https://zeli.app/ko/story/50478632 · markdown: https://zeli.app/ko/story/50478632.md
- de: https://zeli.app/de/story/50478632 · markdown: https://zeli.app/de/story/50478632.md
- es: https://zeli.app/es/story/50478632 · markdown: https://zeli.app/es/story/50478632.md
- ru: https://zeli.app/ru/story/50478632 · markdown: https://zeli.app/ru/story/50478632.md
