Live data from Hacker News

PHP 8.0.0 beta 2

php.net

11–20 of 102 posts

Re: PHP 8.0.0 beta 2

#11
Article with an overview of the changes: https://stitcher.io/blog/new-in-php-8

Some highlights are union types, a JIT compiler, named arguments, annotations, and match expressions.

The approach to named arguments is interesting. It's nice that you don't have to change the signature of existing functions, but the downside seems to be that you can't enforce the usage of named arguments on callers, as in other languages like Ruby and Python where keyword arguments need to be declared as such.

    function foo(string $a, string $b, ?string $c = null, ?string $d = null) 
    { /* … */ }

    foo(
        b: 'value b', 
        a: 'value a', 
        d: 'value d',
    );

Re: PHP 8.0.0 beta 2

#12
post #4

PHP is seeing a renascence and renewed interest similar to what happened with JavaScript a few decades ago. A language that's easy to make fun of but widely used is an attractive target for improvement.

Maybe I'm not in the right circles but I see absolutely no renewed interest towards PHP. Is there any reason to believe that? Honest question - PHP was my first language (or second if you want to consider mIRC scripting) and I have not so bad memories but at least me and everybody I know moved away from it years ago and don't see people going back to it anytime soon.

There's been one big change in the last 5 years – the adoption of type-inferring PHP static analysis tools in CI.

As companies started adopting TypeScript/Flow into their Javascript pipeline, PHP developers realised the need for something similar in their ecosystem.

I work at Vimeo (which has a lot of business logic in PHP) and I took it upon myself to write a static analysis tool (which you can play with at https://psalm.dev). Other similar static analysis tools were developed at other places that use PHP, and together they have helped make modern-day PHP development a little more orderly.

Re: PHP 8.0.0 beta 2

#13
post #7
post #3

PHP, since version 7.0, has been a much improved language since when many people started hating on it. They have been consistently moving the spec forward and making improvements. It's not perfect, but no language really is after all. It is really nice just seeing issues that have been around for a long time being addressed and fixed.

I have to confess that I have a lot of prejudice against PHP after having to work with it at the time of PHP3 and 4. It seemed like even worse than Perl in the sense of how many things were just bolted on it as a way that the developers could claim "yeah, you can do that with PHP". After having a blog running wordpress hacked twice by mere virtue of being online, I dismissed it for good. I keep hearing about how the…

> after having to work with it at the time of PHP3 and 4

PHP 5 was released 16 years ago and was a massive evolution of the language. The same is true for PHP 5.2, 5.3, and 7. It's safe to say that your conclusions about the language are no longer accurate.

> Is there anything that PHP is developing or adopting that can not be had at other established languages?

No. I can't think of any reason to start a new project with PHP today. All of its best features are things that have been available in other languages for years. It's also not particularly popular outside of WordPress.

Re: PHP 8.0.0 beta 2

#14
post #4

PHP is seeing a renascence and renewed interest similar to what happened with JavaScript a few decades ago. A language that's easy to make fun of but widely used is an attractive target for improvement.

Maybe I'm not in the right circles but I see absolutely no renewed interest towards PHP. Is there any reason to believe that? Honest question - PHP was my first language (or second if you want to consider mIRC scripting) and I have not so bad memories but at least me and everybody I know moved away from it years ago and don't see people going back to it anytime soon.

Symfony was the backend framework with the most contributors in 2019[1], and Laravel is seeing some huge growth in the PHP community. I think there's a lot of hype for the modern improvements in the language, and it's quite easy to manage a stateless web server in production making it a safe technology to use.

[1]: https://symfony.com/blog/symfony-was-the-backend-framework-w...

Re: PHP 8.0.0 beta 2

#15
post #9

PHP is damn good in certain areas. It is one of the best choices (if not the best choice) for rapid prototyping of a program. Its damn fast to similar alternatives (Python, Ruby, Dart, JavaScript), and the standard library is huge. It does have footguns. I am not a fan of the loose typing, but you can take some steps to mitigate. You can do "===", "strict_types" and type hinting for function input and output. It is s…

I can't believe named arguments aren't default in every language. TypeScript could have implemented it.

Re: PHP 8.0.0 beta 2

#16

If the JIT for PHP ever becomes good enough it solves the memory leak problems PHP to this day is still plagued with, that might be enough to convince me to use PHP again, possibly, for some workloads. I can't help but feel that PHPs popularity is mostly tied to Wordpress, and to a lesser extend Laravel (with Symfony coming in behind that). Not really sure the rest of the ecosystem even matters, outside those core pi…

[deleted]

Re: PHP 8.0.0 beta 2

#17
post #7
post #3

PHP, since version 7.0, has been a much improved language since when many people started hating on it. They have been consistently moving the spec forward and making improvements. It's not perfect, but no language really is after all. It is really nice just seeing issues that have been around for a long time being addressed and fixed.

I have to confess that I have a lot of prejudice against PHP after having to work with it at the time of PHP3 and 4. It seemed like even worse than Perl in the sense of how many things were just bolted on it as a way that the developers could claim "yeah, you can do that with PHP". After having a blog running wordpress hacked twice by mere virtue of being online, I dismissed it for good. I keep hearing about how the…

> Is there anything that PHP is developing or adopting that can not be had at other established languages?

IMO, no. The language is still near the bottom for both dynamic and "static" typed languages. HOWEVER, if you're doing web backend stuff, Laravel and Symfony are both really solid frameworks.

The direction PHP Is moving in right now is to emulate Java 7, but without generics or concurrency. It's definitely a dead-end unless they come up with something pretty novel and change direction (again).

Re: PHP 8.0.0 beta 2

#18
post #7
post #3

PHP, since version 7.0, has been a much improved language since when many people started hating on it. They have been consistently moving the spec forward and making improvements. It's not perfect, but no language really is after all. It is really nice just seeing issues that have been around for a long time being addressed and fixed.

I have to confess that I have a lot of prejudice against PHP after having to work with it at the time of PHP3 and 4. It seemed like even worse than Perl in the sense of how many things were just bolted on it as a way that the developers could claim "yeah, you can do that with PHP". After having a blog running wordpress hacked twice by mere virtue of being online, I dismissed it for good. I keep hearing about how the…

> Is there anything that PHP is developing or adopting that can not be had at other established languages?

Good documentation and reasonable backwards compatibility.

Re: PHP 8.0.0 beta 2

#19

If the JIT for PHP ever becomes good enough it solves the memory leak problems PHP to this day is still plagued with, that might be enough to convince me to use PHP again, possibly, for some workloads. I can't help but feel that PHPs popularity is mostly tied to Wordpress, and to a lesser extend Laravel (with Symfony coming in behind that). Not really sure the rest of the ecosystem even matters, outside those core pi…

What are the memory leak problems? I was under the impression that PHP's stateless nature, with a whole new instance of everything coming into being for each request, somewhat sidesteps the capacity for problematic memory leaks that could otherwise exist for processes that remain alive between requests.

Most web workloads will use some sort of process cache, like php-fpm, simply because spawning a process for each request is very inefficient. So the process and any extensions used can leak memory over time across requests.

Re: PHP 8.0.0 beta 2

#20

If the JIT for PHP ever becomes good enough it solves the memory leak problems PHP to this day is still plagued with, that might be enough to convince me to use PHP again, possibly, for some workloads. I can't help but feel that PHPs popularity is mostly tied to Wordpress, and to a lesser extend Laravel (with Symfony coming in behind that). Not really sure the rest of the ecosystem even matters, outside those core pi…

What are the memory leak problems? I was under the impression that PHP's stateless nature, with a whole new instance of everything coming into being for each request, somewhat sidesteps the capacity for problematic memory leaks that could otherwise exist for processes that remain alive between requests.

Manipulating complex data structures that are large and/or trying to manage long running processes cause memory leaks. I often find I have to jump through hoops I don't have to in other languages to deal with these kinds of problems, for instance.

I usually have to resort to queues, which just adds complexity where I typically don't want it.

Post reply on HN