Pollen vs. Polyglot: Which Should I Use?

Last updated: home

EDIT (March 22nd 2020): This website is now built using Unlike-Assets, the library on which Polyglot depends. This article is now an indirect demonstration of Polyglot's features.

Pollen is a tool for publishing digital books by Matthew Butterick.1

Polyglot is a tool for expressing websites using any language for humans or computers.

Someone asked me how Polyglot compares to Pollen for authoring websites. I made Polyglot, but I won’t say it’s for everyone. I’ll show an uncomprehensive comparison of Pollen and Polyglot, then end with my own interpretation for who is best served by each tool.



What Does It All Mean?

To see the differences in action, let’s review how Butterick and I handle Markdown. Pollen supports Markdown by user demand, and Butterick made it clear that’s the only reason why it’s there:

But let’s make a deal, Markdown fans. Having met you more than halfway, will you at least consider that Pollen markup might be a better option for you than Markdown? [context]

From this, Butterick argues that the language you use to write content is a design detail that shapes your experience as a writer from then on.

I think that the language you use to write content is an implementation detail for an experience that you can change at any time. That means I can write Pollen markup within the Markdown for this page:

#lang pollen/markup

(define (marked text) `(p ((style "color: blue")) ,text))

◊marked{Hello, World!}

That module sits in the source of this page, inert. That way Polyglot lets me decide what to do with it. I use a workflow that lets me write modules to functionally replace the entire page,3 so I’ll need some glue:

<script type="application/racket" id="embed-pollen">
#lang racket/base

(provide replace-page)
(require polyglot "./pollen-sample.rkt")

(define (replace-page page-tx)
  (tx-replace-me page-tx
                 (λ (x) (list (cadr doc)))))

Say hi, Pollen.

Hello, World!

The glue shows that I’m in control of how assets work together.

Granted, Markdown alone can’t do any of this, and <taggy> boilerplate is tedious. Since I’m using Racket from within Markdown, I can already make custom elements. That’s my preferred way to do this.

<marked>I came from inline XHTML in Markdown</marked>

I came from inline XHTML in Markdown

Am I defending Markdown? No. Butterick is right about Markdown being a limited notation that we should not have to accept as writers. I still have to use an XML syntax to act as a weird border between languages. What I am saying is that Markdown limits don’t matter in practice under Polyglot. If it can be expressed as an X-Expression, then it can integrate with Racket.

In Pollen, you must write under a workflow that Pollen supports. If Polyglot did this, I’d be invested in the language you use to write documents too! I don’t have a dog in that fight because what I think about how you work is irrelevant. So even if I end up hating my code in a year (LOL, “if”), Polyglot gives me a way to transition between workflows without rewriting anything. That means I can greenfield my website at any time without losing content.

Still, Polyglot is not generally better than Pollen or vice-versa. What matters is what you want to deal with when creating content.

The drawbacks of Polyglot are the same as the drawbacks of Emacs. You have to be a programmer to make the most of Polyglot, and you will be dependent on the workflow you make.

The drawbacks of Pollen are the same as the drawbacks of things like AngularJS: You will be productive so long as you let Pollen call the shots. It’s not for people who are tired of being told how to work.

Of course you don’t have to use either, but if that was your call then you probably didn’t read this far.

What you want to get for your time? If you don’t mind following someone else’s workflow to quickly write beautiful books, then use Pollen. If you want to take responsibility for your own workflow to make a rich website, then use Polyglot. If you can’t decide, then use both. Since this is all in Racket, you only need a few lines to glue them together.

  1. RacketCon 2018 distributed a nifty password selection book written using Pollen.
  2. Pollen users might argue that they use code within content because #lang pollen can drop down into Racket among text content. I’m arguing that the fact #lang pollen appears at the top means that the initial context of the document is that of a program, and the content is inside that program.
  3. This is why I don’t need a templating engine.