Live data from Hacker News

What's New in PHP 8.1

stitcher.io

21–30 of 112 posts

Re: What's New in PHP 8.1

#21
post #20
post #19

I recently killed all my PHP code in favor of Go. What finally convinced me is the Go package system. I like that Go has a builtin package manager, while I dont think PHP does. I know about Composer, I just wonder. After all these years, why hasnt PHP incorporated a builtin package manager?

Your question is weird, like a solution in search of a problem. So let me ask, what problem does composer have that you hope to see a builtin package manager solve (at the cost of losing its own dedicated team) ?

Who knows, maybe one day Composer will be bundled with PHP. (And bundling Composer with PHP wouldn't necessarily mean that Composer would lose its own independent dev team.)

Re: What's New in PHP 8.1

#22

I am not a developer, but I use PHP a lot for scripting and personal automation including small web apps with SQL backend. I found PHP 7 to be a great improvement over 5.x, but with 8 I skipped every single new thing they brought. I can use PHP 8.1 in PHP 7.4 compatibility mode, but I find the features in 8.1 making the language less readable and less logic; for example, 3 dots become part of the language syntax? Wha…

... was already syntax, for variadic parameters. Re-using it for unpacking makes perfect sense IMO.

Re: What's New in PHP 8.1

#23
> array_is_list

This is a stupid solution to a stupid problem. Defaulting to weak typing has enough problems, but changing the behavior of your data structure based on its contents is next-level pain. I used PHP for a few years at a student dev job and I can’t count how many times this conflation wasted my time and introduced various bugs.

If PHP wants to become more respectable as a PL, it has got to break that out into real arrays (a linked list might be acceptable under certain circumstances) and maps.

Re: What's New in PHP 8.1

#24
post #8
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.

Funny. I almost dislike all of PHP but think that their choice of basic data structure is the one good thing. Computers are getting faster and faster and simplifying programming could be done to a whole new level. Clojure for example has a similar approach. Okay, PHP lacks contracts, but maybe PHP adds them in 20 years when the mainstream understands that they are great.

I too dislike PHP, but this is one of the things I hate the most: this is like conflating addition and multiplication of types. Arrays and maps have separate use cases and very different trade-offs and PHP gives you no choice in the matter.

Re: What's New in PHP 8.1

#25
post #18

I do not think PHP is a good language to use in a project. - dev recruitment is hard. - dev retention is hard. - hard to find people that write clean, modern, performant PHP - it is PHP, with everything that it entails. It does not enjoy the best reputation as a language.

Do you have evidences to back up these claims? Many PHP projects are successful. WordPress, Nextcloud, Wikipedia, Facebook... Something about it must be right.

I think the OP has a fair point. I could be way off but I feel few developer get excited about working on PHP projects. I jumped ship to Node.js around PHP 5 and haven't enjoyed working on PHP code bases ever since. I think this in part could be due to TypeScript, giving much more confidence in refactoring and moving a project forward. The massive npm module ecosystem is probably also a major factor. The fact that WordPress and Facebook use PHP is more historic then being exemplary for it being an excellent solution.

Re: What's New in PHP 8.1

#26

I am not a developer, but I use PHP a lot for scripting and personal automation including small web apps with SQL backend. I found PHP 7 to be a great improvement over 5.x, but with 8 I skipped every single new thing they brought. I can use PHP 8.1 in PHP 7.4 compatibility mode, but I find the features in 8.1 making the language less readable and less logic; for example, 3 dots become part of the language syntax? Wha…

What's wrong with ellipsis as syntax? Plenty of languages have some sort of ellipsis (either 3 dots or 2) as syntax. See for instance https://en.wikipedia.org/wiki/Ellipsis#Programming_languages and https://en.wikipedia.org/wiki/Ellipsis_(computer_programming... . JavaScript/TypeScript also uses it in a similar way to PHP.

Re: What's New in PHP 8.1

#27
This is really making what used to be an easy to read, easy to learn language a lot less of that. Some of us still don’t use IDEs and are okay with more thoroughly defined code that is readable.

If people are so gung ho on adding in syntax hacks, shortcuts, etc, they seem to be bringing ideas from other languages and why not simply continue to use that other language? PHP seems to be looking more and more like Go or JS to me now. Anyone want to start a fork called “PHP Classic”? :)

Re: What's New in PHP 8.1

#28

I do not think PHP is a good language to use in a project. - dev recruitment is hard. - dev retention is hard. - hard to find people that write clean, modern, performant PHP - it is PHP, with everything that it entails. It does not enjoy the best reputation as a language.

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 something running is underrated frankly.

Re: What's New in PHP 8.1

#29
post #27

This is really making what used to be an easy to read, easy to learn language a lot less of that. Some of us still don’t use IDEs and are okay with more thoroughly defined code that is readable. If people are so gung ho on adding in syntax hacks, shortcuts, etc, they seem to be bringing ideas from other languages and why not simply continue to use that other language? PHP seems to be looking more and more like Go or…

[deleted]

Re: What's New in PHP 8.1

#30
post #19

I recently killed all my PHP code in favor of Go. What finally convinced me is the Go package system. I like that Go has a builtin package manager, while I dont think PHP does. I know about Composer, I just wonder. After all these years, why hasnt PHP incorporated a builtin package manager?

PHP developers have been very successfully using Composer for many years. It's actually quite nice having the package management decoupled from the language, there's fewer chances for breaking things between upgrades which helps slightly with long term support.

Congrats on getting a package manager for Go!

Post reply on HN