Eye of the Beholder
by Jeremy on May.22, 2008, under Uncategorized
Okay, so PHP Sucks, But It Doesn’t Matter.
I like Jeff Atwood. I enjoy reading his blog and I’m looking forward to stackoverflow. I’m just not used to seeing him quote painfully old articles when trying to make his points.
From my own experience, and the countless of online tutorials and blogs, many PHP developers are guilty of the same crap code VB developers were once renowned for. OO, N-Tier, exception handling, domain modeling, refactoring and unit testing are all foreign concepts in the PHP world.
Ever heard of PHP 5? PHPUnit? Zend Studio? The plethora of other tools that real, good development shops use? Sure, a lot of the junk you see in PHP was done by hobbyists or people without a good, firm understanding of how things work. There are quite a few professionals out there who develop and distribute quality PHP-based products.
I think Stas put it best, PHP isn’t the only language where really crappy code is produced. I read The Daily WTF quite a lot and notice a ton of other languages in there, so they must all suck too, right?
It’s certainly very possible to build really elegant solutions in PHP. It’s also possible to build maintainable solutions in PHP. As tools like Zend Framework, PHPUnit, Phing, phpUnderControl, xdebug, Eclipse with PDT, Omega Vortex’s own Omega Matrix, and many others start to become more widely used, I think it’s very possible that you’ll see a gradual increase in the overall quality of PHP code.
May 22nd, 2008 on 9:23 pm
Jeremy: I wrote my article when PHP5 was mature. The point isn’t that PHP doesn’t support them, it’s that those features aren’t used. Oh, I’m sure there are plenty of good examples where they are…but I’m equally sure that there are far, far, far more where they aren’t.
Specifically, and honestly the point I haven’t really seen well defended, is that PHP itself (not as a language, but as a framework and a library) doesn’t make use of these features. Take for example the documentation for mysqli – the improved OO library for dealing with mysql:
$mysqli = new mysqli(”localhost”, “my_user”, “my_password”, “world”);
/* check connection */
if (mysqli_connect_errno()) {
printf(”Connect failed: %s\n”, mysqli_connect_error());
exit();
}
why doesn’t mysqli throw an exception if a connetion fails? Why aren’t errno and error instance members?
For backwards compatibility? Fair enough, but does that mean it doesn’t suck? I don’t think so.
If the library you build your application on isn’t solid, can you truly build a maintainable app? Absolutely – but you really are starting at a disadvantage.