November 22, 2010

8 Experts Break Down the Pros and Cons of Coding With PHP

8 Experts Break Down the Pros and Cons of Coding With PHP: "


The Web Development Series is supported by Rackspace, the better way to do hosting. Learn more about Rackspace’s hosting solutions here.

PHP ElephpantWe’ve been asking a panel of experts for advice and insights about PHP over the past several weeks.

In recent posts, our “PHP masters” gave helpful hints for beginners as well as some pointers for intermediate and advanced coders. For the last post in this series, we’ve turned to the same experts with some more general questions: What makes PHP a good language? What are some of PHP’s drawbacks? And what are the best apps or cleverest hacks you’ve seen made with and/or for PHP?

Here are their answers; we’d also love to get your thoughts in the comments. In your opinion, what are PHP’s biggest strengths and limitations?


1. Elizabeth Naramore: Spaghetti Coding


Naramore is a SourceForge employee and founded PHPWomen.org.

She told us in an e-mail, “One of PHP’s biggest strengths is also one of its limitations. PHP is very flexible in general; there are no less than 30 ways to accomplish the same task. (For example, I don’t think it’s possible to actually count the number of PHP frameworks out there.)

“While this is great for those of us who like to do things our own way, it makes it very difficult for other people to pick up where you left off, and makes debugging and refactoring a nightmare. The result can be hacks on hacks and a whole lot of crappy, spaghetti code… if code standards are not consistent and best practices aren’t followed.”

When it comes to PHP done right, Naramore says she’s a big fan of Sebastian Bergmann’s testing framework, PHPUnit, which was written in and for PHP.


2. Keith Casey: Security


Casey founded a software shop and does a lot of work in the unconference circuit.

He says PHP’s biggest strength is its ubiquity and relative ease. “Since it can be used for just about anything, it runs on every current operating system. Drupal, WordPress, Joomla, etc. benefit from this and feed it further.”

However, this ease of use is both a blessing and a curse, from Casey’s point of view. “PHP’s biggest weakness is that it may be too easy to learn. There were — and still are — some horribly insecure PHP applications out there. Lots of non-developers picked it up and didn’t know to consider security. It’s created the perception that PHP itself is insecure when the problem was within the projects.”

As far as the best apps created with PHP, Casey is not alone among our panelists in pointing to Facebook. “They’ve taken PHP to a scale beyond what most people ever considered possible. And better, as they’ve hit problems with caching, operations, deployment, etc., they’ve solved them and shared much of it back with the community. HipHop is just the most visible project.”


3. Lorna Jane Mitchell: Low Barrier to Entry


“Lornajane,” as Mitchell is more commonly known online, is a PHP consultant, developer, writer and speaker.

Like Casey, Mitchell says the language’s greatest strength and weakness are one and the same: “Anyone can program PHP.

“The low entry barrier means that there is a lot of bad PHP in the world. But bad PHP that works is useful, even if it isn’t pretty. Personally, I think if you can solve your problems with PHP, then you should get on and do it, even if it isn’t perfect.”

Mitchell recommends Joind.in as a good example of what can be done with PHP (she notes it’s an open-source project, as well). She also points to phpMyAdmin, a PHP-built app that handles the administration of one or more MySQL servers over the web.


4. Chris Cornutt: Flexible But “Scatter-Brained”


Cornutt runs PHPDeveloper.org and Joind.in and has been using PHP since 1998.

Cornutt’s thoughts echo Naramore’s; again, PHP’s flexibility is both a pro and a con, in his opinion.

He says the language’s adaptability “makes it simple to just get in there and get what you want done without having to worry about setting a lot of resources ahead of time. Anyone from a junior developer all the way out to the most senior level guy can tell you that having the language ‘just work’ and be able to bend the rules when needed is essential to PHP development.

“Unfortunately, this is also one of its biggest limitations. PHP, while a great language for web development, still has a bit of a scatter-brained mind. The development that’s been done over the years suffers some from the ‘wouldn’t it be cool if…’ mentality.

“While this can lead to some really cool stuff and some amazing things the language can do, it can also make it more difficult in the long run to maintain. That’s half of what PHP development is, really — finding the best way to adopt best practices in development despite how things were implemented in the language.”

Cornutt also recognizes Joind.in as a good example of a PHP app. “It’s based on a pretty simple LAMP platform, but it does some good things with external web services integration.”


5. Abraham Williams: Copy-Paste Hacking


Williams is a developer and self-styled “hacker advocate.”

Williams, like his fellow experts, admits that PHP “has a short route to minimum viable product.” He also says that the readily available resources online can be great and terrible at the same time.

“There is a huge amount of code laying around on the Internet ready to copy and paste to hack together. On the flip side, the low barrier of entry results in a lot of crappy code that you really don’t want running on your server.”

He also says one of his favorite PHP apps is the open-source microblogging platform StatusNet. (http://status.net/).


6. Demian Turner: Elegant OOP


Turner has been working with web and open source projects since 1996. He runs PHPKitchen.com and was a recent Seedcamp finalist.

While many of our panelists have said that PHP’s low barrier to entry is a drawback, Turner takes a different approach. He says that “aspects of PHP are easier to learn than comparable aspects in other languages,” which can lead to “horrendous code” from newer developers.

However, he sees PHP as an excellent tool for disciplined developers. “It stays close to its C roots while removing some of the unnecessary pain points like memory management, pointers and the compile cycle. The OOP implementation is simple, elegant and easier to read than its peers. The Java mantra of “complexity at any cost” is nowhere to be found; concise method names are used throughout. Libraries and extensions exist for pretty much every technology on the planet, and hacking activity and community participation are most likely the highest of any programming language.”

Still, he notes that PHP has its fair share of limitations. Turner says devs have “too much choice when it comes to selecting a library or framework to work with, and the information available is often biased and unreliable (posted by teenagers) so a lot of time can be wasted searching for quality.”

He continued, “The core development team is somewhat hysterical and not professional at times, which has resulted in backwards compatibility being broken often, and in unacceptable ways, and our current namespace implementation.”

And finally (and notably), “There currently isn’t any decent IDE for PHP, not something comparable to what’s available for Java… A new candidate that seems promising and is non-free is PHPstorm, so far I’ve found it a relief to use compared to Netbeans. Eclipse, on the Mac at least, I don’t think is even in the race.”

For an example of good PHP, Turner points to PHPDoc, which he says is “probably better than most PHP that gets written today.”


7. Stuart Herbert: Documentation


Herbert has been coding PHP since 1999; he’s been writing about PHP for several years and has contributed greatly to Gentoo Linux.

He says PHP’s greatest strength is “the fantastic documentation available at PHP.net for free. With certain other languages, you need to go out and buy the docs as books, but not with PHP.”

However, he said, the language “lacks a credible equivalent to Perl’s CPAN [Comprehensive Perl Archive Network] component library. The closest we have is either PEAR or PHP-Classes.org. Both are useful, but neither comes close to the leg-up that CPAN has given Perl programmers for years now.”

And as far as great PHP web applications are concerned, he says, “The best app has to be Facebook. Unlike Twitter, there have been few scaling issues that have affected users. It just works, a bit like PHP itself.”


8. Maggie Nelson: Community and Perception


Nelson is a PHP developer currently employed by Flickr.

She says, “The great strength of PHP is not that it is easy, but why it is so. The best part about PHP is the healthy (friendly, active, productive) PHP community. If you’re just starting with PHP, you immediately have… well-maintained and easy-to-access documentation of the language through docs on php.net.”

Nelson also says the PHP community is full of “great people who are always willing to explain and help understand. Just check out the #phpc (which stands for ‘PHP community’) channel on irc.freenode.net. Even though this channel explicitly claims not to be a help channel, you will always be pointed in the right direction for whatever PHP-related problem you’re facing.” She points to PHP Planet as a great resource for and from PHP community members.

And when it comes to the language’s drawbacks, Nelson thinks it’s mostly a matter of perspective.

“These days, PHP’s biggest limitation seems to be how it’s perceived among developers. Over the years, PHP has lacked features that other languages offered out of the box. In a way, PHP is a language that’s easy to complain about. There’s the now popular complaint about the choice of the namespace separator as well as the classic annoyance with the inconsistent order of parameters in built-in functions.

“These are small things, but things that developers seem to enjoy making fun of. In reality, many of the original complaints about the language have been addressed, mitigated or outright fixed. For example, PHP now features way nicer OOP support and the wonderful Standard Public Library.”

And for those who complain about PHP’s limitations, Nelson concludes pithily, “PHP is open source for a reason — stop QQ’ing, get involved and fix it!”

Nelson’s favorite PHP-built web apps include Flickr (naturally), Wikipedia (which runs on MediaWiki, which is written in PHP) and Threadless, the now-legendary, culturally iconic online T-shirt-monger.


Series supported by Rackspace
rackspace

The Web Development Series is supported by Rackspace, the better way to do hosting. No more worrying about web hosting uptime. No more spending your time, energy and resources trying to stay on top of things like patching, updating, monitoring, backing up data and the like. Learn why.


More Dev & Design Resources from Mashable:


- 11 Trends in Web Logo Design: The Good, the Bad and the Overused
- Essential Web Design Advice From a Wireframing Master [INTERVIEW]
- 10 Beginner Tips from PHP Masters
- 10 Intermediate and Advanced Tips from PHP Masters
- 4 Game-Changing Trends in Web App Design


Reviews: Drupal, Eclipse, Facebook, Flickr, Gentoo Linux, Internet, Joomla, MediaWiki, PHP, Perl, Threadless, Wikipedia, WordPress

More About: cons of php, List, Lists, php, php hacks, programming, pros of php, tips, Web Development, web development series

For more Dev & Design coverage:



"