Hacker News Re-Imagined

PHP 8.1.0 Release Announcement

  • 204 points
  • 5 hours ago

  • @AegirLeet
  • Created a post
  • • 114 comments

PHP 8.1.0 Release Announcement


@rbanffy 2 hours

Replying to @AegirLeet 🎙

Genuinely curious: who here thinks PHP is a good choice for a new project and also has experience with other languages such as Scala, Kotlin, Python, or JavaScript and their respective web frameworks?

Reply


@shruubi 1 hour

Replying to @AegirLeet 🎙

As someone who has worked in a lot of languages and now works in PHP, I think that while PHP still has some of the same warts it did in the old days, I am also understanding that given PHP is, for better or worse, a fundamental piece of web infrastructure, and that providing an upgrade path while also ensuring that they don't just break a large chunk of the web is less a matter of "software conservatism" and more a responsibility of the dev team.

And, if we're being honest, the reality is that for that chunk that would break, most of them would either not have a developer on hand to fix it, or would be what I call a "Wordpress cowboy" who has a WP site they set up five years ago that they never update, and the sum total of their development experience is installing various WP plugins until the site vaguely does what they want it to do.

It's hard, because on one hand, if we didn't have things like Wordpress, then PHP would be in a position to undertake more breaking changes that would overall give the language and its libraries the much needed quality improvements. On the other hand, without things like Wordpress, it does become somewhat questionable as to whether PHP would have survived the dark days of PHP4 and the early versions of PHP5.

In saying all that, the work that the dev team have done to add great features and solid performance, alongside the community which has done a lot of good things like PSR's and the PHP League libraries to me, is one of the key things that makes PHP still an attractive environment to work in.

Reply


@tarokun-io 4 hours

Replying to @AegirLeet 🎙

I haven't written PHP in years but I get the feeling from this release that they are taking inspiration from TypeScript and JavaScript.

Reply


@firefoxd 3 hours

Replying to @AegirLeet 🎙

I've been using PHP since 5.x. Often had to work on older 4.x web apps. I find it interesting when I read people saying "PHP has come a long way. It's a proper language now, etc."

If you work long enough with a language and figure out most its quirks, it's a breeze. It's nice that they are adding all these new features, but they are hardly what makes it or break it for me.

Here is the one features that is taken for granted in "modern stacks":

Edit file -> Alt+tab ctrl+R. Oops, Alt+tab fix -> Alt+tab ctrl+R.

When debugging I can do that 50 times a minute. With my react app, I can do it maybe 5 times a minute. With my golang app I'm lucky if I can do it twice a minute.

Reply


@pdenton 3 hours

Replying to @AegirLeet 🎙

Question: does class_exists still return TRUE when given the QCN to an enum?

Because it's not possible to instantiate an enum, if one appears in the constructor of a class it'll break auto-wiring. I've written my own IoC containers and one fundamental assumption in them is that when class_exists returns true, it is what it says on the tin. Using a specialized factory would still be possible. I wonder if other containers would break on seeing enums as well, but I hope they fixed this because it's not mentioned in the breaking changes. The documentation for class_exists doesn't mention enum.

Reply


@jdjdjrj 3 hours

Replying to @AegirLeet 🎙

Say what you want about PHP, but here we are decades later. I'm still using it, it still works, and it's still getting updated and improved.

Reply


@EGreg 4 hours

Replying to @AegirLeet 🎙

What is this?

  class User 
  {
    /**
     * @Assert\All({
     *     @Assert\NotNull,
     *     @Assert\Length(min=5)
     * })
     */
    public string $name = '';
  }
  PHP 8.1
  class User 
  {
    #[\Assert\All(
        new \Assert\NotNull,
        new \Assert\Length(min: 6))
    ]
    public string $name = '';
  }

Reply


@bilal4hmed 4 hours

Replying to @AegirLeet 🎙

I haven't written PHP since the 5.0 release but its amazing to see how it has grown over the years. Seems to have picked up a few nice things and is still enjoying usage even today.

Reply


@marcodiego 4 hours

Replying to @AegirLeet 🎙

Still holding the web. Happy to see it is continually evolving.

Reply


@simonw 4 hours

Replying to @AegirLeet 🎙

Fibers "allow blocking and non-blocking implementations to share the same API"

That's an interesting contrast to Python where the need to use "value = await fn()" v.s. "value = fn()" depending on whether or not that function is awaitable causes all kinds of API design complexity, all the way up to the existence of tools like https://github.com/python-trio/unasync which can code-generate the non-async version of a library from the async version.

Reply


@pachico 3 hours

Replying to @AegirLeet 🎙

Everyone laughing at PHP hasn't tried it for years, I'd bet. It started clumsy, true, but it became a solid and quite elegant way of doing things.

And by things I don't mean just web development.

The current limitations I see in PHP is that there is not an official multi-core coroutines solution.

Reply


@maxpert 2 hours

Replying to @AegirLeet 🎙

Fibers!!! Who wants to bet we are a few releases away from async/await syntax now. Giving credit where it’s due Microsoft with C# pioneered the syntax and every classic (including a few modern) language has adopted the syntax.

I believe we are a few steps away from a fully builtin production ready server and db connection support.

Reply


@s-xyz 3 hours

Replying to @AegirLeet 🎙

Who is still using PHP anno 2021?

Reply


@tdrdt 2 hours

Replying to @AegirLeet 🎙

I use C#, Javascript and PHP a lot.

PHP always wins when it comes to deployment and productivity. In my opinion that's the power of PHP.

It's also versatile. I used it for small projects, multi-million € projects, COM-port communication, API communication, prototyping and what not.

The syntax is not great, but to me PHP is this multi-tool that just gets the job done and will run reliable for years.

Reply


About Us

site design / logo © 2021 Box Piper