Tuesday, 2 December 2014

Why developers love and hate PHP

thumbs up thumbs down

The language has a substantial stake in Web development, but it is marred by design flaws

PHP, the venerable server-side scripting language, is famous for its use in Web development. First released in 1995 by Rasmus Lerdorf, it has been leveraged by the likes of WordPress and Facebook and reportedly is used in 82 percent of websites whose server-side programming language is known, according to W3Techs. The language is slightly behind Java in the PyPL Popularity of Programming Language index, and it ranks sixth in the rival Tiobe index. A high-performing upgrade, PHP 7, is due in 2015.
Like any technology, however, it has its devotees and bashers. Here's why advocates swear by PHP and why some dissenters might swear at it.

Good: It's popular and easy to learn

"PHP is by far the most popular Web development language," says Andi Gutmans, CEO at PHP tools vendor Zend Technologies. Josh Lockhart, a Web developer at new Media Campaigns, as well as an author, emphasizes PHP's small learning curve, ease of deployment, and fast development iteration. "PHP is one of the easiest and most accessible Web programming languages available," Lockhart says. "It's installed on a vast majority of servers (including most shared hosting plans). It's relatively easy to learn thanks to excellent online documentation and up-to-date online resources."

Good: Jobs available for Web developers

"PHP will help you make money and find a job," on the server-side Web, Gutmans said. A quick search on the Dice.com technology jobs site last week found 3,366 jobs related to PHP. This pales in comparison to the 17,418 Java jobs and trails Perl (4,300 jobs) and Python (5,429 jobs), but it was more than Ruby (2,973 jobs) and even Objective-C (985 jobs). Lockhart sees PHP as one of the most frequently used languages, although it's a bit less trendy than languages like Ruby, Python, Go, and Rust.

Good: It continues to evolve

The language boasts modern capabilities like closures and namespaces, as well as performance and modern frameworks. As Gutmans notes, "Some people who want to move away are not necessarily educated on what PHP has to offer." Developers, Lockhart says, are recognizing that PHP is powerful with modern features and a proper object-oriented programming model. Coming up is version 7, set to offer dramatic performance improvements in applications. Lockhart notes Facebook's enhancements for PHP, including the HHVM virtual machine and the Hack language.

Bad: Complaints about design, lack of focus

"Virtually every feature in PHP is broken somehow," says blogger Eevee in "PHP: A fractal of bad design," a 2012 missive against the language. Eevee goes thumbs-down on not only the language, but the framework and ecosystem as well. Rather than being predictable and consistent, the language is full of surprises and is inconsistent, according to the blogger. Among the criticisms, PHP is called opaque, with no stack traces by default, and saddled with complex weak typing "There's no clear design philosophy. Early PHP was inspired by Perl; the huge stdlib with 'out' params is from C; the OO parts are designed like C++ and Java."
Lockhart acknowledges Eevee's anti-PHO sermon as being "hyperbolic with a kernel of truth." Although a PHP advocate, Lockhart was gracious enough to list criticisms when asked:
  • The language is inconsistent, specifically function names and argument ordering. "This is easily learned, though, so it's not a very big concern."
  • PHP still has a lot of legacy baggage, like globals, magic quotes, etc. "These bad practices are slowly being pruned from the language, but until they are gone, they help ignorant developers persist bad practices."
  • PHP is not as focused as other languages, which Lockhart attributes to its being developed "piecemeal over a long period of time, often by committee.

No comments:

Post a Comment