Show HN: Hyperdiv – Reactive, immediate-mode web UI framework for Python (github.com)
I'm releasing Hyperdiv (https://hyperdiv.io), a framework for rapidly developing reactive browser UIs in Python, with immediate-mode syntax and using Shoelace (https://shoelace.style) as its built-in component system.
This short coding video will give you a good idea of what it is: https://www.youtube.com/watch?v=4XJKfxaqvGE
I wrote a brief article about the motivation and approach: https://hyperdiv.io/intro.html
Hyperdiv doesn't aim to compete with serious full-stack frameworks. The core aim was to make it easy and fast to prototype apps and build UI-based tools. I was originally motivated by internal tools at work -- feeling the need to quickly put together UI-based tools to share with both technical and non-technical coworkers, without having to stand up and maintain a full internal stack.
This is my first major open source release. I really appreciate your feedback and support. - Marius
83 comments
[ 0.28 ms ] story [ 219 ms ] threadHyperdiv is a generic framework with unrestricted layouts (but you can use a template if you want), and a component architecture where all components, whether UI components or internal state, are fundamentally similar and expose stateful props.
By contrast, Hyperdiv lays out UI declaratively based on state, and when state changes, the app re-runs, generating an updated UI. Streamlit and Hyperdiv seem to work similarly, though I'm not sure how Streamlit handles state and state-based layout.
Hyperdiv does this:
def my_ui(hide_text=False): button("Button 1") if show_text: text("Hello") button("Button 2")
I'd like to read the docs myself to find out, but it seems like they are not hosted on the website. I can see that I can install the package and run the docs command, but I'd really rather use the web browser I'm already in to explore a new (to me) project's docs.
You can also pass in a custom executor and use processes instead of threads.
Thanks for the feedback wrt docs app.
https://github.com/hyperdiv/hyperdiv-apps/tree/main
Have you tried training an AI chatbot to write Hyperdiv apps? It seems like a good idea, and I'm just wondering whether you've tried it and what the results have been like. I might try it myself.
In general I get the impression that this approach, of teaching an LLM a small self-contained API like Hyperdiv's, can work better/less hallucinatory compared to trying to build apps with very large APIs like the DOM API.
It's so funny how subjective that is — I liked the audio enough to tell the author about it in a DM. Then I come to HN and read that someone disagrees. :)
> htmx being involved
I think it's possible. Hyperdiv uses a custom DOM patching system but I could imagine it being swapped for an existing HTML over the wire tech.
I fully agree that it is a great project and that there is plenty of space to have different frameworks with their specialties that allow to choose the best one based on the circumstances.
The proof is in the pudding but its safe to say I'm ALL THE WAY interested right now.
Makes me realize how webdev is still just teeming with stupid levels of incidental complexity, and I'm not sure I trust webdevs to actually get us out of the tarpit.
https://news.ycombinator.com/item?id=39353269
example app: https://github.com/thejchap/pue/blob/main/example.py
good luck! i think there’s definitely something here with this kind of thing
Just today, I started exploring the current web development ecosystem in Python. As a long-time Python developer, it is amazing to see all the recent work that has gone into making the web accessible to more than just JavaScript developers.
Despite seeing all these amazing new approaches (e.g., Reflex, Streamlit, and now this), I can't help but think there is still a need to rely on "more mature tech" (though this gap is closing) to make non-trivial websites in Python (and in general). After surveying the Python (and JavaScript) ecosystem, I personally decided that a simple stack consisting of FastAPI, Pydantic, SQLAlchemy, Jinja2, Tailwind CSS, and HTMX would be the fastest approach to build a non-trivial app using Python.
With that being said, I will definitely circle back around in a month or so to see how things have progressed. I wish you all the best in making Python a contender for the next generation of web development.
SQLite, Linux, Apache/Nginx, PHP
It’s reminiscent of LAMP, so it’s very easy and cheap to deploy and maintain. I do wish the P stood for python instead of php, but Nginx integrates so well with php and doesn’t require a long running process like PM2 (nodejs) or Gunicorn.
This scratches a good itch that Streamlit just seems to baaaaaaaaaaaarely miss -- more fine-grained control of the React under the hood.
Keep it up!
I happen to be working on a standardized protocol (braid-http) for sending diffs over HTTP, and have been thinking about applying it to hyperdiv. I'd love to understand your use-case and what about plain HTML you like here.
Answering your question: it’s mostly the curmudgeonly tendency to avoid custom protocols that are harder to introspect and debug. It’s possible that the hyperdiv sync protocol is super intuitive and simple, but whenever possible I’d like to use boring web standards to reduce the surface area that I’ll feel the need to learn.
It also allows standard tools and front-ends to work with any back-end. We could have CDNs that can cache and sync dynamic HTML for a set of users without touching the server.
The dom sent over the wire is very similar to html but it’s json.
Then the diff is a json that indicates whether to add children and at which index, whether to remove children and at which index and how many, and attributes to update. This is the part I’m unsure of there being an analogue in protocols like htmx.
Easiest way to see it in action currently is to run a Hyperdiv app, open chrome dev tools and watch the websocket traffic on /ws
I hadn't heard of shoelace before, but I love how easily you split things out into named components in the demo. Really cool mix of tech
We already support frameworks like Streamlit, Gradio, Shiny, Solara, Voila, among others. Ping me if you're interested!
https://docs.cloud.ploomber.io/en/latest/intro.html
Separately, all of the above seem to lack official auth solutions. People with experience in all of these, do you just roll your own or integrate with something else?
By contrast, Hyperdiv runs everything in Python and ships DOM and DOM patches to the browser.
1. https://github.com/pydantic/FastUI
One key feature of BEAM, has always been its ability to sustain high user count with this architecture, as its totally ok to have “a thread per user” on your server.
Wondering now how hyperdiv scales to thousands/millions of users, given python’s inherently stateful nature, what’s the key tech that made it possible?
Anyway, I tried to look around and it seem to be lacked any component to upload files. Is it in the pipeline or I missed something?
[1] https://gitlab.com/BenWiser/python-live-gui