Hacker News new | ask | show | jobs
by meredydd 1141 days ago
> something like Pynecone that targeted html/dom/js directly instead of wrapping node/react/next

This might not be what you were imagining, but I think this js more or less what we built at https://anvil.works (I'm a founder).

Anvil's UI toolkit is built "straight on the DOM", and it's shaped like Python objects rather than going via some other React-y abstraction. This is possible because we expose the difference between client and server code - even though they're both in Python (transpiled as necessary), and you can make mostly-transparent function calls from one to the other. Contrast Pynecone, where the UI is "puppeteered" from the back end over a websocket, so every update is a round-trip. And of course, because you're writing in-browser code, the HTML/JS interop is pretty straightforward (in fact, you can import JS objects right into Python code).

There are downsides to our approach, of course - the developer needs to understand the difference between code in the browser and on the server, which can be a hurdle, and it's really neat that Pynecone apps can be a single Python file - but you don't have to round-trip every UI update to the server, and we've seen people have scaled up to some pretty big apps with Anvil!

2 comments

Anvil has been great. I'm a happy subscriber. As someone requested above for Pynecone, could Anvil also make a tutorial for creating ChatGPT clone (UI wrapper for ChatGPT/gpt-4) using Anvil?
Agree a little different approaches, we found many developers wanted to stick with a 100% code approach and avoid the constraints of using an online drag and drop builder like retool/anvil etc. Instead opting to stick a traditional code tech stack that provides benefits like easier version control with ui and reviews with larger teams. Where as with a low code tool you are now forced to develop on the ui platform and locked in by the vendor.

We have also had some users build some fairly large Pynecone apps including our whole website built in our own framework.

Oh, yeah - "text in a Git repository" is table stakes for developers. Ditto being open source to avoid lock-in. (Which is why Anvil has both! You can check your code out, edit in VS code, and host locally.) But if you want a visual UI editor, you gotta have the tooling somewhere...

Aside: I get grouchy about the term "low-code", mostly because it's almost always a lie (you're going to need the code, and most "low-code" systems just hide how much that's going to hurt - which is why we put the code front and centre), and it causes people to lump Anvil in with, eg, Retool rather than, eg, Pynecone/Viola/Beeware...but this is definitely getting off topic ;)

Interested to hear how your scale-up/B2C users deal with the round-trip delays - I guess that's less of a deal with websites than interactive apps? (Should probably have grabbed you at PyCon to ask, but we were both pinned down pretty hard! I did manage to wave at you though, I think...)

Yeah Pycon was busy but next time :)

Will be improved in the future as we start to offload client side actions with wasm, starting to do this but the python wasm ecosystem is still maturing

slight aside, but it's refreshingly pleasant to see a cordial discussion between representatives of two competing aproaches. HN is better than some other sites, but there's still a fair bit of polarised "my choice is right and so yours is wrong".

I didn't know about either Pynecone or Anvil, and have a side project for a friend that might be well suited to one/both. So I'm both more enlightened on options, and more predisposed to both given the positive dialogue here. Thanks for both.