PHP solves problems. Oh, and you can program with it too
Let's talk about the conclusions that are drawn in this article. I'll try to challenge them one-by-one.
> PHP is a great language to start programming!
No. PHP is not a good language to start programming. And I mean programming in a broad sense, not slapping together websites (which is not really programming, let's be honest). Let's look at people who know how to program, you know, the guys who participate and win awards at ACM ICPC and TopCoder. There are several such people among my friends. Exactly zero of them have started with PHP. Some have started with Pascal, some with Java, some with C++. None with PHP, even though it was available and widely used when they started. I wonder why.
> Once you started, PHP is also good for “real” programming (you know, object orientation and stuff).
First of all, "object-orientation and stuff" is not a measure of how good a programming language is. So you'll have to bring a better argument to explain why PHP is good for "real" programming (whatever that term means). Saying "but Facebook and Wikipedia use PHP!" doesn't count :-)
> PHP is not as bad as they say. There are issues, like with every language, but they rarely cause problems in practice.
Actually, it is. It has some deeper issues that lack of consistency in function arguments. Some of them really do cause problems in practice, like its retarded type system and lack of sane support for multithreading. But I'm not going to name them here because there are tons of articles on the internet explaining those issues. You have probably read some of them. If they did not change your opinion about the language, then I surely won't be able to do it.
Oh, please. Stop it! Not another fucking PHP vs. the world thread on HN! C'mon kids, get off it!
Any number of us could name tons of very successful (profitable, popular, worth tens, hundreds and billions of dollars) companies that rely to a large extent on PHP.
And the same could be said about a dozen other languages and frameworks.
Be done with this shit, will you? Haven't you had enough?
No one is disputing that you can hammer a nail with a brick. Most of the criticisms around PHP revolve around the idea that it's better idea to use a hammer (with one claw side, and one hammer side)
Likewise, when you have a real problem that isn't needs to run on a $5 shared host, or written for $4/hour in China PHP is rarely a good choice unless you happen to already know it.
If I needed to solve either of the above two problems I'd choose PHP. I write a lot of PHP (mainly wordpress sites) and it's certainly workable, it's just annoying once you've used languages like C#, Ruby, F#, Scala, Clojure, or Python.
None of the problems with PHP are unmanageable it's like driving an old diesel car, you just remember to plug it in the night before if it's going to be less than 40 degrees.
it's interesting to read the comments here. Most of them go on bashing PHP because it's a terribly designed language. They're probably right, but they're totally missing the point, primarily because this is a very technical community.
I'm not a programmer. Yes, I can solve problems with code, I can whip up a webpage, I can talk to a database, I can use Jquery. But I don't know what lambdas are, I don't understand what LISP macros are all about, and I wouldn't know where to begin writing image recognition software.
But you know what? I get stuff done. And PHP helps me do it. Because I can make things without worrying about not having a CS degree, not caring how a compiler works and not having to set up a server from scratch.
If you look at all the sites out there making money and getting views I think you'll find that an awful lot of them are made by people like me.
I think PHP's problems are actually quite solvable without core language changes. The OO model is actually pretty good, there's even reflection functionality that's sufficient to do stuff like auto-generating docs and self-validating DTO objects. The issue are the "legacy" api's, and the primitive types. What's missing are object api's wrapping the primitive and legacy functionalities. Those could be built quite easily though.
You could have something like jQuery's $ function, but for PHP variables, that gives you an OO api on top of that value (especially now that you can use the -> operator on return values of functions without intermediate assignment). I wonder why nobody's built that yet. I suppose because those in the PHP community are all busy programming instead of meta-programming.
As C++ has taught us, the solution to the errors made in a badly misdesigned language is not to continue cramming every feature you can think of into it.
I guess it's irrational, but the fact that there are some good points nestled inside this post only makes me more irritated about the post as a whole. You see, it's easier to just shrug and say "meh" if the whole thing is crap.
Te problem with the main premise is the same thing PHP apologists have been harping about all the time:
some poor soul wants to create an online encyclopaedia, or some teacher needs an online teaching platform, or someone wants to write a blog. Those people do not want to learn to program, they want to solve problems.
Newsflash: solving those kinds of problems is called programming. That's what programming is. You want to make the computer do something that it can't do with the existing programs, so you create a new program.
If a programming language is easy to use by everyone, it's because it doesn't require you to think like a programmer. It's part of the language design. If you start fixing those design decisions, you'll most likely end up with a decent language that simply isn't easy to use by everyone anymore.
This idea that you don't need to be a programmer to write programs has already failed on several occasions in history of programming: dBase, Visual Basic and Access are notable examples. Not repeating the history is too much to ask for, but let's at least try to avoid making it look like it's a good thing.
This is offtopic, but I just wanted to say that I really enjoyed your "PHP's Source Code for PHP Developers" posts. Please keep writing!
The fact that people have to constantly defend PHP says something in itself.
Coming from someone who didn't start with PHP. Has used a variety of other programming languages. And programs in PHP daily I will say that it fails in many important respects and will for some time to come. The first things that come to mind are functional programming (it has some abilities but is fairly quirky and harder to read than other languages). Being able to use array_map or array_reduce is useful in many places but certainly not elegant in PHP. Code reuse is also not that easy with PHP (though traits may fix it, but we don't use PHP 5.4 yet because it's seemed fairly problematic for us in production) and the need for autoloaders is somewhat insane once you've used a language with an actual package system. It doesn't have a mature dependency management system (though Composer is currently an up and comer). It's great for small projects but horrible to maintain at large scale - and this is from someone who has written 100K+ line programs in PHP.
That's what i like about PHP:
- low maintenance. That's true.
- straight forward coding. Yes you can shot yourself in the foot. But it's easy.
- controlled file descriptors, functions, etc:
Tell me, how can you restrict the baseopen dir, certain functions such as exec'ing, how can you log all mails going out from.. python's wsgi, or ror, etc?
That's right. You can't. Well PHP can.
So, I dislike PHP for all the reasons everyone are going to write for the umpteen time too, but it does have several unique strengths too.
Wrong! Nope!
PHP OO is screwed up and hacked together. Look at crappy support for late static binding, being unable to bind $this in closures, and all of the hack-glue that is get_class(), get_class($this), get_called_class(), self:: vs static::, the list goes on.
The thing is that, with PHP, the "new, modern" features are only surface deep... once you do anything slightly advanced, you can always tell that they were hacked on to a language that was never meant for anything more than 'include counter.php', and maybe that's okay, but stop saying it's a real programming language because it's NOT.
There's nothing particularly wrong with this article. It describes some aspects of PHP.
It's just that Atwood's article describes PHP much better. (http://www.codinghorror.com/blog/2012/06/the-php-singularity...)
I think the latter view is spot-on, and nikic's view here just serves as a perfect example of why certain people are still addicted to their awkward toolset.