We're a place where coders share, stay up-to-date and grow their careers.
It's not so much that PHP is a bad language, as PHP was designed around a way of doing things that doesn't make a ton of sense in the modern context.
Back in 1995 when dynamic pages meant serving up lots of fixed HTML with a little bit of dynamic content from the DB thrown in it made a ton of sense. The status quo at the time was CGI Perl scripts that generated HTML by literally writing print statements. I literally mean print "
Enter PHP, where you could write a well formed HTML document, just escape to PHP mode in the few places you need to print out a variable or have some logic. It creator never even set out to write a full fledged programming language, he just wanted to create a little scripting language, do some includes and such. It was great for its time but its limitations show.
Web apps today don't work the same way as they did in 1995. Almost all of the code today tends to be "business logic", and people prefer not to mix code and HTML in the same file. A telltale sign is when almost every php file starts off with <?php and ends with ?> and is never in HTML mode at all, all all HTML is generated with another templating language (eg. symfony), which uses a different syntax.
In other words, despite the improvements that have made along the way, frameworks that help mitigate some of PHPs inherent flaws etc., at the end of the day PHP has outgrown its original purpose and you're really fighting it every step of the way when you're writing a modern application.
It certainly doesn't say anything bad about you as a programmer if you're in a company with a large PHP codebase or a large team that already uses PHP. If you have a legacy app it's probably hard to make the case take the time and effort and other costs to switch to a new platform. But if that's the language you choose to go with in a project without those constraints, you have to step back and ask yourself why.
"ends with ?>" is a telltale sign that application is not written in modern PHP, as that's universally considered bad practice. PHP in 2017 is very different from PHP in 1995.
Maybe they should update their tutorial then. I sure as hell can't tell the difference.
PHP is far from unique in starting out as a very different language, and having some baggage because of that. For a trendy example, look at node.js; for a more established one, look at C; or go to the enterprise, and tell me with a straight face that Sun got Java right first time.
If you want to build your website in Erlang, or Haskell, or whatever, fine. But don't hold your breath for the world to join you.
"It's not so much that PHP is a bad language, as PHP was designed around a way of doing things that doesn't make a ton of sense in the modern context."
You mean like the whole "serverless" thing that's all the rage today, and that's baically exactly how PHP works (receive request, start a process, get query and body params, process, return response, kill the process)?
Which, incidentally, is also how you can scale horizontally by adding more servers (containers?)
If you're going to reduce things down to "receive request, start a process, get query and body params, process, return response, kill the process" then you might as well go back to using Perl CGI scripts, because your description works equally well for that.
I agree. The only thing PHP has going for it these days is the giant existing ecosystem (though many things therein are of questionable quality), including the drop-dead simplicity of hosting it virtually anywhere at any price point. In virtually all other aspects it's a language full of compromises and pitfalls. Yes, you can be perfectly productive in it, and as far as that concerns you as a programmer that's all that really matters. But it is rightfully the butt of jokes as a language.
"The only thing PHP has going for it is ... and ... and ..." - you remind me of the Monty Python sketch about "what have the Romans ever done for us?"
Touché. Though again, my gripe is specifically about the core language itself, which is a hot mess. That is merely mitigated by all the rest. But there are other languages which have all the rest and are good languages.
The ultimate point of my article was that building a successful application is our goal as developers and we shouldn’t critique each other so heavily for choosing one language or another. I understand that PHP has flaws, but it is modernizing and can be used to make a solid web app. Many programmers are comfortable with the language and can make a good non-legacy website with it so I would be careful to not just relegate PHP to the past.
Out of curiosity, which other platforms have you seriously tried out? By seriously, I mean actually taken the time to lean and tried to build a non-trivial project in.
I'd be interested in your answer the other way around: what modern PHP frameworks have you taken the time to learn and built a non-trivial project in? Is your criticism of PHP based on genuine experience, out of date memories, or just received wisdom and prejudice?
I've used PHP for many years including a custom website that got millions of pageviews a day, and I've used WordPress quite a bit including custom themes and plugins. Yes, more recent version of PHP are better than older ones but I've seen nothing that makes me want to go back.
It's not just PHP that's got better, the frameworks and ecosystem that are available now are so different from just a few years ago. Saying you've written some WordPress plugins is a bit like saying you've written some Java applets, so don't see any reason to give a Java framework a try. It's pretty harsh to assume everyone only uses PHP because they don't know better, if you're only judging it from that distance.
Reading comprehension is not your strong suit, is it?
Maybe you should actually trying reading what I wrote.
In all your petulant posts on this topic, you've actually made zero arguments about the merits of PHP, you've just attacked other people who don't think PHP is all that great.
If you want to explain why you think PHP is so great, I'd be happy to hear about it. If not, let's just end this conversation. I don't even slightly care what language you use. If you're happy with PHP, go for it.
I haven't been giving specific examples of PHP's advantages, because that's not what this discussion was about; there have been very few concrete examples of PHP's flaws, either.
The original post was about people feeling undermined by being told that they're "doing it wrong" by using PHP. In that context, it's hard to see how else to interpret a response ending "you should ask yourself why" other than "yes, you are doing it wrong". That's quite a criticism, not just of the language, but of anyone using it.
You were also the one to mention frameworks, but you didn't actually name which ones. The implication seems to be that these are so much better than anything possible in PHP that you don't even need to try the PHP frameworks, and already know that anyone would be a fool not to switch.
I think you've effectively answered my question, thank you. I'm done engaging with you.
I don't understand why you felt the need to comment in the first place, but now are unwilling to continue. Thank you for your vague advice to try something other than PHP because it will be better in some unstated way.
We're a place where coders share, stay up-to-date and grow their careers.