Show HN: A Spatial Environment for Python (python.natto.dev)

169 points by paulshen ↗ HN
Hi all! A little background: I've been working on natto.dev, a spatial environment for JavaScript. I'm really excited about new interfaces for code (leveraging metaphors we're good at, spatial reasoning, making state visible, design tools, etc). With all the buzz around PyScript, I discovered Pyodide and got it working inside natto. This Python version is a stripped down version of https://natto.dev (eg interactive outputs, multiplayer) so please check that out if this interests you.

I'm excited to share this spatial environment for Python. Imagine Jupyter cells arranged on a 2D canvas.

Some key differences from traditional Python notebooks:

- By default, cells rerun whenever its code changes or an input reruns, like a spreadsheet!

- Dependencies are explicit. There is no parsing or global scope.

- Duplicate panes by option-dragging. This is a core interaction in design tools for exploring ideas.

- State panes add interactive elements. Check out this scikit demo https://python.natto.dev/example/de5cae3dfbcb43919981cc14203...

- Python execution happens in your browser as WASM via Pyodide (implementation detail, not design choice). This is currently a demo, not meant to replace your production ML notebooks.

I would love to hear your feedback on any of this and your thoughts on new programming interfaces!

33 comments

[ 1.9 ms ] story [ 91.8 ms ] thread
(comment deleted)
> By default, cells rerun whenever its code changes or an input reruns, like a spreadsheet!

This is transformational — I’ve been using Pluto.jl a lot lately for prototyping library code and doing data analysis. Now when I work in python I find myself really missing that reactivity. The closest thing I’ve found is streamlit, which is cool but not quite as liberating IMO

Can’t wait to try it!

(comment deleted)
>> By default, cells rerun whenever its code changes or an input reruns, like a spreadsheet!

> This is transformational

Just a note, but this has been around for forever in tools and languages like TouchDesigner, vvvv, Max, Pure Data, LabVIEW, with various permutations on the idea.

I've never heard of any of those.
Cool, thanks for the references! LabVIEW is the only one I’d heard of

I didn’t mean to imply that there’s no prior art (observable also comes to mind), but I’ve just gotten so frustrated lately with how easy it is to make an unsustainable mess in jupyter. Factoring code into modules and auto loading those helps, but it’s still easy to get in trouble with implicit state

RxPy and "Functional Reactive Programming" (Flow Based Programming) also seem related, albeit they are not visual tools.
Love the concept and design language! I had been thinking about making something like this for clojure for some time, but never got around to it. In my head I was thinking you would be able to drag in functions from libraries / other namespaces into the canvas. I'm gonna have to play around with this.
I love that phrase "drag in X". It's closer to how we interact with objects in the real world. Coding should feel more like that!
cool UI design
Very cool.

What is the front-end built in?

good ol' React and TypeScript! The Python magic here is Pyodide.
would be interesting to see frontends written in pyscript one day!
Can you give a brief background what "spatial" means in this context? I do not see a map, or projections. Is it pure spatial-"math" (e.g. geometries) etc.?
That is what I thought too, but here it means a node-graph, nothing to do with GIS.
Sorry! I meant "spacial interface" referring to how panes are laid out on a 2D canvas.
This is awesome, and I'd use it immediately if I could install it on a machine of mine.

One interesting thing to pursue may be memoization for block output (perhaps with limited slots or TTL).

Thanks! I'm curious why you want to install it. All the Python runs in your browser and never leaves it. Do you want to use it offline? Or is it a matter of trust? (I understand!)
Just speaking for myself, but if I can't fully self-host or run a service offline, the odds that it will be gone/I'll have to find a replacement after a (buyout|bus accident|burnout) really get in the way of embracing tools.
Amazing! Do you have plans to make it srlf-hosted? I'd love to try it!
Nice tool ! IMO a self hosted option is mandatory for product adoption as python is often used to process data, which might be confidential enough to prevent the use of SaaS tooling from a not "Well Known" service provider...
It's pyodide so I imagine everything is happening in the browser...
> Python execution happens in your browser as WASM via Pyodide
I love it, I am not sure yet what I am going to do with it but I definitely want to use it. I really love this kind of software and the execution focuses on the right spots.

This looks like the result of a lot of work, keep on !

A tangent: how hard would it be to integrate Elm into this? I think as a language it has a lot of teaching potential combined with natto.

One library that could be useful is elm-ta-interop maybe...

> - Dependencies are explicit. There is no parsing or global scope.

I can't express how happy it makes me to read this! So many "modern" tools these days come with global state and force you to do lots of implicit dependency juggling. This makes it hard to test things, to read code, to re-use code… It's as if we have to keep re-learning the same lessons again, and again, and again…