Snakes around Jupiter

When I first heard about python interpreter in browser via PyScript in 2022, I was like: that’s coooool… but why???

It feels like the opposite of Node.js: Node.js brings javascript to server, and PyScript brings python into browser. While the async nature of javascript makes it solid for backend development, I couldn’t see a good reason for bringing python into frontend on client side. Data and machine learning are use cases where python really shines to my experience, and they seem to have very minimal overlaps with frontend or browser.

However, it turned out that I totally missed the potential of this work. Talented developers have put efforts into this direction for years, and made JupyterLite, a full static Jupyter distribution that runs in browser. This great work has inspired me and made me see what could be achieved.

Jupyter notebooks are made of texts, images, and code snippets. It provides an interactive environment backed by programming language interpreters (python, R, javascript, etc), making it very suitable for education, demo, or even development. I found it work very well with data manipulation, since it could provide immediate response on every transformation step applied to the data, enabling very fast iterations through the development.

But it could be painful to manage the runtime environment. It is very common for python users to get confused when navigating through package management tools (pip, poetry, piptools, uv, conda, etc.), and it takes quite some experience for developers to keep global and virtual runtime environments organized for projects.

The magic happens when the runtime environment is inside the browser. Modern web browsers provide a sandbox environment for computing, which is isolated and self-sustained. For Jupyter notebooks backed by a python runtime in browser, as long as the runtime is shipped with all dependencies, there will be no need for users to do anything for the runtime. This makes Jupyter notebooks completely plug-and-play for users, as long as they have a device that can run a browser. The interactive notebooks have never been so available for content consumers.

Moreoever, it also eliminates the need of computing resources for hosting, since instead of providing the python runtime on a server, it is provided as static content and runs in the browser on the client side. The interactive notebooks have been so cost efficient for content providers.

With JupyterLite, I made this lab with some demo on acoustic waves. Hope you have fun with it!

Imagine there’s no venv
It’s easy if you try
No pip or command line
It only takes, a static site
Imagine all the people
Sharing all the world
Ah

You may say I’m a dreamer
But I’m not the only one
I hope someday you’ll join us
And the world will be as one