When scrolling through Lemmy, I often will see the same posts from the previous page - usually as the first links on the current page I’m on.

  • @jetA
    link
    English
    18
    edit-2
    10 months ago

    Lazy programming.

    The naive way to do pagination is to say show me items x through y. But obviously if the back end is dynamic, x through y could change. So the better way to program pagination is to say show me items above item n, too item n plus x, where n is a specific post rather than an index. Then you can have dynamic pagination based on the last comment, you saw.

    Another way to do this is have your session look at a static snapshot of the dynamic database, until you refresh the page or go back to the top. This is possible with a lot of different databases, kind of like how ZFS can give you snapshots of root at any time.

      • @jetA
        link
        English
        810 months ago

        It’s a valid design choice. But it is to keep the programming simple. One might characterize that kind of choice as lazy. Especially in terms of user interface. But I’m not beating up on Lemmy. I’m just explaining to the original poster the trade-offs that people make.

        • @Thehalfjew@lemmy.world
          link
          fedilink
          39 months ago

          It’s not necessarily lazy. If I want to go back to a particular post I saw on page 1 when I’m on page 2, but it was knocked off the front page, how would I find it? It’s no longer on page 1, so back would miss it. I’d have to go to 1 and then back again to 2 to find a post that moved.

          It gets even more complicated when the algorithm also changes post order.

          Sometimes simple with minor inconvenience is the best option.

          • @hedgehog@ttrpg.network
            link
            fedilink
            English
            19 months ago

            In an endlessly scrolling implementation, you’d just scroll up.

            Without endless scrolling, it could behave as follows:

            1. Moving back to page 1 takes the user to where they were on page 1 when they navigated away, with the same items visible
            2. When automatically fetching new posts, either expand the page (pushing nothing off) or make it visually clear that pages will be pushed to the next page. Or just don’t fetch new posts automatically, and only reset the first / last post of a page if the user clicks Refresh.
    • @4am@lemm.ee
      link
      fedilink
      English
      69 months ago

      “Let’s have each user take an individual snapshot of the database to scroll over until they refresh like in ZFS” ok buddy

      Tell me you’ve dabbled in homelab stuff without telling me you’ve never designed a high traffic web backend

      • @jetA
        link
        English
        11
        edit-2
        9 months ago

        Sir, you hardly know me! Disagree fine, but don’t assume my pedigree.

        FWIW temporal tables, and time travel are real things available now and they are built very similarly to ZFS versioning.

        If we are truly trying to make a highly scalable distributed website, we wouldn’t be querying a database directly, would be using something distributed. Like foundationDB, or memcached. And we would have to modify our approach somewhat, but these are still solvable problems. The architecture and the requirements are tightly coupled. But we can’t make assumptions and rule out solutions at the whiteboard stage.

      • Kayn
        link
        fedilink
        English
        29 months ago

        Why do you have to be so condescending from the get-go? Just explaining why it wouldn’t work would have been fine.

        • @False@lemmy.world
          link
          fedilink
          1
          edit-2
          9 months ago

          To be fair it’s in response to a guy that started off by calling the programmers lazy.

          • Kayn
            link
            fedilink
            English
            -19 months ago

            That explains, but doesn’t excuse.