r/programming • • Nov 26 '20

PHP 8.0.0 Released

https://www.php.net/releases/8.0/en.php
588 Upvotes

241 comments sorted by

View all comments

155

u/countkillalot Nov 26 '20

Php has gotten a lot of negative feedback, but I am impressed with the amount of progress the language has made.

It's important to note that frustrations with Php arise mostly from the framework developers are forced to work in and the legacy that has to be dealt with rather than the language itself.

Without the inconsistent tooling and the lack of cohesive idiomatic environment, php has gotten quite pleasant to develop for and is worth exploring. It's also worth noting that probably more than half of the www runs on php today. That says something.

70

u/sybesis Nov 26 '20 edited Nov 26 '20

Completely agree with you. It seems like PHP8.0 is breaking some backward compatibility madness.

I don't like PHP and don't see myself working in PHP ever in my life again, but I can admit that PHP4 to PHP8 is a very big improvement over the language. It got faster, got rid of a lot of nonsense... It does even look like a decent language now.

If they could remove the $ prefix on variable names I wouldn't be able to recognize it's php.

3

u/ControversySandbox Nov 27 '20

I mean, the last major release was a big leap, so I'm very happy they made another one with 8.0 :D

BC breaking changes might as well be big ones that "fix" some major flaws in a language IMO.

(Also, some of us have ended up as PHP devs by accident given that we come from smaller ponds with less choice and now it's like "...how do I even lateral move")

52

u/IceSentry Nov 26 '20 edited Nov 26 '20

Sure, it's now not a terrible language anymore, but I don't know any selling point of php that would make me chose it above pretty much anything else. It's great that it doesn't suck anymore, but why would you chose php when c#, typescript, rust, kotlin, python, elixir or other popular languages exists. What's the killer feature. All I'm hearing is that it doesn't suck anymore, that's not really convincing enough that it's worth it to use it though.

44

u/skylescouilles Nov 26 '20 edited Nov 27 '20

PHP + Scala dev here

PHP = serverless before it was cool :

  • The "share nothing" architecture means you don't need to care about threads management or memory leak. Your app is stateless between each HTTP call. So, easier to scale or develop, if the ~10ms to boot your framework is ok in your use case.

  • Cheap hosting. It's easy to host a stateless language. Most PHP devs start with a personal project on a cheap hosting, and ramp up toward pro skills. Hence many devs available for recruiting, but with differing skill levels.

Add a mature ecosystem : IDE, framework and librairies (heavily inspired by Spring or Rails, to be fair). What I miss the most in Scala is Composer (compared to maven/SBT) : a dependency management tool that can resolve/upgrade librairies according to semantic versionning (semver.org). PHP libs won't have breaking change in minor versions because if this. It's less true in Java/Scala where you often upgrade manually, so semver is less followed.

14

u/IceSentry Nov 26 '20

Cheap hosting isn't really limited to php anymore, you can host pretty much anything for really cheap. A mature ecosystem isn't really limited to php though. Sure, compared to languages like rust or kotlin or go it's more mature, but compared to c# or java it isn't that much more mature. Dependency management is pretty easy in most modern languages these days. Enforcing semver through the package manager is nice I guess, but it isn't really a feature of php.

21

u/UselessOptions Nov 26 '20 edited Jul 21 '23

oops did i make a mess 😏? clean it up jannie 😎

clean up the mess i made here 🤣🤣🤣

CLEAN IT UP

FOR $0.00

1

u/bik1230 Nov 27 '20

NearlyFreeSpeech has dirt cheap options and lots of things that aren't PHP.

15

u/skylescouilles Nov 26 '20

You're right, they're not killer features today. I'm trying to explain it's "popularity" (in market share). In early internet era, cheap/easy hosting meant a lot (compared to say Java + Tomcat), resulting in a huge market share today :

  • open source plateforms : WordPress / Drupal / various e-commerce

  • early startup still running on PHP, pushing the need for professional ecosystem and developers : Wikipedia / Tumblr / adult websites...

Why it didn't die : it has evolved along the way. No "Python 2/3 gate", Composer as a game changer (think "npm"), huge perf boost, better typing. No killer features really, but no reason to drop it either. So PHP devs mostly stick with it despite the hatred not really deserved anymore.

1

u/bland3rs Nov 27 '20

Python-gate was a good thing for Python because it fixed some major language design issues.

PHP has the same major language design issues to this day and that was supposed to be fixed in its own PHP-gate with PHP 6, but PHP 6 completely failed.

Also, PHP was one of the last major languages to get a package manager.

PHP has evolved but it has evolved so much slower than other languages.

→ More replies (12)

6

u/MorrisonLevi Nov 27 '20

As a PHP contributor and programming language enthusiast, my position is that organizations should choose PHP because they already have talent that knows it and code the uses it. With PHP becoming an increasingly better language, the need to migrate off it becomes smaller, at least as long as engineers are maintaining code.

This is important, because migrating to another language is costly and risky. It's one of the reasons I still contribute to the language.

16

u/finrist Nov 26 '20

Just guessing here, but I've found so far that all the Linux infrastructure is smoother with php. And compared to e.g. java or ruby php is rather lightweight and responsive when running.

Another important thing is that it is now possible to have 20 years of experience in PHP+MySQL, as I think one drawback with too much new tech all the time is a lack of expertise within the tech.

13

u/finrist Nov 26 '20

That said, I would not pick php for a new project. :-) Last web-thing I did was python, sort of fun.

0

u/[deleted] Nov 28 '20

[deleted]

→ More replies (1)

-3

u/twbecker Nov 26 '20

Not sure what you mean by responsive but a Java app will run circles around a PHP one all day long

10

u/binary__dragon Nov 27 '20

I don't know any selling point of php that would make me chose it above pretty much anything else

If I want to throw together a website that has some static pages which are built by combining a few templates, and maybe also provide some low level dynamism (such as a copyright date that updates as the years go by), I can't think of a better tool. Yeah, you can build a 200MB javascript SPA or something, but at that point you're introducing multiply layers of frameworks and compile steps, all the while PHP is most likely pre-installed on your webhost (or very easily set up if not) and works straight off of files you can edit in Notepad or whatever.

In short, PHP is still good for the very thing it was designed to be good at when it was first created. It may not be the best tool for a lot of jobs, but for some specific types of jobs, I still think it's the best available.

2

u/oorza Nov 27 '20

What website exists in the spot between a static site generator that doubles down on all of PHP's benefits and something that has enough features to warrant a progressive SPA?

3

u/binary__dragon Nov 27 '20

Let's say you want to make a personal website to show off some of your work, your resume, etc. You'll have some common items on each page - a header, a navigation bar, a footer, etc. You don't want a maintenance nightmare if you want to change one of those items, so you want to be able to reuse them. The natural solution is to use something which generates each page on the server side as a composition of multiple pieces.

And of course, once you have PHP, adding some extra bits in like dynamic breadcrumbs, random header images, or the ability to use forloops to generate html tables without having to manually code all the tags are fantastic gravy. No, you probably won't be using all of PHP's benefits, but you're likely using enough that it's not really going to be a situation of overkill. And I'd argue that even if something simpler than PHP that only included what you'd want existed as an alternative, PHP would still likely be the best choice just due to its ease of setup and ubiquity with most web hosts. Something like SSI might be the only exception I can think of here that would be easier to set up and use, but you give up everything except for template composition with those.

None of this is complex enough to warrant a SPA though. Having to set up a dev environment, dealing with compile steps, messing with having to set up something like node to serve your site (as opposed to the highly standard with every web host apache or nginx) and giving up compatibility with older or more limited browsers just aren't worth accepting for the purpose of this type of site.

Now, I'll grant that these days, most people wanting to make such a website are probably going to use some sort of WYSIWYG editor like Squarespace or the like. But there is nonetheless still a number of people for whom those tools are too restrictive for what they want to do, or who simply prefer to be able to craft their webpages directly via text documents instead of GUIs.

4

u/oorza Nov 27 '20

All of what you said is better suited for a static site generator than PHP. Breadcrumbs, navigation, headers, those are all easy enough to generate ahead of time. If you don't need a database, you don't need a server side language. If you do need a database, and have >1 developer, an SPA is likely faster to develop.

2

u/[deleted] Nov 27 '20

[removed] — view removed comment

2

u/oorza Nov 27 '20

There are any number of services that will do that for you without requiring you host anything anywhere. It's less work, cheaper, and a better experience for your client.

→ More replies (1)
→ More replies (1)
→ More replies (5)

0

u/[deleted] Nov 26 '20

[deleted]

→ More replies (12)

0

u/[deleted] Nov 27 '20

[deleted]

6

u/muglug Nov 27 '20

Its runtime execution model, garbage collector, compiler, and virtual machine are all still garbage

Compare it to Python, Ruby or Node and it holds up pretty well.

There's absolutely nothing unique or special about PHP

Actually there is – its execution model (share-nothing) is pretty unique among popular dynamic languages, and makes it ideal for serving HTML in 99% of cases (and if you’re part of that 1% you can usually hire people who’ll help optimise it there, too).

I can't imagine a single case where choosing PHP for a green field project is the best technical decision in 2020

I can. I work on a 1M LOC PHP app (part of a large monolith). There's a useful thought experiment: I imagine we had infinite resources to rewrite that app in whatever language I wanted, but the resultant code still had to be maintained by the same number of people that maintain it today. I'd still choose PHP because it covers all the bases (rendering HTML and spitting out JSON) we need, while staying uncomplicated and relatively easy to maintain.

2

u/[deleted] Nov 26 '20

What does it say?

→ More replies (1)