Live data from Hacker News

What's New in PHP 8.1

stitcher.io

71–80 of 112 posts

Re: What's New in PHP 8.1

#72

Earlier quoted context omitted.

PHP is incredibly easy for any competent programmer to pick up. If you know C/Java you can get into php pretty easily. If you use structured projects, (symfony) in our case its much easier to use and maintain. We have older Java and Perl and Python to maintain. Its much harder to get those up and running. The startup I worked at 8 years ago used PHP and got bought. I think the ability to get into it quickly and get s…

PHP was the most competitive when ASP was around. After that, PHP entered a dark age where almost every other language ran circles around it in terms of performance, security, maintainability, tool support... and literally everything. Some of those problems got addressed but by the time that happened PHP's reputation was irreversibly trashed and now nobody wants to know about it. That is the world we live in. People…

I would not be so sure on performance vs Python: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

I haven't run the tests myself in 2021, but I used to do PHP for many years, and there were significant performance improvements done in PHP which I remember took it way ahead of Python at the time.

Re: What's New in PHP 8.1

#73
post #3

"New array_is_list function" I use PHP a fair amount, but this is one area that irks me. PHP arrays can be arrays, lists, and hash maps. PHP obviously copied some of Perl's features, and I never understood why hashmaps and arrays weren't different types, as they are in Perl.

Yes a million times this. This becomes a even bigger problem with json_encode when PHP can't tell the difference between an object and array sometimes and outputs the wrong type. Yes you can use stdClass but that feels like such a hack. It would have been amazing if they were different types all along.

Re: What's New in PHP 8.1

#74

Earlier quoted context omitted.

> changing the behavior of your data structure based on its contents PHP does no such thing. There is one array type with one behaviour. There is no distinction between different kinds of arrays in the language.

Doch. Try piping the result of array_filter to array_map sometime. You can’t do it without an intermediate call to array_values first because the result of passing a list to array_filter does not behave like a list anymore: it operates strictly like a map and cannot have map called on it. (Oh the irony!)

The caveat I'm aware of with array_filter is that it can leave gaps in the indexes, but having an array like that doesn't break array_map. The output from it will just have the same index gap as the input.

Re: What's New in PHP 8.1

#75

Earlier quoted context omitted.

PHP is incredibly easy for any competent programmer to pick up. If you know C/Java you can get into php pretty easily. If you use structured projects, (symfony) in our case its much easier to use and maintain. We have older Java and Perl and Python to maintain. Its much harder to get those up and running. The startup I worked at 8 years ago used PHP and got bought. I think the ability to get into it quickly and get s…

PHP was the most competitive when ASP was around. After that, PHP entered a dark age where almost every other language ran circles around it in terms of performance, security, maintainability, tool support... and literally everything. Some of those problems got addressed but by the time that happened PHP's reputation was irreversibly trashed and now nobody wants to know about it. That is the world we live in. People…

> Even CPython is faster.

The benchmarks I’m familiar with[1] show recent PHP releases to be a lot faster than CPython for many tasks. Are there better benchmarks I should be aware of?

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re: What's New in PHP 8.1

#76

Earlier quoted context omitted.

PHP was the most competitive when ASP was around. After that, PHP entered a dark age where almost every other language ran circles around it in terms of performance, security, maintainability, tool support... and literally everything. Some of those problems got addressed but by the time that happened PHP's reputation was irreversibly trashed and now nobody wants to know about it. That is the world we live in. People…

> Even CPython is faster. The benchmarks I’m familiar with[1] show recent PHP releases to be a lot faster than CPython for many tasks. Are there better benchmarks I should be aware of? [1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

If you consider that you'll be using numpy and similar libraries, then CPython beats PHP for most important CPU bound stuff.

Re: What's New in PHP 8.1

#77

Earlier quoted context omitted.

PHP is incredibly easy for any competent programmer to pick up. If you know C/Java you can get into php pretty easily. If you use structured projects, (symfony) in our case its much easier to use and maintain. We have older Java and Perl and Python to maintain. Its much harder to get those up and running. The startup I worked at 8 years ago used PHP and got bought. I think the ability to get into it quickly and get s…

PHP was the most competitive when ASP was around. After that, PHP entered a dark age where almost every other language ran circles around it in terms of performance, security, maintainability, tool support... and literally everything. Some of those problems got addressed but by the time that happened PHP's reputation was irreversibly trashed and now nobody wants to know about it. That is the world we live in. People…

People do not want to learn PHP or work in PHP.

The majority of new programmers might not want to, but I consider it a clever strategy for new devs to get their foot in the door with their first real job. There's always a huge amount of open PHP jobs and if more elite devs are passing over those jobs then it means an opportunity for somebody. And some of those people who start with PHP will move on to more modern or better languages after they get their legs. It's a smart path to get on the dev career track, especially if you don't come from a traditional CS or dev background.

Re: What's New in PHP 8.1

#78
post #54
post #3

"New array_is_list function" I use PHP a fair amount, but this is one area that irks me. PHP arrays can be arrays, lists, and hash maps. PHP obviously copied some of Perl's features, and I never understood why hashmaps and arrays weren't different types, as they are in Perl.

I'm kinda used to PHP "arrays", but I really wish it had proper lists. This array_is_list function doesn't change things much: I already have the same implemented in many of my projects. The point is that I shouldn't do that: I just should use a typehint the same way as I'd do it with array or MyCustomClass. Of course there is Ds\Sequence, but having it as a part of some relatively obscure library isn't the same as h…

What `array_is_list()` changes is that it makes this check fast. Previously, the fastest method of checking for a list-like array was `$arr == array_values($arr)`, which was slow on large lists and could fail entirely on some unusual structures containing circular references.

(I was involved in the development of this function: https://github.com/php/php-src/pull/4886)

Re: What's New in PHP 8.1

#80
post #77

Earlier quoted context omitted.

PHP was the most competitive when ASP was around. After that, PHP entered a dark age where almost every other language ran circles around it in terms of performance, security, maintainability, tool support... and literally everything. Some of those problems got addressed but by the time that happened PHP's reputation was irreversibly trashed and now nobody wants to know about it. That is the world we live in. People…

People do not want to learn PHP or work in PHP. The majority of new programmers might not want to, but I consider it a clever strategy for new devs to get their foot in the door with their first real job. There's always a huge amount of open PHP jobs and if more elite devs are passing over those jobs then it means an opportunity for somebody. And some of those people who start with PHP will move on to more modern or…

PHP is not bad as a first language but it is rare that a new developer will prefer it.
Post reply on HN