Live data from Hacker News

Hyperflask – Full stack Flask and Htmx framework

hyperflask.dev

151–160 of 160 posts

Re: Hyperflask – Full stack Flask and Htmx framework

#151
post #148

Earlier quoted context omitted.

So, redux? It's either redux or, sorry, "lifecycles magic + probably global_state". And who uses redux in 2025?

Honestly, if you’re getting thru life with this attitude, good for you, but you might want to consider if it’s the only way

I'm doing fine, thank you. Perhaps you didn't understand what I said.

My best ballpark guess for global redux usage in react projects is between 25% and at best 50% if you include redux/TEA-like libraries, but not non-pure usage.

So yes, saying that react is `ui = f(state)` does everyone a disservice. It might be true for you, but it's probably not even the average.

Re: Hyperflask – Full stack Flask and Htmx framework

#152

Earlier quoted context omitted.

SQLAlchemy Core isn't an ORM, it's just a very good query generator. Although nobody seems to use the term ORM correctly any more so it's entirely possible that neither is peewee or sqlorm. The story behind why ORM is nowadays no longer used correctly is kind of funny: 1. Query generator sounds primitive, like cavemen banging rocks together. Software engineers are scared of primitive technologies because it makes the…

I don’t know if I buy that. Object-relational mapping can in principle be a broad spectrum of possibilities. SQLAlchemy (the original, not Core) is an ORM that still exposes some of the underlying relational aspects. It is still basically a query generator, just with the helpful step of converting selected tuples into objects, and tracking changes to those objects. This means that it is often possible to solve ORM-re…

Cool, the term "object-relational mapping" does indeed sound broad, as if it could be applied to merely the act of mapping tuples into something more structured, but that doesn't matter. It has a definition.

If people started using the term "data serialization" to mean taking parallel data and making it serial (for an English speaker, a perfectly reasonable meaning) would you say that this is what data serialization also was?

The term object-relational mapping refers to the very specific concept of taking relational databases and letting you access them as if they were a database of objects. Specifically, in which you had objects which held one-to-one or one-to-many or many-to-one references to other objects etc. This is a graph. The object-relational mismatch deals with the fact that relational databases and graphs are fundamentally different such that there isn't a well defined way to represent all kinds of one as the other and vice versa. Moreover, there is a performance penalty to attempting to pretend that your relational database is a graph database, and querying the relational data in ways which would make sense for a graph database.

In the case of SQLAlchemy ORM (not Core) when I worked with it back in 2018 now you could select all users from a table, or all orders. But if you wanted to select the most recent order for each user, it's much harder and requires breaking more abstractions than if you were to do it using a query generator. This is because SQLAlchemy ORM expected you to represent your data as a graph:

    class User(Base):
        __tablename__ = "users"
        id: Mapped[int] = mapped_column(primary_key=True)
        name: Mapped[str] = mapped_column(String, nullable=False)
        orders: Mapped[list["Order"]] = relationship(back_populates="user")
If you _just_ use the ORM you would write something like:

    users = session.query(User).all()
    most_recent_orders = []
    for user in users:
        if user.orders:
            most_recent = max(user.orders, key=lambda o: o.created_at)
            most_recent_orders.append((user, most_recent))
This is the n+1 query problem, and the performance would tank.

To avoid this, you have a few options, the simplest seems to be to add a virtual fiend to your User object which holds the most recent order:

    User.most_recent_order = relationship(
        Order,
        primaryjoin=Order.user_id == User.id,
        order_by=Order.created_at.desc(),
        uselist=False,
        viewonly=True
    )

    session.query(User).options(selectinload(User.most_recent_order)).all()
But this still isn't performant, as there's going to be a double-select, one for the users, and one for the orders (filtered by the users).

If you want to do this performantly, with one final query, you end up needing an alias:

    RankedOrder = aliased(Order,
        select(
            Order.id, ...,
            func.row_number()
               .over(partition_by=Order.user_id, order_by=desc(Order.created_at))
               .label("rnk")
        ).subquery()
    )
    session.execute(
        select(User, RankedOrder)
            .join(RankedOrder, RankedOrder.user_id == User.id)
            .where(RankedOrder.rnk == 1)
    )
All this and you don't get users with their corresponding order contained within, you get an abstraction leaking sequence of tuples and their corresponding orders.

This is just one single mildly non-trivial example. All this extra boilerplate just to get performance.

Meanwhile if you use just Core:

    ranked = select(
        orders.c.id, ...,
        func.row_number().over(
            partition_by=orders.c.user_id,
            order_by=desc(orders.c.created_at)
        ).label("rnk"),
    ).subquery()
    query = (
        select(users, ranked)
            .join(ranked, ranked.c.user_id == users.c.id)
            .where(ranked.c.rnk == 1)
    )
Which looks like literally the final "ORM" code.

This is what I mean when I say ORMs are either not actually ORMs or their users aren't using the ORM part for the most part.

Re: Hyperflask – Full stack Flask and Htmx framework

#153
post #132

Some interesting concepts: - Components: https://hyperflask.dev/guides/components/ - Bundling view and controller in the same file: https://hyperflask.dev/guides/interactive-apps/ I think these may be footguns though. Components for example are just a regular macros under the hood. Why not use macros then? I'm also curious about the choice of Flask. I started with a similar approach for /dev/push [1], but ended up mo…

I moved to Quart instead. It's flask with async support built by the same developer.

Quart was interesting, but it didn't seem to have as much traction as FastAPI. I also seem to understand Flask is trying to integrate some of Quart's ideas.

Re: Hyperflask – Full stack Flask and Htmx framework

#154
post #17

Hello, author of hyperflask here. I'm happy to finally announce this project as I've been working on it for quite some time. I made an announcement post here: https://hyperflask.dev/blog/2025/10/14/launch-annoncement/ I love to hear feedback!

yo, i'm the htmx guy this looks awesome!

Didn't recognize you without the horse picture.

Re: Hyperflask – Full stack Flask and Htmx framework

#155

Earlier quoted context omitted.

This is complete nonsense. I’ve written a few ORMs and you have the same performance executing a select and getting rows back and translating them into objects than you do my ORMs. It’s literally the same. Are you going to return back a Row* from your function? No. You’re going to return an object or an array. Building that from an array of rows is no different than an ORM mapping those rows for you using instruction…

You seem to be disagreeing on what the term ORM means and using the new, not very useful, and very far from the original definition. I do recommend you look at the literature of the time when ORMs and the "Object Relational Mismatch" became a hot topic and look at how ORMs worked and how people used them. Because you would be surprised to find that it's nothing like what you describe. I didn't say you didn't want a q…

Agree to disagree.

Your last sentence negates anything you claim.

Re: Hyperflask – Full stack Flask and Htmx framework

#157

Earlier quoted context omitted.

You mean I should be storing the state of a popup menu in my database?

Correct. That's literally what happens with the scroll position, and share modal in this demo (QR code is generated on the fly on the backend): https://checkboxes.andersmurphy.com

There is a noticeable delay between interaction and response (~200ms), which is way over the usual 16ms budget for smooth interactions. I think you need some pending state on the client, but that sort of breaks the idea of storing all state on the server haha.

Re: Hyperflask – Full stack Flask and Htmx framework

#158

Earlier quoted context omitted.

I don’t know if I buy that. Object-relational mapping can in principle be a broad spectrum of possibilities. SQLAlchemy (the original, not Core) is an ORM that still exposes some of the underlying relational aspects. It is still basically a query generator, just with the helpful step of converting selected tuples into objects, and tracking changes to those objects. This means that it is often possible to solve ORM-re…

Cool, the term "object-relational mapping" does indeed sound broad, as if it could be applied to merely the act of mapping tuples into something more structured, but that doesn't matter. It has a definition. If people started using the term "data serialization" to mean taking parallel data and making it serial (for an English speaker, a perfectly reasonable meaning) would you say that this is what data serialization…

> orders.c.id

you don't need .c. in recent releases, you can just use the same model attributes as in orm.

Re: Hyperflask – Full stack Flask and Htmx framework

#159

Earlier quoted context omitted.

This is complete nonsense. I’ve written a few ORMs and you have the same performance executing a select and getting rows back and translating them into objects than you do my ORMs. It’s literally the same. Are you going to return back a Row* from your function? No. You’re going to return an object or an array. Building that from an array of rows is no different than an ORM mapping those rows for you using instruction…

You seem to be disagreeing on what the term ORM means and using the new, not very useful, and very far from the original definition. I do recommend you look at the literature of the time when ORMs and the "Object Relational Mismatch" became a hot topic and look at how ORMs worked and how people used them. Because you would be surprised to find that it's nothing like what you describe. I didn't say you didn't want a q…

You seem to be the odd one out with a very particular, niche, and nonperformant definition of ORM.

Re: Hyperflask – Full stack Flask and Htmx framework

#160
post #148

Earlier quoted context omitted.

Honestly, if you’re getting thru life with this attitude, good for you, but you might want to consider if it’s the only way

I'm doing fine, thank you. Perhaps you didn't understand what I said. My best ballpark guess for global redux usage in react projects is between 25% and at best 50% if you include redux/TEA-like libraries, but not non-pure usage. So yes, saying that react is `ui = f(state)` does everyone a disservice. It might be true for you, but it's probably not even the average.

Well, for anyone using Vue you get automatic observability baked in, right? And reactive programming state management libraries within react are plenty popular, not to mention the built in state management being quite literally UI = f(state).

The fact people use the tortured disaster that is redux isn’t really a knock on react in any sane person’s view, we all know the JS community is full of beginners who don’t know better

Post reply on HN