Zach Drake's Blog

Programming

Peanut Butter and Jelly: Why Python and JavaScript Belong Together

·
By Zach Drake

Peanut butter is the dependable one. It shows up in the pantry, it does not need to be refrigerated, and it will hold a sandwich together on a long hike. Python is peanut butter: batteries included, readable, and quietly everywhere — from data science notebooks to the glue scripts that keep a server farm alive.

Jelly is the flashy one. It is bright, it is sweet, and on its own it is a little too much. JavaScript is jelly: it runs in the one runtime nobody can avoid — the browser — and it turns a dry piece of toast into something you actually want to eat.

A jar of peanut butter labelled Python

Neither one is a complete lunch. A jar of peanut butter with no jelly is a sad, sticky mouthful. A spoonful of jelly with no peanut butter is a sugar rush followed by regret.

The sandwich is the stack

The reason the PB&J works is that the two spreads are complementary. The peanut butter gives structure and protein; the jelly gives sweetness and acid. In software terms, Python is where the durable logic lives and JavaScript is where the user actually touches it.

A jar of grape jelly labelled JavaScript

Most real projects end up doing exactly this. A Python service behind an HTTP API, and a JavaScript front end that renders it. The two of them are not rivals — they are two halves of the same sandwich.

A peanut butter and jelly sandwich labelled Python and JavaScript

Keeping the sandwich in one place

The important part is that all of the ingredients for this post — the Markdown and the images — live together in a single directory:

content/
└── blog/
    └── peanut-butter-and-jelly/
        ├── index.md
        └── images/
            ├── peanut-butter.svg
            ├── jelly.svg
            └── pbj.svg

The {attach} links are what make this work. When Pelican builds the article, each {attach}images/... reference is rewritten and the linked file is copied into the article's output directory, preserving the images/ relationship. The post is a self-contained bundle: move the folder, and everything it needs comes with it.

So the next time someone tries to start a language war, point out that nobody argues about whether a PB&J should have peanut butter or jelly. You put them together, and you get lunch.