
Pollen: the book is a program - jdoliner
http://docs.racket-lang.org/pollen/
======
SwellJoe
It's interesting to see a somewhat widespread shift away from the separation
of code, templates, styles, and text model of publishing things (mostly
websites, but most publishing can be boiled down to that if you squint), where
code/templates/style get merged into one. React does this. Pollen seemingly
takes it even further and sticks the text in the code, too. Or, rather sticks
the code in the text, I guess.

It's a surprising shift. "Separation of concerns" is still a thing everybody
wants to do, it's just flipping the idea of what should be the same "concern",
where React considers every piece of a component to be one concern...and, it
seems to work. I'm not sure I'm on board with this for writing, but the
results certainly do look very nice; the books the author has published with
Pollen all look gorgeoues and are very navigable.

I've been tinkering with Hugo for converting my projects docs to something
that isn't in a wiki or a CMS (because I find I dread working with either a
wiki or a CMS for large documents). I think it's probably "enough" for all of
my needs, so I doubt I'll take the time to learn a bigger system like
Pollen...but, it's hard to argue with the quality of the results.

~~~
dfischer
When I learned HTML in the 90's and early 2000's you got a strong notion that
they were separate concerns.

When I was learning react when it came out I had such a visceral reaction I
just wanted to run away.

After coding within react for the past couple years I strongly feel that react
has got it right.

A concern is after all a generality that has the potential to generate a
strong bias.

My lesson is that concerns should be taken with a grain of salt, and be
willing to try new things with as little as bias as possible; and then form a
new opinion, maybe a slightly different concern.

P.s I have also started writing CSS in our presentational focuses react
components and I couldn't be happier. It naturally did a BEM-like
architecture. I highly recommend it. I say this with extensive experience of
CSS architecture for applications.

~~~
bauerd
Of course React got it right because there's no violation of separation of
concerns involved.

JSX is just syntactic sugar on top of method calls. One is perfectly free to
extract the `render` functions into separate files and call them "templates".
Unless the argument is that virtual DOM libraries are an inherently bad idea,
I don't see what's to complain about separation of concerns.

~~~
stdbrouw
Separation of concerns is about both the structure of a piece of code (which
is what you refer to) and about how it is organized in files, folders and
mentally (which is what others refer to).

~~~
bauerd
As I said, you're free to do this to yourself. Put every function that calls
`React.createElement` in a separate file/directory and import it.

------
alew1
I'm a CS teacher and use Pollen to write my assignments (sample:
[https://drive.google.com/file/d/0B9DAZWpkQIDuUlA4SU5lcHItRDg...](https://drive.google.com/file/d/0B9DAZWpkQIDuUlA4SU5lcHItRDg/view?usp=sharing)).
It allows me to type assignments as fast as I can think them, in a specialized
mark-up language for exactly the type of assignments I give. I can then apply
various post-processing operations (like doing syntax highlighting, converting
straight quotation marks to curly but not when inside sample code, numbering
of problems, inserting special CSS to make the assignments print with nice
margins / without breaking up headings and paragraphs that belong with them,
etc.) all with very little pain.

It's also neat to show students, after they've spent months learning Racket,
that all sorts of useful things -- including the writing of their assignments!
-- can be automated with their new skills.

~~~
xrayspec
This is great. I would love to see the source for this. Would you consider
posting it?

~~~
alew1
Thanks! Happy to :-) Here's the code for this assignment, as well as the
pollen.rkt and HTML template/CSS files. (Disclaimer: this was written as code
to get something done, not for others to see, so it's not always pretty!)

[https://gist.github.com/alex-
lew/883ee382a697b39f0f6b49561a0...](https://gist.github.com/alex-
lew/883ee382a697b39f0f6b49561a0542f1)

By the way, I use Atom, which has an excellent Pollen plugin, to write. Typing
'@' then pressing tab turns into ◊{}, with the cursor between the lozenge and
the braces.

------
whalesalad
Is the ‘lozenge’ a Racket-ism or is it unique to this project? I understand
the logic around using a character that’s hardly used in regular writing – to
avoid escaping – but it seems as though it would be hard to use in practice.

~~~
kuschku
It’s a racket-ism to use unicode characters wherever possible, yes.

Racket by default also doesn’t use the keyword "lambda", but instead uses "λ".

You can obviously use something different, if you want to, but the default,
and recommended solution, is using unicode characters.

As Racket is frequently written in the DrRacket IDE, this also makes sense.

~~~
Xophmeister
> Racket by default also doesn’t use the keyword "lambda", but instead uses
> "λ".

I'm not sure that's true:

    
    
        Welcome to Racket v6.10.1.
        > (define foo (lambda (x) (+ x 1)))
        > (foo 1)
        2

~~~
kuschku
As I mentioned, both are possible, but (λ ...) is strictly preferred.

~~~
tonyg
This is certainly not the case. Some, but by no means all, of the core
maintainers prefer the unicode glyph, but the vast majority of the code uses a
spelled-out lambda.

In my current checkout of the codebase, I see the following:

    
    
        ~/src/racket/racket/share/pkgs$ ag lambda **/*.rkt | wc -l
        1041
    
        ~/src/racket/racket/share/pkgs$ ag λ **/*.rkt | wc -l
        163
    

Note also consistent usage of spelled-out lambda in the Racket style guide,
[https://docs.racket-lang.org/style/](https://docs.racket-lang.org/style/).

~~~
tonyg
I made a mistake, believing that `ag` could handle extended glob syntax. The
real numbers are:

    
    
        ~/src/racket/racket/share/pkgs$ find . -iname '*.rkt' | xargs ag lambda | wc -l
        33589
    
        ~/src/racket/racket/share/pkgs$ find . -iname '*.rkt' | xargs ag λ | wc -l
        16722
    

Glyph λ is more common than I thought, but still heavily outnumbered by
spelled-out lambda.

------
shalabhc
I realize it's the norm, but anyone wonder why we're pushing around static
content about dynamic programs? Why the dynamic program snippets do not work
_inline_ , even though the computer you're reading them on is fully capable of
running them?

~~~
gosub
You should watch "stop drawing dead fish" by Bret Victor

[https://www.youtube.com/watch?v=ZfytHvgHybA](https://www.youtube.com/watch?v=ZfytHvgHybA)

------
grzm
Discussion from 3 years ago (at time of release?) (53 comments):
[https://news.ycombinator.com/item?id=7822057](https://news.ycombinator.com/item?id=7822057)

------
a3n
"the book is a program"

Quibble after scanning, but the _book_ as produced appears to be a standard
web page, no more or less a "program" than any other web page.

~~~
baldfat
Quibble all ebooks were produced by programs in a computer?

Your looking at it as if the output is the programming piece. Heck markdown
outputs to HTML. You wouldn't look at markdown as a programming language in
the general sense?

Look a little closer my friend and you will see that this is very unique and
special.

"Pollen gives you access to a full programming language (Racket) with a text-
based syntax that makes it easy to embed code within your documents."

~~~
a3n
Sure, it goes farther than, say, Pandoc, in giving you access to an underlying
programming environment as a writer.

But to double down on my quibble, when I go into a bookstore, or on O'Reilly
(or now, Amazon, sniff), what's on offer are books. Even if on github and
similar, what's on offer there is source of various languages and markup,
which go to produce a book.

I just can't see any final, static rendering of source as a "program." I would
consider Stephenson's _Young Lady 's Illustrated Primer_, or anything that
aspires to that, as a program.
[https://en.wikipedia.org/wiki/The_Diamond_Age](https://en.wikipedia.org/wiki/The_Diamond_Age)

------
geokon
these short descriptions I've read don't seem to answer this question for me -
how is this different from orgmode + org-babel + HTML/PDF export? See like
reinventing the wheel for one language, or am I missing something?

~~~
fantispug
Pollen is a Racket language, and gets parsed into an AST and evaluated. You
can programmatically generate correct markup using all of Racket.

Org Babel is more about evaluating code snippets in a variety of languages.
Even if you can evaluate to produce org markup that's processed it doesn't
have the same level of structural integration.

~~~
geokon
I get that it's cleaner that it's an AST but when would you ever want to
_generate_ markup? Seems like a weird use-case

------
Chiba-City
This looks lovely and near perfect. But what happened to Docbook? I worry
about tool longevity and thus ongoing editability of source assets. I imagine
groff still might grind old tbl and nroff and docs into Postscript.

~~~
jimhefferon
Like many computer things, Docbook had (and as I understand it still has) a
life in a certain domain. But, for reasons that are perhaps not perfectly
clear, it never made the jump to hyperspeed. It just never became _the_ thing.

------
wiz21c
Is it me or this is like Knuth's Literate Programming ?

~~~
unkown-unknowns
The idea of literate programming is to write explanations of programs in human
language as the primary form of communicating what a program does to others.

OP link is about using code to create a document.

Probably you could use OP tool to write literate programs but that is not the
primary intention.

------
Tehnix
Hmm, is there a cheatsheet or crash course for it? Not particularly interested
in reading a book just to get my editing game on. Just throw me in the deep
water with the basics, and then I'll jump around to what I need.

Would consider using this instead of LaTeX for my thesis, but not so much if
the time investment is too much.

~~~
peatmoss
If your university has requirements around formatting (most do), then you'll
likely spend many hours making anything that isn't LaTeX (or, blech, Word) do
the right thing. For a thesis, your best case is to just use a university
provided LaTeX template and then spend as little time bike shedding as humanly
possible.

~~~
Tehnix
Luckily they don’t :) My Bsc thesis I did in a template another student had
made years ago, which swims around, but honestly LaTeX is quite tedious and
time wasting to write in for most non math heavy content, which is why I’d
prefer something else, that stills allows the same flexibility if needed.

~~~
peatmoss
My masters thesis had strict formatting requirements, and I bikeshedded the
hell out of building my own LaTeX template in part because I needed an excuse
to distract myself from... writing my thesis. And of course there were some
ambiguities in the formatting spec that resulted in me needing to track down
an advisor to resign a page in my thesis before she boarded a plane to Europe.

If I had it to do over again, I'd have spent the time I spent bikeshedding
doing something more properly restorative such as exercising or video games
or... anything else other than grokking the internals of my home-built LaTeX
template :-)

Then again, if there are no formatting requirements, a digital version will
suffice, and writing Pollen rather than your thesis brings you joy, then go
for it.

------
Sir_Cmpwn
See also werc [1] and my crappy POSIX sh rip-off of werc [2]

[1] [http://werc.cat-v.org/](http://werc.cat-v.org/)

[2] [http://git.agunix.org/wersh/](http://git.agunix.org/wersh/)

------
pathsjs
Apparently, books written in Pollen do not support scrolling (or it's just me?
I am using Firefox on a Mac)

~~~
kuschku
That should be just you, Pollen doesn’t intercept any scrolling, doesn’t set
any scroll handlers, doesn’t use custom scrollbars, etc.

~~~
pathsjs
In fact I tried on Chrome and it seems to work there. Not sure what is going
on in Firefox

------
choxi
Cool idea. Has anyone else used Racket to make DSL's for specific business
applications?

~~~
oxryly1
Yes. I spent many years doing that for games. AMA.

~~~
SwellJoe
So, how'd it turn out? Did you ship any games?

~~~
oxryly1
Yes, the "Uncharted" series and "The Last of Us". Our team built a large
system in Racket that built all kinds of data for the game. The front end
could and often did have many layers of DSLs using Racket syntax macros.

Overall it enabled us to do many things that would have required lots of
specialized tools. The downsides were things like people ramping up on editing
s-expressions in text files and lots of gotchas with hygienic macros.

~~~
SwellJoe
Well, that wasn't the answer I expected! Super cool, I wouldn't have guessed
any AAA titles were using a Lisp/Scheme heavily in their toolchain (but I'm
not particularly knowledgeable about the game industry).

I'm fascinated by procedural generation and constrained randomness in games,
and I'd think something like Racket would be a fun choice for that. Do you
reckon you'd make the same choice if you were starting today?

------
hellbanner
This looks very cool. Have you (jdoliner or anyone else) used this to publish
a book?

~~~
soapdog
Matthew Butterick uses it to publish all his current books (as far as I know),
check out some of them at:

* [https://beautifulracket.com/](https://beautifulracket.com/) (and this about making it [https://beautifulracket.com/appendix/racketcon.html](https://beautifulracket.com/appendix/racketcon.html))

* [https://practicaltypography.com/](https://practicaltypography.com/)

~~~
MikusR
One of your links
[https://practicaltypography.com/](https://practicaltypography.com/) redirects
to this
[https://practicaltypography.com/graylist.html](https://practicaltypography.com/graylist.html)
a site that has no content and asks to pay for something.

~~~
empthought
If you read it and follow the instructions, you will see how to access the
original link without needing to purchase anything.

~~~
MikusR
So i follow a link, supposedly about a book, and i see a wall of text trying
to sell me something with no information what that something is.

That reminds me of this: “But look, you found the notice, didn’t you?” “Yes,”
said Arthur, “yes I did. It was on display in the bottom of a locked filing
cabinet stuck in a disused lavatory with a sign on the door saying ‘Beware of
the Leopard.”

~~~
empthought
It is checking the referrer value and only displaying it to people from
reddit, HN, etc. -- because when traffic spikes due to those communities, it
can be expensive.

Given the choice between this and advertisements, I much prefer this.

------
alex_g
At the end of the day, how is this an improved experience for the reader?

~~~
jdoliner
There's nothing from a readers perspective that you can accomplish with Pollen
that couldn't be accomplished in some other way. But if it makes author's
lives easier they'll publish more which improves the reader's experience.

~~~
jimhefferon
Making texts that are active is currently a hard job. There is a fairly large
set of technologies to know, and an author can worry that each of those will
have a limited life.

People who have something to say, and who know all the techs, and who are
willing to keep their work up, may well be a small set.

------
ai_ia
How can I integrate pollen with my Meteor-React Stack website?

------
zeamaize
> I chose the lozenge as the command character because a) it appears in almost
> every font, b) it’s barely used in ordinary typesetting, c) it’s not used in
> any programming language that I know of, and d) its shape and color allow it
> to stand out easily in code without being distracting.

> If you’re using DrRacket, you can use the Insert Command Char button at the
> top of the editing window to — you guessed it — insert the command
> character.

> If you’re using a different editor, here’s how you type it:

> Mac: Option + Shift + V > Windows: holding down Alt, type 9674 on the num
> pad > GNU/Linux, BSD: Type Ctrl + Shift + U, then 25CA, then Enter

> For more information on entering arbitrary Unicode glyphs, see Wikipedia.

Jesus Christ that's a terrible design.

~~~
wodenokoto
He also advocate not using underline to denote links. In his practical
typography book he practically hides all hyperlinks.

I also find his redesigns of documentation pages uninviting to read.

I find Butterick to be a passionate, opinionated, hard working, but ultimately
a poor designer.

~~~
munificent

        > He also advocate not using underline to denote links.
        >In his practical typography book he practically hides all hyperlinks.
    

I think that's a fine, defensible stylistic choice. When reading a paragraph
of prose, I find it INTERRUPTS MY FLOW if there is a jarring style change in
the middle of a sentence, as in this one.

The visual style of a hyperlink is only relevant to the point that you know
the hyperlink is there and can find it when you want to click on it. Most of
the time, that's not a goal, so you want it to fade into the background unless
the user has indicated that _is_ their goal.

So my preferred style for hyperlinks in prose is a color that's right at the
just-noticeable difference [1] relative the normal text. When you mouse over
the paragraph, which indicates you are intending to click, the contrast
increases.

[1]: [https://en.wikipedia.org/wiki/Just-
noticeable_difference](https://en.wikipedia.org/wiki/Just-
noticeable_difference)

~~~
vanderZwan
> _When you mouse over the paragraph, which indicates you are intending to
> click, the contrast increases._

What would you suggest in the case of touchscreens? Increased contrast while
scrolling with a slow fade-out afterwards?

~~~
munificent
Ooh, that's a great question. I haven't thought about that (though I do
generally try to make my designs responsive and mobile-friendly). I like your
idea of a slow fade after scroll.

~~~
arantius
> I like your idea of a slow fade after scroll.

Things blinking/fading/shifting/changing when I'm taking completely unrelated
actions (or, worse, all on their own) is one of the most unreadable/unusable
design decisions I regularly face. It's a good way to get me to close a tab,
regardless of any other factors.

------
stefanwlb
The web browser display is very beautiful. But how would I go about seeing it
offline? Is there a PDF sample of Pollen I can try on my eBook reader?

~~~
inetsee
One thing that disappoints me about Pollen is that I haven't seen any easy way
to produce output in the Epub format.

