• expr@programming.dev
      link
      fedilink
      arrow-up
      11
      ·
      9 months ago

      Modern PHP isn’t half bad, and it has at least two major benefit over some of its competitors: Each request is a totally independent request that rebuilds the world. There’s no shared state (unless you want there to be).

      …isn’t that how every web framework works?

        • expr@programming.dev
          link
          fedilink
          arrow-up
          3
          ·
          9 months ago

          Yikes, pretty bizarre considering stateless endpoints is the gold standard.

          Re: persistent process, that doesn’t seem like a big deal, to me. It’s pretty normal since you often want to keep some common stuff going, like metrics. Unless you’re doing something crazy it should really take next to no resources while idling.

          • adrian783@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            9 months ago

            for content sites, stateless is fine. for web apps you need states of all different kinds. even the smallest detail is a state in an application.

            endpoints themselves are stateless, but the web application is stateful. you only have to build the world once, and its much friendlier for end users.

            • expr@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              9 months ago

              I wasn’t talking about frontend state, just the server. Frontend state is kind of irrelevant, tbh.

    • xigoi@lemmy.sdf.org
      link
      fedilink
      arrow-up
      3
      ·
      9 months ago

      Each request is a totally independent request that rebuilds the world. There’s no shared state (unless you want there to be).

      I with there was a language with this model, but without the language itself being completely garbage.

      • RonSijm@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        9 months ago

        Isn’t that the same as modern languages? For example in ASPCore / C#, you can just register all your services with a lifetime scoped to the request, and then there’s no shared state.

        If you want there to be a shared state, you’d just have to register your services with a higher lifetime scope, like with a singleton scope

      • redcalcium@lemmy.institute
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        9 months ago

        You can still use CGI with Apache. Apache will execute your program on each request and return its output from stdout as webserver response. If you have a form, it’ll get POSTed to stdin when Apache execute your program. You can write your program with whatever language you want as long as you can read stdin and write to stdout. It’s just tedious af so no one really use it these days. PHP was basically born because people got tired writing CGI program with pearl or C and want something more convenient. But with modern programming languages, perhaps CGI is not too bad, except the one process per request which will absolutely kill your server the moment you have visitors spike.