Live data from Hacker News

A look at modern PHP

lwn.net

21–30 of 610 posts

Re: A look at modern PHP

#21
post #7

Earlier quoted context omitted.

I cut my teeth on it years ago, I don't hate on it for cheap jokes. That said I don't know why anyone would pick it to start a new project in 2020. We've been lucky to have so many new and established options that are better in almost everyway.

"so many new and established options that are better in almost everyway" such as?

C# (optionally using the ASP.NET framework) running on the fast, efficient, cross-platform .NET Core.

Or Java/Scala/Kotlin. Or Go. Or Python. Or Node + Typescript.

Re: A look at modern PHP

#22
post #7
post #2

PHP hater sheeps incoming

I cut my teeth on it years ago, I don't hate on it for cheap jokes. That said I don't know why anyone would pick it to start a new project in 2020. We've been lucky to have so many new and established options that are better in almost everyway.

you can run PHP pretty much anywhere, even the cheapest VPS probably has PHP, as well as all managed hosting. For python, go or other languages it can be more tricky if you're looking for cheap hosting / VPS

Re: A look at modern PHP

#23
I wrote my very first webapp in PHP when I was a teenager, and my first dozen paid apps shortly thereafter as a consultant. PHP was a lot worse then, but still has a lot of the same fundamental issues that it won’t ever be able to escape without becoming a different language.

I think it’s a good first tinkering language for people around that age: sort of like BASIC, but for the web.

I am glad PHP is still around; it is a very useful signal on the resume or CV of someone who uses it a lot.

It’s sort of like c# in that regard (exception granted for vertical-specific devs who work professionally to ship commercial apps with Unity), or Visual Basic before it.

Same goes for heavy Java outside of Google/Amazon backend, or outside of Android.

Most of these people are desktop Windows users by choice, too. It’s a very specific type of techie. Perhaps one day I should make an ishkur-style taxonomy. :D

I think this is also why almost all forum software is written in PHP.

Re: A look at modern PHP

#24
post #19

I use php daily. Mostly Symfony/Laravel stuff. There are still some stuff it needs what other languages have. (Can't really right now remember all the stuff i stumble upon sometimes which gives me the feeling "damn if i could do this like i do it in rust/java/cpp/(w/e)") Maybe the worst thing is the composer (it's slow.)

Try Prestissimo, which enables composer to download packages in parallel

  composer global require hirak/prestissimo

Re: A look at modern PHP

#25
post #10

I've worked with PHP since 5.4, and to me the language has not been the obstacle, it has been my own skill-level that has held me back, and still is - I lack very much the core architectural skills in getting forward as a developer, among many other things. I've seen some codebases using an even older version, and I think I can understand where people are coming from with their angst towards the language - but I thin…

Good, that you can confirm your skill level, so maybe PHP suites you very well.

For me, having no standard HashMap and having to set strict mode params in functions - is an instant no go. There is no lack of better options.

Re: A look at modern PHP

#26
post #7

Earlier quoted context omitted.

I cut my teeth on it years ago, I don't hate on it for cheap jokes. That said I don't know why anyone would pick it to start a new project in 2020. We've been lucky to have so many new and established options that are better in almost everyway.

you can run PHP pretty much anywhere, even the cheapest VPS probably has PHP, as well as all managed hosting. For python, go or other languages it can be more tricky if you're looking for cheap hosting / VPS

With docker containers and the numerous PaaS/FaaS runtimes, does that really matter? You can run anything just about anywhere these days, cheaply or even for free.

Re: A look at modern PHP

#27
post #10

I've worked with PHP since 5.4, and to me the language has not been the obstacle, it has been my own skill-level that has held me back, and still is - I lack very much the core architectural skills in getting forward as a developer, among many other things. I've seen some codebases using an even older version, and I think I can understand where people are coming from with their angst towards the language - but I thin…

This has been my experience too. Ten+ years ago I had already concluded that the biggest problem PHP has is the community. Googling for "php mysql" you still end up on w3schools and the like where SQL injection is still not emphasized. Everyone was making their own frameworks and software from scratch. My last foray into PHP, and my realization that it's not actually all bad, was working in Zend Framework (iirc this was also when Ruby on Rails was fairly new and gaining popularity fast).

I haven't touched it (beyond very basic edits on my website, wordpress etc) for over a decade, but recently I inherited an older codebase at my new job. The existing codebase is an absolute mess, worse than the shit posted in those tutorials I mentioned.

But as part of the job (beyond rebuilding the application), I also had to add a big new feature to the application, a REST API. Keep in mind that due to constraints on the systems we install on, it had to be made in PHP 5.2 or 5.3 - one difference being that the older version doesn't even support an array creation shorthand (`$var = []`).

I could keep interactions with the existing codebase to a minimum. The rest was... actually surprisingly all right, thanks to me knowing what a REST API is and how to structure an application properly.

I did have to basically write my own framework (sigh) because pretty much nothing is still available that works on pre-array-shorthand-versions of PHP, but it was fairly minimal; an off-the-shelf router and URL matcher (can't be arsed with writing that myself), middleware for authentication, and a simple class structure to encapsulate different output formats (json, csv, streaming plain text).

Granted, this old version of PHP is seriously rough around the edges, and at the time it already represented great advancements in the language. I mean before 5.4 the language didn't even have a function to set the HTTP response code (you had to write the header manually).

Re: A look at modern PHP

#28
post #15

For web backend, being able to ship a single binary, such as what Rust and Go can provide, is really nice. I don't see PHP as a more compelling solution than either of those languages. Scripting and command line automation is executed better by Python and Ruby, which excel for writing Unix scripts and tools. I do not see what the use case for PHP is in 2020. PHP has one of the most abhorrent language syntax designs t…

At the same time, being able to install new or change existing software just by uploading some files to a cheap webhost is not to be dismissed as easily.

Re: A look at modern PHP

#30
post #15

For web backend, being able to ship a single binary, such as what Rust and Go can provide, is really nice. I don't see PHP as a more compelling solution than either of those languages. Scripting and command line automation is executed better by Python and Ruby, which excel for writing Unix scripts and tools. I do not see what the use case for PHP is in 2020. PHP has one of the most abhorrent language syntax designs t…

> Scripting and command line automation is executed better by Python and Ruby, which excel for writing Unix scripts and tools.

Python has a ridiculous time it needs to start up, it is not suited for any batch task that requires a lot of process creation.

> PHP has one of the most abhorrent language syntax designs this side of Perl and the standard library is wildly inconsistent.

At least it has a standard library that is both usable (in contrast to the JS ecosystem, remember left-pad?) and actually not that inconsistent if you have experience in developing C - most of what is described as "inconsistent" comes right from there.

And: the stdlib of PHP can easily be expanded upon by a rich variety of Composer libraries that can easily be deployed. Let's compare that to... Java, for example. Three popular dependency managers (and build tools): Ant, Maven, Gradle. Plus classpath worries if you're using Tomcat or other application servers which means you also have their libraries in the mix.

Changing code in production? In PHP it's as easy as changing the file using rsync and automatically all new incoming requests will use the new code, vs Java where you have to restart the server (which for large project means minutes of downtime).

Post reply on HN