zlacker

[parent] [thread] 26 comments
1. Cianti+(OP)[view] [source] 2022-12-08 13:21:04
As someone who has written in past a lot of PHP and Python, I find it interesting that PHP devs can do a lot of breaking changes, and don't get a huge amount of flak for it.

Python 2 -> 3 change really was painful for Python community, but PHP does these almost fundamental breaking changes so often, that maybe people just get used to it? I haven't really followed Python past version 2, but I think they are less likely to ever do such amount of breaking changes.

There must be a lot of unmaintained PHP codebases that will break if PHP is updated by hosting provider etc. Someone must be pulling a lot of hairs because of this.

Edit: Those dogpiling there, I rest my case with josefresco's comment:

https://news.ycombinator.com/item?id=33907628

It's painful. Dropping dynamic properties? That will be a lot of fun. WordPress is probably biggest segment for PHP usage.

replies(12): >>TazeTS+l >>mgkims+11 >>dotanc+41 >>amcsi+b1 >>august+72 >>psychp+k2 >>liveon+W2 >>cardan+63 >>effica+z3 >>tyingq+Ma >>denton+ib >>qbasic+OQ
2. TazeTS+l[view] [source] 2022-12-08 13:23:40
>>Cianti+(OP)
PHP learned the lessons of the Python 2/3 transition and is making backwards compatibility breaks much more carefully. “fundamental breaking changes […] often” seems like an exaggeration to me.

PHP 7 made a few big and necessary changes but they generally did not affect well-written code much. Python 3 broke a lot of things without good justifications, and without a way to make your code compatible with Python 2 at the same time.

replies(1): >>hakre+GC6
3. mgkims+11[view] [source] 2022-12-08 13:29:01
>>Cianti+(OP)
Can you give some specific examples? I can't think of too many 'fundamental breaking changes' in PHP between major versions. Some things that will be changed in 9 are now deprecated in 8.2.

PHP has gone through a few changes.

PHP 3->4 was a moderately big change under the hood, and introduced a lot of new things, but most 3 'worked' under 4 (but was... awkward).

PHP 4->5 - a few 'big' things changed - XML processing changed - I had to use some shims to get some projects upgraded.

PHP 5->7 - my recollection, and that of most colleagues, is that this was pretty painless for most projects. I can't recall too many major breaking changes, but it was mostly just getting a doubling of speed without any substantive changes.

The PHP community has a couple decades of 'major version changes' to look at to learn from. I still can't say I agree with 100% of the decisions, but it's still progressing nicely.

replies(2): >>bawolf+B8 >>denton+4c
4. dotanc+41[view] [source] 2022-12-08 13:29:10
>>Cianti+(OP)

  > There must be a lot of unmaintained PHP codebases that will break if PHP is updated by hosting provider etc.
Tons of them. If PHP really powers 50% of the internet, as they say, then maybe 25% of the internet is running an out-of-date PHP version. Then get into out of date Wordpress installs (can't risk breaking that plugin) and Magento 1 installs (out of support for half a decade, still in widespread use) and remember that they can't even update PHP without updating the Framework. In general, Laravel is sometimes better if the devs have been upgrading every LTS or so, that's once every two years. But if they miss an LTS, Laravel installs fall just as fall behind as any other framework.

  > Someone must be pulling a lot of hairs because of this. 
No, nobody really cares. Sometimes I'm paid a lot of money to fix things, though, so I'm not bothered by the situation either. It seems that once a site is passed to the content managers, the only way to budget for upgrading the site is when there is a problem. Never mind that they might have some small internal dev team adding features all this time.
5. amcsi+b1[view] [source] 2022-12-08 13:30:15
>>Cianti+(OP)
The big difference is that while the PHP major upgrades - although had breaking changes - provided a forward-compatible way for you to run older version code on a newer version PHP (see WordPress for PHP 5 running fine on PHP 8), Python did not offer such a thing; code was either exclusively for Python 2 or for Python 3, making upgrade paths very difficult.
6. august+72[view] [source] 2022-12-08 13:36:22
>>Cianti+(OP)
PHP doesn't do a lot of BC-break. Proposing one and getting it accepted is very difficult (2/3 of +1 votes required). Most cases of BC breaks are based on security concerns.

PHP didn't learn from Python 3 BC fiasco, its governance makes such changes very difficult to be made.

7. psychp+k2[view] [source] 2022-12-08 13:37:42
>>Cianti+(OP)
I actually found Python as an organisation quite obnoxious during the transition to 3.

Even as someone who supported it. Perhaps there was internal built up resentment.

Whatever it was it showed in their communication.

Very occasionally I have to communicate on a topic I think could see backlash based on internal views. I make an effort to communicate it as neurally as possible.

My org currently prefers a saccharin approach when there is controversy I can't stand that, but I prefer it to over the like it or lump it bristling with rage approach Python took.

8. liveon+W2[view] [source] 2022-12-08 13:40:29
>>Cianti+(OP)
but this isn't the case for PHP at all? The PHP side of upgrades are, usually, trivially simple and you are given literal years of deprecation warnings before anything happens. The tricky part (as always in PHP) is the modules and stuff, but that is getting better
9. cardan+63[view] [source] 2022-12-08 13:41:07
>>Cianti+(OP)
> PHP does these almost fundamental breaking changes so often, that maybe people just get used to it?

PHP also cares a great deal about backwards compatibility. There are long deprecation phases before anything gets removed.

The RFC system also helps a lot in ensuring that changes to the language are well thought out to and discussed beforehand. The is not much change just for change's sake. Churn is kept to a minimal while still allowing the language to evolve.

> There must be a lot of unmaintained PHP codebases that will break if PHP is updated by hosting provider etc. Someone must be pulling a lot of hairs because of this.

PHP upgrades are also good money for agencies. Got to earn that bread.

And to let out a dirty secret, for really hopeless projects there is the option to keep them on life-support by running them inside a docker container with an older PHP version. (Horrible but if that's what the customer wants, it's their risk.)

10. effica+z3[view] [source] 2022-12-08 13:43:41
>>Cianti+(OP)
if your project is managed by composer you just set your compatible php version and you’re set. the 5.6 to 7 conversion was painless for most because 7 was largely backwards incompatible. I did it for a 300kloc 10 year old codebase in a few days. After that the breaking changes have been pretty easy to manage, and many users are still on 7.4. 8 is where things have really started to change but still the process is not that hard.
◧◩
11. bawolf+B8[view] [source] [discussion] 2022-12-08 14:20:44
>>mgkims+11
Php 7 -> Php 8 is where php has really started making more breaking changes (for better or worse). Or at least introduced lots of new warnings.
replies(1): >>hakre+dD6
12. tyingq+Ma[view] [source] 2022-12-08 14:34:51
>>Cianti+(OP)
I don't think PHP's introduced anything quite as disruptive, for example, as introducing bytes vs strings. Where no tool can really convert existing code.
replies(1): >>hakre+yF6
13. denton+ib[view] [source] 2022-12-08 14:38:33
>>Cianti+(OP)
> but PHP does these almost fundamental breaking changes so often

I have a private (non-internet) web-app that's still on PHP6.5; I like the new PHP features, but upgrading private code to conform to PHP 7 and 8 looks a lot like make-work. I wish it shipped with good upgrade tools.

[Edit] @darkwater (below) is correct; I meant PHP 5.6. PHP6 was some kind of abortion - I can't remember the story.

replies(3): >>user39+vc >>hakre+0F6 >>chilli+NRc
◧◩
14. denton+4c[view] [source] [discussion] 2022-12-08 14:42:34
>>mgkims+11
> PHP 5->7 - my recollection, and that of most colleagues, is that this was pretty painless for most projects.

They replaced the MySQL plugin in version 7. All MySQL code was broken. I don't know, but I'd guess that most PHP sites were using MySQL as their database (the 'M' in 'LAMP' stands for MySQL).

replies(3): >>abujaz+Gd >>danari+9k >>stephe+L31
◧◩
15. user39+vc[view] [source] [discussion] 2022-12-08 14:45:35
>>denton+ib
> PHP6.5

Is that a joke? PHP 6 doesn't exist...

replies(1): >>darkwa+Fd
◧◩◪
16. darkwa+Fd[view] [source] [discussion] 2022-12-08 14:51:25
>>user39+vc
They probably meant 5.6
◧◩◪
17. abujaz+Gd[view] [source] [discussion] 2022-12-08 14:51:33
>>denton+4c
Using mysql_ functions directly was very outdated and long deprecated when 7 was released. Any reasonably maintained code base had already been using mysqli or PDO for years.
◧◩◪
18. danari+9k[view] [source] [discussion] 2022-12-08 15:27:21
>>denton+4c
I thought I had to replace all my mysql code in a massive overhaul to upgrade from 5.x to 7.x.

Then I read a little closer, and realized I pretty much just had to add an "i" onto all the underlying mysql functions ("mysql_" to "mysqli_"), at least for the ones I was using commonly.

I'm still in the process of migrating that project, now on 7.4, to a modern Symfony framework, but I tested it out in 8.1 the other day, and it needed...1 change to work apparently perfectly.

I'm still going to need to do more thorough testing before I put production on 8.x, but with 7.x now unsupported, that has become a priority.

replies(1): >>mgkims+SH
◧◩◪◨
19. mgkims+SH[view] [source] [discussion] 2022-12-08 17:07:26
>>danari+9k
IIRC the parameter order for some parameters differs between mysql_* and mysqli_* functions. But as someone else said above, built-in PDO or some other abstraction library for data access has been the way to go for more than a decade (more like closer to 20 years at least).

That said, I'm still surprised when I come in to codebases where people are still using hard-coded db function calls all over the place (mysql_* or mysqli_) I indicate that abstracting that away should be a priority. Even doing something as simple as "I want to log all the queries that I'm making for debug purposes" is essentially impossible when you have hundreds of individual calls to mysql_ embedded throughout the code. But... I've not come in to a codebase in the last... 4-5 years that does that, so either I've been lucky or that coding behavior is indeed becoming a thing of the past.

replies(1): >>danari+3O
◧◩◪◨⬒
20. danari+3O[view] [source] [discussion] 2022-12-08 17:38:08
>>mgkims+SH
Yyyyep. That's a big part of the migration I've been working on. However, it's a non-monetized side project that I inherited with a loooot of legacy code, so it's not exactly going to be speedy.
21. qbasic+OQ[view] [source] 2022-12-08 17:53:13
>>Cianti+(OP)
Python was invented and heavily used before most people could even access the web, nevermind building dynamic websites. The web has always been churning heavily--HTML, browsers, JS, etc. changing and adding features etc. Web folks have always been dealing with churn. In contrast some people have scripted out tons of python code for managing computers, labs, etc. and they absolutely cannot and will not tolerate churn or things breaking with minor python releases.
◧◩◪
22. stephe+L31[view] [source] [discussion] 2022-12-08 18:58:58
>>denton+4c
> All MySQL code was broken.

Not quite. Code that *wasn't* using either of the two modern APIs for MySQL was "broken".

They removed the oldest, jankiest of the three APIs for connecting to MySQL in php7.

MySQLi (literally, "MySQL Improved" extension) was introduced with PHP 5.0, in 2004.

PDO was introduced with PHP 5.1 in 2005.

The documentation started showing "soft deprecation" notices on mysql_* functions in 2012. It was already common practice to advise people to upgrade to either mysqli or PDO.

The old mysql extension was deprecated as of php5.5, in 2013.

The final shipped version with the mysql extension was 5.6, which was supported until 2018 - half a decade after the deprecation was added.

◧◩
23. hakre+GC6[view] [source] [discussion] 2022-12-10 14:47:46
>>TazeTS+l
I remember one breaking syntax change in PHP 7 a larger project was affected and it was tested with grep and fixed with sed in a matter of minutes.

There is benefit if you have the project under test and can run the build with different php versions thought. Best in parallel so you have current, next and future. It perhaps becomes the norm since the yearly release cycle but always was a requirement when supporting different php versions.

◧◩◪
24. hakre+dD6[view] [source] [discussion] 2022-12-10 14:51:30
>>bawolf+B8
Deprecation warnings for the most. But those can be taken away so you can have PHP 5/7/8 code without much deviation.

More than a LTS release I'd prefer more PHP 8 releases than the five in 7.x, e.g. more until 8.8 or 8.9.

◧◩
25. hakre+0F6[view] [source] [discussion] 2022-12-10 15:03:52
>>denton+ib
> but upgrading private code to conform to PHP 7 and 8 looks a lot like make-work. I wish it shipped with good upgrade tools.

I'm doing this quite often as I maintain some code-bases that have backward compat down to PHP 5.3 as the baseline. So if you're looking for forward compatibility of your PHP 5.6 codebase to 7.x and 8.x (incl. 8.2), its not so much of work.

If you need an upgrade tool, have different PHP versions at hand and load each file on the CLI and PHP will show you the deprecation warnings. It then depends a bit on the code (each()/next()/reset() family undergone some changes if not removals in 8? so you have to replace with some different syntax) but most of the rest is only deprecation warnings that can be overcome with #attributes "annotations" that are just comments prior php 8.

tooling could be better especially if you're running from low versions, thought. but using php on the cli directly brings you quite far and on speed already for most things in my personal experience. git, find and xargs are your friends.

◧◩
26. hakre+yF6[view] [source] [discussion] 2022-12-10 15:08:23
>>tyingq+Ma
Well there once was such an idea. That what would have become PHP 6. But then there was the decision to not do that, keep strings binary only and never release PHP 6. Instead we had seen a couple more PHP 5.x releases and the yearly release cycle was introduced (with 5.6 having extended community support [plus one more year]).
◧◩
27. chilli+NRc[view] [source] [discussion] 2022-12-12 16:58:44
>>denton+ib
>PHP6 was some kind of abortion

IIRC, the initial development was in the mid 2000s but it was abandoned several years later because they couldn't get Unicode support working correctly. By the time it was abandoned there was already a lot of material referencing it like books and conference talks. So when the PHP team decided to do a new major version most of the planned PHP 6 features were already added to 5.3 and 5.4 so they thought it best to just skip 6 to avoid confusion.

[go to top]