ownCloud and PHP

PHP-logoPHP, as a language, is at the heart of the web. In 2013 almost 40% of websites ran on PHP. Major sites such as Wikipedia and Facebook are built on it and numerous other sites are deployed on a PHP based framework like Drupal, WordPress or Joomla. ownCloud is built on PHP, and in a conversation with ownCloud founder Frank Karlitschek and ownCloud core developer Thomas Müller we discussed where PHP is today and how its simple design benefits ownCloud.

Ye Olde days

The web used to be static. Frank reminiscences about his first web development experiences in the 90’s. Back then, “interactive on the web meant contact forms,” done in perl. PHP has made the web more dynamic and by the end of the 90’s, when PHP 3 was on stage, the language had become quite popular. The reason being that it was “quick and efficient,” as Frank points out. With perl you had this “strange divide” between the static pages and the interactive pages which go through a different URL, “the cgi-bin directory.” With PHP you could do a normal HMTL page and when you needed dynamic behavior you “just put it in and then it’s done.” This is still a strength of PHP– “everybody gets this concept in five minutes.”

Of course, “nowadays, it has turned around.” You usually don’t use PHP within the HTML of websites, instead you might embed some HTML in an app written in PHP; while static HTML has died and is generated dynamically by code. Still, this embeddable quality of PHP lowers the barrier to newcomers.evolution of knowledge wikipedia

Evolution and Reputation

Through its history PHP has evolved with the web, starting as a language integrating dynamic content in a page to becoming “a proper language today,” as Frank notes. Its reputation of being a hackish language (as Mailchimp noted in a blog post) hasn’t gone away since then. Yet if you would learn it today, like Thomas did long after having worked with many other languages, you would conclude it is “just like every scripting language for the web.”

Thomas’ first PHP code was written when he contributed to ownCloud and he notes that the language is “not without its quirks,” but is capable of doing what has to be done and is quite forgiving at that. It was the bad reputation which had kept Thomas away from PHP, “you don’t want to use something bad, so I never tried it”, he notes. But he concludes that today, PHP is “as capable as other web-oriented languages” as well as their frameworks, tools, and libraries, and provides “the same power and efficiency” as those others.

Of course, there are still things to improve. Frank blogged about a possible future for PHP earlier and he and Thomas have more thoughts on the subject. PHP has “some inconsistencies in the naming of internal functions and classes variables,” which could use a cleanup, however Frank thinks that it is “not a huge deal” and certainly not unique to PHP. Another subject he brings up is security, stating that “many people consider PHP insecure.” This reputation comes from “design decisions in the past.” This has been fixed by using the right frameworks and patterns, but “the reputation is still there.” Frank thinks that it is still easy to write insecure PHP code, but Thomas disagrees on this, noting that there is is the “problem of comparing the language with a framework.” Of course, “people say, ‘with Rails, this bug with PHP would never happen because it is handled in some framework layer.’” That is “apples and peas;” had the rails project used pure ruby, it would have run the same risk.

Thomas concludes that he never saw the horrors that were ascribed to PHP, but rather that the language has “some nice things” about it.Disco_ball4

Where PHP Shines

Frank explains that PHP makes “some things simple,” which especially helps in big projects. For example, it does not run “background stuff, no server like in Java.” A request comes, a script executes, and the request is done, which brings an advantage in scalability. But this is not about performance in itself, as Frank points out, but about the question of “if I double the hardware, do I have double the speed?” PHP is built in a way where “you don’t have a single big monster app server,” so scalability is rarely a PHP question, but rather one of database, file system and user management.

This simplicity also helps profiling, debugging, and “learning how stuff works.” Not a lot of people appreciate simplicity, Frank says. There are some things you would do “totally different” in Java EE. Thomas makes a note about Java stating that “these guys really like complexity.” For closed source or internal business driven development, a high entry barrier is “not a big problem,” he says. “There is some investment until you bring somebody on track” but that is “acceptable.” In an open source project, however, this does not work. People have “maybe two hours in the evening where they just want to hack something quickly.” Indeed, “nobody will dig into a complex build system for a week before they send their first patch,” Frank agrees.

Of course, complexity is often not without reason. Sometimes it helps to have complexity on the tooling side to ease the job later on. Thomas brings in SQL as an example. “The easy way is– write everything yourself;” separate queries for each database as needed. This is how it is in ownCloud at the moment and it “is easy; everybody can contribute.” But the result is that you have to “test the code paths on every database.” But by using some “advanced technologies like a query builder or object-relationship, OM tool,” the test efforts could be reduced, however, the entry level will remain higher. This thus represents a “trade-off that we are facing.”

Frank always brings this up when “we have people who want to improve the framework with complex, sophisticated solutions.” These solutions, of course, bring benefits but also “create a barrier for new people.” We have to be careful that we don’t “create a monster that nobody can maintain anymore;” just one person. “It’s not only about the architecture, it is also about the social aspects and the community momentum.” Frank emphasizes that “fun is so important because not everybody is paid to work on ownCloud.” PHP isn’t fun because of itself, but because “it is easier to get into” and because “a lot of people know PHP” and can provide resources online like tutorials or help. Last but not least, it is fun because “many interesting projects are built in PHP,” as Thomas noted, including ownCloud of course!

The many PHP projects means that there is a lot of PHP knowledge out there. Many developers are familiar with the language, many libraries are available offering API’s to developers and are making it easy to integrate new functionality. However,not every library, connector, or module out there is perfect, but it usually beats having to write one yourself!

PHP and ownCloud

ownCloud, like many PHP projects, benefits from the ecosystem around PHP. The language might not be perfect, but it has come a long way and still has a huge momentum as well as significant advantages that make it a great choice for many projects. The low barrier to entry is certainly one of them, but in the end,what matters is that interesting technology is written, bringing real, tangible benefits to users.

Comments are closed.