Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by Sn3llius on Tuesday September 17, 2024 @01:25PM
(#41570211)
Rio dev here. I 100% agree with you. We aren't expecting for JS developers to flock to rio en-masse. Instead, we're targeting the many, many Python devs that have been completely left out in the web revolution and are still stuck construcing user-interfaces using tkinter and similar.
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by synergy20 on Tuesday September 17, 2024 @12:26PM
(#41569391)
Hopefully JSX can be more mainstream, that is, I can use it directly in js/html/css projects without all the extra tools pre-installed and pre-configured, making jsx part of the 'vanilla' development will be really nice(no react, no vuejs etc).
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by timkq on Wednesday September 18, 2024 @11:22AM
(#41580884)
I agree about the JSX part - but the thing about real dev is that you have to use all the tools you can, so you don't have to reinvent the wheel. Nobody's still making Windows-only GUI apps using the Win32 API - it's easier and all, but there's so much stuff you have to code yourself that it's simpler to learn a GUI library/framework and Just Use That. I had a quick glance at HTMX - and it seems to just be going backwards (similar to Go - the language is so simple that it's actually hard to code real stuff in it). Why should I make an API that's essentially web only (because you have to send back HTML from the server using HTMX) if I can just use JSON/Protobuf/etc. and with just a few build tools I can automatically generate functions that I can call directly in JS. Sure, it's easier to build a website with plain JS (and by that HTMX, which is glorified plain JS) but this is the real world.
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by recursivedoubts on Wednesday September 18, 2024 @02:59PM
(#41584039)
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by nomdep on Tuesday September 17, 2024 @01:12PM
(#41570031)
> If I need a database, I'll grab SQLAlchemy. I wish there were a mature lightweight solution here; maybe Tortoise ORM will get there soon?
[Peewee ORM](https://docs.peewee-orm.com/)
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by davepeck on Tuesday September 17, 2024 @02:06PM
(#41570733)
Peewee never quite got there IMO, and it hasn't kept up with the times (modern asyncio, etc.)
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by nomdep on Tuesday September 17, 2024 @10:23PM
(#41575082)
Is there really an “etc”? Beyond asyncio, I haven’t found anything that SQLAlchemy can do that Peewee can’t even more easily.
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by mixmastamyk on Tuesday September 17, 2024 @12:38PM
(#41569581)
Where’s a good place to learn about the web components aspect? I’ve tried a few times (and the shoelace docs) but it doesn’t stick.
Re:Rio-labs/rio: WebApps in pure Python. No JavaScript, HTML...
by davepeck on Tuesday September 17, 2024 @12:54PM
(#41569783)
I may be the wrong person to answer, alas. I nearly entirely avoid the machinery of web components.
With the stack above, I typically write small classes that derive from HTMLElement and implement a couple key callbacks (usually, connectedCallback and disconnectedCallback). In those, I typically (a) initialize state by reading attributes from the DOM and (b) configure event handlers. Pretty simple.
That's... about it. I'm templating elsewhere, so I avoid using web component templates. And the less I think about the shadow DOM, the better.
For this, the MDN documentation on custom components is enough.
---
For me personally -- and I'm guessing for a bunch of other HNers -- writing full-stack web apps strictly in python is a non-goal.
I've settled on a comfortable (for me) stack for smaller projects that need python on the backend that combines:
1. Litestar (or another lightweight HTTP framework of choice like flask, etc.)
2. HTMX
3. htpy.dev (an in-python HTML builder)
4. Custom web components implemented in a plain-old JavaScript ES6 module loaded directly by the browser
A typical project only needs a handful of components. HTMX and htpy.dev both play very nicely with web components.
When I want zero build steps, I write plain JavaScript + JSDoc comments. JSDoc is... okay-ish, but it ain't no typescript.
If I need a database, I'll grab SQLAlchemy. I wish there were a mature lightweight solution here; maybe Tortoise ORM will get there soon?
There's nothing in this stack that couldn't strictly be done in javascript-land. JSX syntax with HTMX is pretty great and much better than any in-python HTML builder. But often my projects have other requirements (like ML) where python is, at least today, inevitable.