News for hackers. Stuff that matters.
Re:PHP 8 by cstuder on Thursday November 26, 2020 @10:44AM (#25220931)
Apparently some of the deprecations will make this the most backward compatibility breaking version jump of PHP since V4 to V5. (Read a german interview here: https://www.heise.de/news/PHP-8-im-Experten-Check-Der-erwart...)

There's a long report on Wordpress and PHP 8 and it's not pretty: https://developer.yoast.com/blog/the-2020-wordpress-and-php-...

Re:PHP 8 by nolok on Thursday November 26, 2020 @11:00AM (#25221091)
Reading the list of things that worry them makes it clear that it's not so much php is breaking bc than it is wordpress lack of cleaning and linting for so long catching up to them.

I mean seriously the first thing they list as a worry is that arithmetic operators will now throw an error when one (and only one) of their operand is an array or resource (eg array + array support remains, it's really int + array or string + file_descriptor, things like that). This is literally a case that makes no sense in the code ever, not one of the "php used to do something magical for us" but "php used to keep silent about this buffonery", so if your code does that you have bigger worries ...

Almost every single one of those things are easy to fix, in that it requires mostly time not much if any redesign, and almost every single one of those things are also deprecated or on their way out since at least a decade.

Re:PHP 8 by matt_kantor on Thursday November 26, 2020 @02:02PM (#25222701)
> it's really int + array or string + file_descriptor, things like that

I haven't personally used PHP in years, but was curious about this. Based on some quick/dumb experiments it appears int + array has thrown errors as far back as PHP4:

- http://sandbox.onlinephpfunctions.com/code/0b2f22ea881b36e58...

- http://sandbox.onlinephpfunctions.com/code/0e5fb752fc3ec28e8...

Is the post talking about some other scenario? Maybe the new thing is that it's now specifically a TypeError?

Re:PHP 8 by hakre on Thursday November 26, 2020 @04:18PM (#25223592)
Yes, was warning / log previously, now it throws. So what was a warning and just going on is now an exception that interrupts.
Re:PHP 8 by Denvercoder9 on Thursday November 26, 2020 @04:03PM (#25223506)
int + array has indeed been throwing errors for a while for the basic arithmetic operations, but not for slightly more complex operations such as modulo, and there are plenty more weird combinations that used to work:

https://3v4l.org/IuoGO

Re:PHP 8 by danudey on Thursday November 26, 2020 @02:51PM (#25223038)
It also sounds as though the internal type checking is going to be a large developer load as well. In PHP7, internal functions return null for type mismatches, and in PHP8, they raise a TypeError. This means going back through every case where they call an internal function and wrapping it with a try/catch for TypeError, in addition to checking for null. That sounds like a pretty significant workload change.
Re:PHP 8 by Denvercoder9 on Thursday November 26, 2020 @04:04PM (#25223514)
Or just make sure you pass the correct type to the functions. It's easier and probably more correct as well.
Re:PHP 8 by zaarn on Friday November 27, 2020 @01:57AM (#25226149)
If you rely on type labels on your functions and variables, you should rarely require a try/catch to handle type errors for internal functions.
Re:PHP 8 by ComputerGuru on Thursday November 26, 2020 @11:12AM (#25221195)
> This is literally a case that makes no sense in the code ever,

Speaking as someone that hates PHP but still appreciates that it has its uses: You’re speaking from one perspective. There are others. That operation is perfectly valid and well-defined in Matlab where it increments all members of the matrix/vector by the scalar.

Re:PHP 8 by Denvercoder9 on Thursday November 26, 2020 @12:58PM (#25222181)
But PHP didn't do that, it just silently ignored the operation or returned zero. That behaviour doesn't make any sense.
Re:PHP 8 by ufmace on Thursday November 26, 2020 @01:24PM (#25222365)
This is actually a perfect example of why I don't like these magical overloads for what looks like basic mathematical operations.

It's perfectly obvious to everyone what adding 2 numbers does. It works the same in basically any computer language. What happens when you add a number to an array though? There is no universal obvious rule, it depends on whatever was convenient for whoever initially wrote that overload. You just have to remember what it does in this language. Maybe it appends it to the array, maybe it does the operation on the first or last entry of the array, maybe it does it to everything in the array, or does something else entirely. Does it modify the array in place, or create another copy with the change? Woe betide anyone who forgets what it does there or gets it mixed up with another language. Better IMO to at least have functions with clear names for doing these sorts of things.

Re:PHP 8 by oseityphelysiol on Thursday November 26, 2020 @11:49AM (#25221526)
Did it php use to do that? Otherwise your point is invalid.
Re:PHP 8 by muglug on Thursday November 26, 2020 @10:52AM (#25221007)
> There's a long report on Wordpress and PHP 8 and it's not pretty

This is an awkward side-effect of WordPress core team largely neglecting PHP code quality issues for the last decade or so. With good reason – improving such a large codebase is a massive, mostly-thankless task.

Re:PHP 8 by Kluny on Thursday November 26, 2020 @12:15PM (#25221816)
I worked at WordPress for half a year, and I'm no expert, but the code reviews there were more intense than any I've ever experienced. Every line of code gets reviewed before it gets committed, and if the commit is longer than 20 lines or so, it undergoes an additional scheduled review as well as pre-commit review. They also have pretty good code sniffers that ought to catch errors like OP mentioned.

The reason they're concerned, I think, is because they try to protect users who have plugins that came from their plugin repository, where the same code quality rules don't apply. WordPress has always been huge on backward compatibility.

Re:PHP 8 by muglug on Thursday November 26, 2020 @12:52PM (#25222122)
> WordPress has always been huge on backward compatibility.

Yes, and I think that's ultimately the root of its challenges.

A fear of breaking things means WP shies away from large-scale changes that would help it become a modern-looking PHP app.

I wrote this two years ago, and WordPress's basic architecture hasn't changed since: https://medium.com/@muglug/improving-wordpress-with-static-a...

Re:PHP 8 by marc_io on Thursday November 26, 2020 @01:12PM (#25222270)
> A fear of breaking things means WP shies away from large-scale changes that would help it become a modern-looking PHP app.

They are strongly advocating Javascript as the future of WordPress right now, so I'm not sure if they would like it to become a modern looking PHP application.

Re:PHP 8 by noahtallen on Friday November 27, 2020 @04:35PM (#25232778)
I'm working on some of these "future of WordPress" projects right now, and I don't think PHP is going away any time soon. The JS-future for WordPress is more to do with the editing experience than anything else -- the entire rendering pipeline, backend, and rest API is still PHP, and I'm not aware of any plans to change that.

The main difference with the future of WordPress is that instead of templates (which describe the structure of a site) being written in PHP, they will be written as blocks so that they are user-editable. I would say it's more apt to say that "blocks" are the future of WordPress. The block editing experience is written in JS, but serialized block markup is backwards compatible with HTML, so no JS is needed to render blocks once they are serialized.

Re:PHP 8 by eitland on Friday November 27, 2020 @06:42AM (#25227830)
Interestingly the one other mainstream language that manages to mess up

- equality

- type coercion

- array handling

and more to the same degree as PHP :-)

Re:PHP 8 by mgkimsal on Thursday November 26, 2020 @01:23PM (#25222361)
> The reason they're concerned, I think, is because they try to protect users who have plugins that came from their plugin repository, where the same code quality rules don't apply.

Then start making the quality rules apply. Or produce code quality ratings for plugins and display them for people to make decisions on.

Making sure that WP can keep working with lower-quality plugins in the name of 'compatibility' just ensures that WP is, at best, a mixed-bag.

Re:PHP 8 by Kluny on Thursday November 26, 2020 @03:53PM (#25223450)
It's a tradeoff they've made. Allowing the plugin store to be a free-for-all creates a very low barrier for entry, and the marketplace is thriving and well populated as a result. They've added metrics you can use to assess quality, in the form of compatibility reporting, user reviews, stars, etc.
Re:PHP 8 by pbowyer on Thursday November 26, 2020 @12:51PM (#25222114)
WordPress core team members and users are welcome to get involved in PHP development and providing feedback on proposals.

They are notably absent, and so people who write modern PHP - or wish PHP was a different language - are the ones influencing language development.

Re:PHP 8 by chipotle_coyote on Thursday November 26, 2020 @02:25PM (#25222862)
> And so people who ... wish PHP was a different language are the ones influencing language development.

That's definitely been my impression. I used to be a professional PHP developer, still use it occasionally for personal projects, and appreciate the language, warts and all, even if I can't truly say I love* it -- but I'm only half-joking when I quip that PHP has evolved from its roots as a cargo cult version of Perl into a cargo cult version of Java.

Re:PHP 8 by adimitrov on Thursday November 26, 2020 @03:25PM (#25223273)
> - but I'm only half-joking when I quip that PHP has evolved from its roots as a cargo cult version of Perl into a cargo cult version of Java.

It's a joke in so far as it is funny - but it's absolutely correct. When you only look at the language... When looking at the VM, Java has an absolutely world class VM, with great engineering and decades worth of research poured into it.

PHP has... no such thing.

Re:PHP 8 by chipotle_coyote on Friday November 27, 2020 @02:06AM (#25226190)
I was definitely talking about the syntax. I'm not a huge fan of Java (as I suppose the joke already demonstrated), but I also notice how many places start out with PHP or Ruby or Python and end up moving to, if not Java, a language running on the JVM. So I still appreciate it. :)

To give PHP its due, it can be very fast -- although the more you use it "the modern, right way," the slower it seems to get. I can't help but wonder how much of that is an impedance mismatch between "your program starts over from scratch with every HTTP request" and "structure your program so that by the time every class is instantiated and interface is implemented, ten thousand lines of code have been processed with each request." No matter how great its optimization and caching may be, a Laravel or Symfony app just has a whole lot of overhead relative to any framework in another language that doesn't have PHP's zero-state approach.

Re:PHP 8 by mmerlin on Friday November 27, 2020 @05:55AM (#25227546)
"by the time every class is instantiated and interface is implemented, ten thousand lines of code have been processed with each request."

Haha so true... the first time I stepped through a running Laravel app line-by-line in debug mode in order to understand it better, I was worried my F11 key was going to wear out ;)

Re:PHP 8 by slifin on Thursday November 26, 2020 @08:09PM (#25224752)
PHP has an initial implementation on GraalVM

That is completely ignored by the community

Re:PHP 8 by cutler on Thursday November 26, 2020 @04:05PM (#25223519)
A world class VM tied to a dinosaur language in which you still have to escape regex metacharacters.
Re:PHP 8 by chipotle_coyote on Friday November 27, 2020 @02:18AM (#25226245)
The JVM is not tied to Java, which I think was a large part of adimitrov's observation. Kotlin, Scala and Clojure immediately come to mind. JRuby is also a fairly popular platform for Ruby. There's actually a huge list of other languages that run on the JVM, though.
Re:PHP 8 by The_rationalist on Thursday November 26, 2020 @05:20PM (#25223945)
What are you talking about? Java has raw strings (autoescaping) https://openjdk.java.net/jeps/378 Moreover Kotlin allows to have a state of the art language in a state of the art vm
Re:PHP 8 by im3w1l on Thursday November 26, 2020 @05:17PM (#25223920)
Having no stake in this, I think that's a mistaken way of going about things. Wordpress is PHP's killer app. If people aren't getting involved, php team should consider outreach.
Re:PHP 8 by pbowyer on Friday November 27, 2020 @02:54AM (#25226417)
Part of the problem is PHP has no team. It's determined to be a meritocratic loose organisation of individuals, and so there's no entity to do outreach.

It's not my favoured governance model, but it is what it is.

Re:PHP 8 by tyingq on Thursday November 26, 2020 @10:51AM (#25220999)
"There's a long report on Wordpress and PHP 8 and it's not pretty"

I wonder if that's somewhat on purpose. Part of the remaining stigma with PHP is that people cite bad PHP examples from WP.

Re:PHP 8 by cstuder on Thursday November 26, 2020 @10:56AM (#25221063)
No, I think WordPress being the most installed PHP application on the net warrants the special attention to it.

https://w3techs.com/technologies/overview/content_management

Re:PHP 8 by tyingq on Thursday November 26, 2020 @10:58AM (#25221083)
Not sure I understand. I'm saying the PHP team didn't cede any deprecations to Wordpress this time. Meaning no special attention.
Re:PHP 8 by cstuder on Thursday November 26, 2020 @11:36AM (#25221392)
Sorry, I missunderstood what you were writing.

Yes, it doesn't look like they took special attention to WordPress when developing PHP 8.

Re:PHP 8 by BeyondLimits99 on Thursday November 26, 2020 @08:23PM (#25224822)
As a PHP dev this is a really fair comment.

I think the other reason non PHP devs think we are in the dark ages is because when they google it, our documentation looks like it's from 2010. It's a bit of a joke really.

Re:PHP 8 by samus on Saturday November 28, 2020 @03:44AM (#25236291)
One other thing I always found iffy is the comment section. Why is the information there not reviewed and back-ported into the documentation? Sometimes, as on the page of the `DateTime` class, they actually contain crucial details!
Re:PHP 8 by bufferoverflow on Thursday November 26, 2020 @05:09PM (#25223881)
Just tried it on a Laravel project I'm working on, on Windows. Worked flawlessly. On the downside, no noticeable performance improvements.

Report generation times:

PHP 7.4 = 67ms avg

PHP 8.0 = 66ms avg

This is getting the data from MySQL and massaging it for the templates. With Laravel's insane amount of indirection, of course.

Re:PHP 8 by krick on Thursday November 26, 2020 @06:35PM (#25224338)
Why would you expect performace improvements? Because of JIT? There's no reason to hope that JIT would help with that much, because it's I/O-bound anyways. And function calls in PHP are pretty efficient.
Re:PHP 8 by krick on Thursday November 26, 2020 @08:11PM (#25224771)
Oh, come on. Did you see the benchmarks? This is CPU-bound code, like multiplying numbers 100 000 times over. This has nothing to do with your typical use case.

And, yeah, performance improvements are always advertised.

Re:PHP 8 by rovr138 on Monday December 07, 2020 @09:46AM (#25332541)
>This is CPU-bound code, like multiplying numbers 100 000 times over. This has nothing to do with your typical use case.

I think a lot of people missed this. It's not the usual PHP workload for usual/basic web dev.

Re:PHP 8 by oseityphelysiol on Thursday November 26, 2020 @11:48AM (#25221512)
I never want to get within a mile of a wordpress website after reading this.
Re:PHP 8 by casperb on Thursday November 26, 2020 @02:07PM (#25222740)
Wow, that Wordpress blog is bad. I have seen a lot of projects add support for PHP 8 in recent weeks and they were all kind of easy. Mostly waiting for upstream packages to be ready.

You get nice warnings for years about stuff to fix. If you ignore them because that is easier, there comes a point where it is so bad that you cannot recover.

I know the Wordpress codebase is nasty. But how and when are they going to fix these things? It is going to be so hard.

Re:PHP 8 by smsm42 on Thursday November 26, 2020 @07:08PM (#25224459)
Wordpress is a bit special case though as it has tons of very old code and a lot of plugins, some of which aren't maintained anymore.
Re:PHP 8 by no_wizard on Thursday November 26, 2020 @10:37PM (#25225366)
Reading this list reminds that nobody cares about the tech/engineering decisions of a product if it solves their use case.

That is shockingly poor practice and state of a code base for a product that powers so much of the web

Re:PHP 8 by tempguy on Saturday November 28, 2020 @12:39AM (#25235557)
I would like to hire you for a nsd + unbound high performance setup are you available? it seems the email in your profile doesn't work anymore.

do you have telegram or something?