The Greatest Pun

Shakespeare’s chock-full of puns, no doubt as a sign of his mastery and love of words.

Rarely can you swap two words to form a correct grammatically sentence, yet he played with words like a magician.

Better a witty fool than a foolish wit.

Twelfth Night

In the example above, the noun “fool” flips to the adjective “foolish”, while the adjective “witty” flips to the noun “wit”. The simplest puns leverage the rules of grammar to change the meaning of words.

Then there are puns that play with phrases in a way that leverages context outside the grammar to change the meaning. Here’s one of my favorites:

Put out the light, and then put out the light.

Othello

The first phrase literally means to extinguish a candle, but the second is a metaphor for killing someone (in this case, Desdemona).

The formal dictionary definition of a pun usually talks about the “humorous” effect.

pun /pʌn/ noun
The use of a word in such a way as to suggest two or more meanings or different associations, or of two or more words of the same or nearly the same sound with different meanings, so as to produce a humorous effect; a play on words.

Oxford English Dictionary

Now, I very well believe humor is in the eye of the human. What’s funny to me isn’t always funny to you. But I’d like to introduce you to the greatest pun I’ve ever discovered. It isn’t in English. Natural languages and programming languages have one property in common: grammar. You’ve already seen what a pun can do with that.

Tagged Template Literal

First, a quick background on the grammar. In JavaScript, there’s a thing called a tagged template literal that lets you do powerful string manipulation like this:

const systemPrompt = dedent`
    You are a code review agent.
    
    Follow these steps:
        1. Before reviewing the PR, find recent related PRs.
        2. ...
        3. ...
        4. ...
`;

In this code, dedent is the tag function, which processes the template literal to remove excessive indentation. A tag function receives the literal’s text pieces and the evaluated ${...} values as separate arguments, so it can do whatever it likes with each.

Templating Languages

Most templating languages let you write the template in the same medium as the end product: text with holes where the variables go. Any time your controls live in the same system they are controlling, things get interesting. There is some Gödel incompleteness side-quest worth exploring here. But I digress. Here’s a quick example of a template:

hi {{ name }}

The {{ }} syntax is very common. In fact, the following templating languages use it:

Prompt Template Literal

Check this out. We can define a tag function called prompt that looks like it’s accepting {{ }} templates.

const userPrompt = prompt`
  Please review my code.
    - Link to PR: ${{ url }}
    - Extra notes: ${{ notes }}
    - Timestamp: ${{ time }}
`;

It looks familiar and easy on the eyes, right? Behind the scenes, it’s producing a string that will be processed by an observability tool (Helicone) to help analyze the prompts.

Please review my code.
  - Link to PR: <prompt id="url">https://github.com/etc/etc</prompt>
  - Extra notes: <prompt id="notes">Only review the unit test files</prompt>
  - Timestamp: <prompt id="time">2026-09-26</prompt>

In my opinion, the cool part is that the apparent {{ }} template syntax emerges in our JavaScript code by coincidence: ${...} evaluates whatever is inside it, and JavaScript’s { name } object shorthand is equivalent to { name: name }. The tag function, prompt, now has all it needs to annotate the string properly.

you see ${{ url }} JavaScript sees

JavaScript sees one thing, and you see another. The {{ url }} syntax lives in your head.

… crickets …

Alright, maybe I overplayed the pun, but I’m absolutely proud of it. I worked with Justin from Helicone on this back in 2024. It was an idea I’d been using internally, which Justin then made official in the SDK (Justin’s PR, my PR). I thought the pun was funny. Justin was happy to include it.

A pun is one string with two parses. In Grammar models are back, baby! I take that seriously and hand back a probability distribution over them. In Spatial languages I make it worse and hand the parser a second dimension.