Pages

Monday, October 27, 2014

Wordpress

A while ago, I was hired to extend a web site for a small company. The web site had been build by one of their graphics designers, who did not normally work with programming. As a result, this site had been built using Wordpress, because this was the easiest system for this non-programmer to start with, while he at the same time had to learn the basics of HTML, CSS and PHP. The custom work that he had done was not the best, but still quite impressive considering the time frame and the fact that he did not know anything about coding when he started. But this article is not about designers turning programmers. It is a small overview of Wordpress, and about some of the reasons why I would never build anything with in, unless I am forced to.

Starting on this site, I did not know anything about Wordpress. All that I knew was that it used to be a small blog system, which apparently had grown larger over time. I started reading some of the documentation, and it did seam like something worth looking into. I especially liked the idea of their action and filter callbacks. However, once I got started, I became less impressed.

First of all Wordpress is missing a lot of rules. Sure they have their Plugin.php file, but there is no rules as to what this file should contain. If you compare it to Drupal, which have a module file containing hooks with strict naming schemes, Wordpress introduces the same policy as PHP, where no standard for anything exist. Now I do like PHP, but it would be a lot better, if they implemented parts of Hack into it. Static Typing for one.

Their plugin system is also very minimal. If you need to add some additional tings to the existing blog system, then this is fine. But if you need to add some extensive work into Wordpress, you will need to integrate this directly into the "Theme" files. Also while talking about the Theme files, I think that the people behind Wordpress has misunderstood the word "Theme". These files actually makes up most of the system. They work as bootstrap of some sort, they contain a lot of the site logic as well as the Themes. All in all, they act much like MVC wrapped into one single "Theme" file.

The worst part of Wordpress, some of which was mentioned above, is their action and filers system. The idea is great, but it is extremely pure designed. This is the part that would have benefited the most by some stricter rules. One of the things that one should avoid when working with PHP, is their dynamic caller functions "call_user_func" and "call_user_func_array". Requests that normally takes nanoseconds to load, will take milliseconds and sometimes seconds, when introduced to the above functions. And this is only by a few calls pr. request. Wordpress has integrated this into the entire core of the system. Even before the initialization is done, these functions has been called numerous times. After that, even more calls is done by more of Wordpress's functions, by themes and by plugins. Depending on what you have installed and enabled, you can end up in 3 digit calls to these extremely slow functions. This is the worst design that I have ever seen in any framework for any language, and I cannot stop thinking about those poor CPU's that has to process all of this unnecessary code.

A better design would have been to implement either a strict procedural design, allowing only functions to be parsed, which can be executed without any additional resources. Or implement a strict OOP design by using interfaces, much like how callbacks works in Android.

If you just need a small blog site with few visitors and if you hate your server, then by all means, use Wordpress. But if you want a serious site with many visitors, if you love your server and if you'd like to have some nice coding standards, I would suggest using another CMS or build one using one of the many frameworks available. Wordpress is a mess, there is no standards of any kind, most of your work will have to be implemented using different hacks to work properly and it will rape your server daily.

No comments:

Post a Comment