We Don't Hate PHP
hologram.io
hologram.io
Here are some actual reasons to like PHP:
1. Java-like interfaces and classes and strict argument (and soon parameter) typing enforced at runtime
2. Autoloading and "lazy loading" of classes means defining bi-directional relationships between classes/types is painless (this can of course also make you shoot yourself in the foot, but I prefer that to dealing with circular imports in Python for example)
3. The deployment model is dead simple on a VM (with drawbacks, but by the time you need things like atomic deployments you've probably moved to containers anyway)
4. Statelessness
5. Performance (despite the statelessness!)
6. A very healthy package ecosystem, with several cross-framework interoperability projects
It has lots of bad parts as well, of course, but so does every language. And you may disagree with some of the things I listed if you don't like the particular feature or design, but that doesn't make them not advantages.
I don't really like PHP, because of inconsistency (it tends to break to flow for me) (but maybe it changed since 2014), but php with strict typing is a big plus for me and php7 is already more than fast enough. I might try it again.
The real issue i have with PHP is frameworks :/
Too much choice is a productivity killer for me.
Here's my framework guide: Slim if you're a minimalist and like doing things yourself, Laravel if you like convenience and are a quick learner, Symfony if you want to build something that will last 5+ years.
For instance, the arguments for array_map and array_reduce are reversed, one takes the function as first argument, one the array.
Since the above equally applies to you, I suppose you're saying that these "advantages" are a matter of opinion.
The point I wanted to make was that you might disagree with a certain feature/design but that doesn't make them invalid reasons for someone else who likes them to see them as advantages.
I would like to go one further and say most other more modern programming languages do each of these better. It's always a good idea to look what is beyond the horizon.
And to be sure, modern PHP is better. The beginnings of typing, the fixing of horrible standard library behaviors, and an ecosystem with package management are game changers. But to me, all of that means nothing if the ecosystem is primarily running legacy apps. There are clearly proponents of modern PHP that embrace the new PHP, but what really gives it any modern relevance is old school apps like Mediawiki, phpBB, etc. and I feel like they all underscore what I dislike about PHP: not a single problem but a mindset that is incompatible with modern internet. There is no assumption of shared nothing; most apps assume the disk can be used for persistence. And it’s tricky to dockerize a PHP app effectively since you typically need multiple processes; I know there’s work on an app server in PHP itself but last I checked it was for development, and rather I ended up using uWSGIs embedded PHP support as the only solution I could even find that could do this in a way that wasn’t horrifically ugly or intensive.
It still has its issues. For me the prime issue with PHP is the execution model. I am not in for my document root being my source dir. This weird behavior comes from the CGI era and to this day it doesn’t really feel like there is intent to move away from it. Rather, the age old front controller pattern is poised as a “solution,” entangling web server, PHP and application configuration together in some unholy mess, versus the modern pattern of having an app server.
Absolutely. I handle a lot of the devops work at my job and PHP containers are just all around more annoying to build, configure and run than most other languages. Even on modern frameworks like Laravel still have a lot of default assumptions of being hosted on a server all by themselves.
It's weird how a language that gained so much traction for being the easy language to host has become one of the harder ones to deploy in the modern era.
Otherwise I’ll be stuck in the public sector maintaining broken Deloitte unemployment portals, making 1/3rd of what junior coding academy developers make.
Easy calculus.
Source: left php about a decade ago and I'm not looking back
With Python I'd be stuck reading the latest tutorial on how to deploy virtualenv properly. Java/Spring I'd die of boredom before I figure out where WebMvcAutoConfigurationAdapter wants me to put Bootstrap css this year. Sometimes you just want a quick solution to an easy problem and move on to other things than coding, and I find PHP fits that use case perfectly.
i'm glad those times happened, they were fun - but i wouldn't want to work like that today.
For an article that purports "PHP is good now", I wouldn't expect one of the selling points to be something that could be done in (and is routinely done), in Python/Perl/Ruby for over 25 years now.
Language wise, it's catching up a lot and the additions seem to be sensible enough. I'm not sure I would start a fresh project in it but it's great to see how it's matured over the years, and just like Typescript is to JS, I hope it provides a good introduction to things like static typing to novice programmers who are starting out with PHP for pure ease of use.
Beyond that, what's the point in hating a language? I've found real joy and enthusiasm in playing with different ones just to get a feel for how you would approach certain problems with them.
That said, I'm uncomfortable working with languages which I feel are outdated and get in the way, such as COBOL. You could say I do hate COBOL. I really, really disliked javascript in its infancy; you fought the (lack of) tools and suffered a lot just to achieve something that would have taken you 5 minutes with other languages. This is not the javascript of today, mind you.
One last thing: one should always be wary of the Blub Paradox (one of the best essays by PG in my opinion; I don't particularly like the rest, mind you). People who ignore advances in programming languages tend to look at "their" language, maybe praise its late-coming improvements, and wonder why other people think it's not enough. But it's often not enough indeed, once you learn those other languages...
I've no opinion of PHP because I've never used it.
In practice it mainly means that, in exchange for process startup overhead added to your response times, you get to get away with being sloppy about how you initialize and dispose of resources. It's not something I have ever really regarded as a virtue, and it's one reason why PHP devs can have real trouble transitioning to platforms where the same assumption no longer holds.
But dealing with small leaks that build over time can be a time sink to track down, particularly if in libs you didn’t author.
Some folks might call that backward. I call it solving a problem with the right tool.
1. The Laravel ecosystem.
2. I have over ten years of PHP experience.
1. I'm not aware of any non-trivial feature in Laravel that isn't matched by e.g. Rails, Django, Elixir, or indeed any sufficiently modern web framework.
2. This speaks more to where your comfort zone resides than any intrinsic merit of the language/ecosystem.
To be clear: there's nothing wrong with your using PHP. I'm just left wondering what your initial point was... that PHP is your favorite language?
Is there ever a best tool for _everyone_?
I have only ever been convinced that something is the best tool for a job, when taking into a account a lot of context, exact requirements, available resources, etc. Otherwise you are almost always left with quite a large number of options that are equal for the information available and you can basically choose from by rolling dice.
Regarding 2) I think it goes beyond comfort zone. I have seen plenty of completely chaotic, unmaintainable code bases due to the initial developer(s) starting the project without any prior experience of the technology. Of course many paths lead to chaos, but I would wary to start anything time critical in something too different to what I'm already quite comfortable in
Isn't it just not that popular an option anymore to start new projects with? Most people are aware of the language having changed a lot since its heydays.
And honestly, from the article I'm not quite sure why I should consider using PHP. Sure, it has a lot of modern bells and whistles now that it didn't when I last used it 2005-ish, but what makes it stand out? I know a number of people that are super happy and productive with modern PHP, but those are all people that have been using it continuously since forever so it makes a lot of sense for them. But why switch to it from another stack?
E.g. the supposed best database integration of any language with "PHP Database Objects". At least the examples given are the absolute bare minimum I'd expect to get from such an integration. What makes it the best?
Quite. Just give me a boring language with a stable ecosystem, mature and extensive tooling and fully understood quirks. That means all the time and effort can be spent building the actual product instead of burning time monkeying around with the shiny-new language.
This means that things like Java and PHP (and C in some domains) are nearly universally the correct answer if your goal is to build a product instead of building a resume.
So yeah, there are some people out there who really really hate PHP.
This kind of toxic mentality doesn't produce better code, and it sure doesn't produce better coders. It's just free-floating hostility and gatekeeping.
Here's a few parts of PHP that improved in the past 6 years:
* Static type declarations (and return types, and strict typing, ...)
* Composer has become the de facto package manager for the PHP ecosystem
* Better cryptography (bye mcrypt, hello sodium)
* High quality open source libraries (i.e. Guzzle)
And I haven't even reviewed all of the changes coming in 8.0.
OTOH, there are now mainstream languages with null in the type system, union types, pattern matching, etc... it looks (from the outside) like PHP caught up to where the industry was 10 years ago. If I'm uninformed I'd love to see a comparison to Typescript, Kotlin, Swift, or Scala3.
I made a lot of money on PHP code. But then realized there were other languages that I could also make money on, that worked better for what I needed. But would I go back? No..
For example every Java file seems to start with entire screenfuls of imports.
I've never seen that in any other language. Though I'm sure there are a lot of pitfalls, because module systems tend to grow complex over time.
Proceeds to give a long list of outdated and clunky examples that look like a joke next to any modern framework.
That said, I'm not even saying PHP is bad, but this article doesn't convince me why I'd pick PHP over literally anything else.
I don't think any Python folks would bother to clone it as most of what it does already has better answers in the Python world.
For example, SQLAlchemy is amazing, and I'd never willingly swap it for Laravel's ActiveRecord implementation.
To be clear, I definitely prefer Python to PHP, having worked professionally in both languages (PHP much more often, and currently).
Did Python stray from this? Occasionally yes. Did PHP with Laravel? I'm going to guess also yes.
Nothing can beat features like hot reloading, fast debugging, get things done in a matter of few hours.
Entity Framework in .NET is lightyears ahead of PDO.
I'm a fan of PHP but the DB connectivity is definitely not one of the strong points.
The spirit of early-days security-ignorant PHP lives on in WordPress, where proper security is basically impossible. You'll never be confident that you've found all the back doors after an incident.
That doesn't add up. There was no "PHP 2.0"; the language was still referred to as PHP/FI at that point. And PHP 3 was released in 1998 -- by 2000, I have a hard time believing you would have still been using PHP/FI, which was a much more limited tool.