Live data from Hacker News

React, but in Python

github.com

41–50 of 179 posts

Re: React, but in Python

#41
post #34

Earlier quoted context omitted.

Nowdays, with automatic api generation for your API, there's no difference in backend/frontend communication in type-safe way.

Curious what automatic generation you have in mind?

Say you have a function in the backend, for example in typescript:

function handler(a: A, b: B) {}

With a suitable tooling, you can generate the type for frontend to call handler(a, b) in a type-safe way, which could be validated on the backend and frontend.

So you're just a "generation" step away from bluring BE/FE communication.

Re: React, but in Python

#42

Does anyone have a list of full-stack Python frameworks for building interactive web apps? I feel like a new one comes out each week, and it would be nice to see them together to compare.

I love OP’s project. I probably won’t use it, and I say that sadly. I chased that dragon for years, but ECMA was a sleeping giant.

I do not have the answer to your question, parent, but I feel the need to evangelize vanilla JS/ECMA.

You can do everything you could do with jquery and react with very simple constructs now. Web components are slightly awkward, but damn! Possible, and easier than it ever was before js components.

Introducing any additional technologies or node is no longer necessary. The frontend has evolved.

Now. You still have to learn ECMA, but that’s what browsers definitively run as of my writing.

I can pray to mdn for wasm to be a go-to every day tech, but that day is not today.

Re: React, but in Python

#43
If you're interested in this sort of thing, but want to code in Java, try Flavour: https://flavour.sourceforge.io/

Flavour is a fast, batteries-included, type-safe framework for making modern SPA web apps in Java (and other JVM languages).

* Great Lighthouse scores? Check!

* Real SPAs without sluggish network round trips? Check!

* Modern path-based routing? Check!

* Components (built-in and user-defined)? Check!

* Effortless service calls? Check!

* Refactor frontend and backend simultaneously using your current IDE? Check!

If this sounds interesting, check out these other resources:

* Article in Java Magazine: https://blogs.oracle.com/javamagazine/post/java-in-the-brows...

* 100% Flavour 5-letter word game: https://frequal.com/wordii

* Flavour podcast (created with Castini, a Flavour app): https://castini.frequal.com/cast/show/Flavourcast/f7e171e8-2...

Re: React, but in Python

#44

I'm lost. React builds interactive UIs (web, mobile). After each interaction, the virtual DOM is programmatically recreated and reconciled to the actual DOM. But reactpy is running on a backend sever??? Is each interaction resulting in a server call? Can someone explain what is going on? EDIT: Ah, okay, thanks. Every re-render is a network call. If people complained about web UI performance before..... :)

yes, from reading the docs, there's a websocket. Making a 'server call' on each interaction is also what web apps used to do before SPAs were a thing. And in many cases it's what SPAs do as well. Of course, it depends what counts as an 'interaction', but that's been the case since JavaScript existed.

> Making a 'server call' on each interaction is also what web apps used to do before SPAs were a thing.

One of the reasons behind the popularity around webapps was that they would no longer need to make 'a server call' on each interaction.

> And in many cases it's what SPAs do as well.

I feel you're grossly misrepresenting what SPAs do. SPAs do calls to send and receive data, not to fetch server-side rendered content.

Re: React, but in Python

#45
post #23

Earlier quoted context omitted.

https://htmx.org/ Says otherwise, so does https://blog.appsignal.com/2022/07/06/get-started-with-hotwi...

I haven't used htmx but it looks nothing like pyreact. htmx is about adding attributes to html, so again, you are still writing html.

Htmx is not only about adding attributes to HTML :) check how responses to requests are expected to contain full or partial HTML instead of, say, json.

Re: React, but in Python

#46
post #34

Earlier quoted context omitted.

Curious what automatic generation you have in mind?

Say you have a function in the backend, for example in typescript: function handler(a: A, b: B) {} With a suitable tooling, you can generate the type for frontend to call handler(a, b) in a type-safe way, which could be validated on the backend and frontend. So you're just a "generation" step away from bluring BE/FE communication.

Apologies, I know what generation is. But the ABI that is the wire between the front and the back is notorious for not being stable. Such that I was asking if you have experience with a generation stack that is favorable. Most folks I know do not have favorable experience in this realm. Best I know of, are those that drop down to something like protobuff to describe the messages.

Re: React, but in Python

#47

Earlier quoted context omitted.

yes, from reading the docs, there's a websocket. Making a 'server call' on each interaction is also what web apps used to do before SPAs were a thing. And in many cases it's what SPAs do as well. Of course, it depends what counts as an 'interaction', but that's been the case since JavaScript existed.

Yep. And nowadays you can deploy apps really close to users so latency is really low. If you have <100ms you don't really notice the latency.

> And nowadays you can deploy apps really close to users so latency is really low.

That sounds like blindly throwing money at the software architecture problem you created for yourself. Supposedly SPAs became popular because your line of reasoning was embarrassingly absurd, in the sense that you do not mitigate the penalty of a network call by microoptimizing the cost of a network call.

Re: React, but in Python

#48

Does anyone have a list of full-stack Python frameworks for building interactive web apps? I feel like a new one comes out each week, and it would be nice to see them together to compare.

There are many, but here's a start:

pyjs, streamlit, brython, pyodide, pywebio, gleam, dash, bokeh, gradio, pglet, idom, anvil, pynecone, onu

The last two are YC-funded.

Edit: add https://flet.dev which has superseded pglet

Re: React, but in Python

#49

If you're interested in this sort of thing, but want to code in Java, try Flavour: https://flavour.sourceforge.io/ Flavour is a fast, batteries-included, type-safe framework for making modern SPA web apps in Java (and other JVM languages). * Great Lighthouse scores? Check! * Real SPAs without sluggish network round trips? Check! * Modern path-based routing? Check! * Components (built-in and user-defined)? Check! * Ef…

None of these links seem to work?

This site can’t be reachedCheck if there is a typo in frequal.com. DNS_PROBE_FINISHED_NXDOMAIN

Re: React, but in Python

#50
If you're interested in using React-style frontend programming in Python but want an experience / API closer to that of React, I recommend checkout out Reacton [1].

Similarly to this library, it gives you a `@component` decorator that allows you to create components out of functions. But it also: 1. Includes all existing React hooks (use_state, use_memo, etc) -- so you don't have to learn new patterns. I believe this results in a bit less magic (and so easier debugging) than just using raw variables. 2. Works with ipywidgets, so many existing data apps can be ported over very easily -- Jupyter users celebrate.

I'm not associated with the project, but I know the maintainers (creators of Volia [2]) and they are honestly excellent. I haven't use the project in production, but the getting starting guide is pretty compelling.

[1] https://github.com/widgetti/reacton [2] https://github.com/voila-dashboards/voila

Post reply on HN