PHP Classes

6 Reasons Why PHP is a Hobbit

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog 6 Reasons Why PHP is ...   Post a comment Post a comment   See comments See comments (19)   Trackbacks (0)  

Author:

Viewers: 29

Last month viewers: 5

Categories: PHP community, PHP opinions

Sometime ago a user of the Quora site asked a question if there was a language war, which languages you support and why.

Another user gave a very creative response comparing programming languages with characters of the Lord of the Rings story of JRR Tolkien.

Read this article to understand why PHP or its fans should be compared with Hobbits.




Loaded Article

Contents

Programming Language Wars

6 Reasons Why PHP is an Hobbit

1. PHP is Scripted C

2. PHP is not Teaming with C++ Evil

3. PHP is Not particularly Beautiful but it is Very Useful

4. PHP is Not the Fastest Language to Execute but is Agile

5. JavaScript could be a Hobbit too but Asynchronous Programming is a Hell

6. PHP Success Causes the Envy of Others

Your Comments


Programming Language Wars

Personally I think programming language wars are silly. Languages are tools. You should use them as such, preferably picking the most adequate language for each task.

Some people take the choice of programming language very personally. If somebody attacks their language of choice and does not give a very favorable opinion about that language, they get very upset and sometimes retaliate as if they are in the middle of a holy war.

Opinions are like faces. Each person has his own face. Some people may like it or not. There is no need to become upset about it. The fact is that is impossible to agree with everybody.

Different people have different criteria, and so different opinions about each programming language. There is no reason why expressing opposite opinions should be taken personally. If people have different opinions, at least agree to disagree.

6 Reasons Why PHP is an Hobbit

The original posted asked in the Programming Languages topic If there is a war of programming languages who would you support and why?

Prithviraj Udaya gave a very creative response comparing programming languages with characters of the Lord of the Rings story. It is a bit odd to compare languages with characters. Maybe he meant to compare LOTR characters with each language developers.

I do not necessarily agree with his comparisons. Here is my opinion on why PHP and its developers should be compared to Hobbits.

1. PHP is Scripted C

In the original reply, the author states that the C language should be compared to The One Ring because of its power.

In Lord of the Rings, Frodo and also Bilbo before him in The Hobbit got access to the power of The One Ring.

C is the base of PHP engine. Most of PHP run time code is made of C libraries. PHP is just a glue language to call those libraries. So PHP applications benefit from very fast C libraries.

PHP is scripted C. You just do not have to deal with the pain of managing resources like you have to do in C to deal with memory allocation, because PHP runtime engine manage those resources for you.

2. PHP is not Teaming with C++ Evil

The original response claimed PHP was teaming with C++. That is a reference to the original Facebook HipHop PHP compiler project.

Saruman was associated to C++ because in the beginning everybody thought he was a good guy but then people started to realize it is not like that.

Similarly, in the beginning HipHop was mainly a PHP to C++ translator because it was assumed it would be a good solution to generate fast PHP compiled code. The problem is that optimized PHP to C++ translation takes a long time to process. It is not a viable solution for most people. Even for Facebook it is not very convenient.

However things have changed. Facebook realized there are better approaches which are not as bad and can come to equally good results. They have evolved to a PHP JIT compiler using dynamic compilation.

This means that the PHP code is compiled first to byte codes and then those byte codes are compiled on demand to machine code. So there is no longer PHP to C++ translation. HipHop got rid of that evil.

3. PHP is Not particularly Beautiful but it is Very Useful

In the original response PHP was being compared with Orcs just because those creatures teamed with Saruman, and he is C++. Since that is no longer true, that comparison does not make sense anymore.

Still PHP is not particularly beautiful. It suffers of inconsistencies introduced by many developers contributing over the years to the language with whatever they needed to make it useful for them.

Hobbits are also not particularly beautiful, at least not like elves. Hobbits may look cute because they look like small children. Anyway what matters is that they are useful, as they adapt to whatever are the needs.

4. PHP is Not the Fastest Language to Execute but is Agile

PHP is a scripting language. Despite the great efforts to make it faster with Facebook HipHop compiler or even the Phalanger project that compiles PHP to .NET assemblies, most PHP developers use the official Zend engine based PHP implementation.

The official PHP implementation may not be the fastest but PHP development is very agile. It is even funny when some PHP developers say they will add something to the "PHP Build". I suspect they came from the Java world.

There is no intermediate build process to compile PHP before you can run it. Just write your PHP code in a text file and that is all you need.

The Hobbits are also very agile. They are not the strongest of the character types that live the in the Middle Earth, but notice that in the end they are the ones that solve everybody's problems.

5. JavaScript could be a Hobbit too but Asynchronous Programming is a Hell

JavaScript is another language that shares some characteristics of PHP. It is for scripting, there are good JIT compilers for JavaScript, and most developers are familiar with it.

The problem of JavaScript is that it was originally meant for scripting Web pages presented on a browser. JavaScript is fine for that. Its model of execution of the code is asynchronous. This means that most calls to functions that require waiting for some I/O operation to finish need to be handled by callback functions.

Asynchronous programming is adequate and often very resource efficient for that. However, for most developers it is too painful to write code that needs to handle things like conditions and loops from inside callback functions.

Node.js works mostly with asynchronous library calls, but knowing the pain that it is to deal with asynchronous programming everywhere, Node.js also provides some functions that can handle I/O operations synchronously, so no callbacks are need.

Asynchronous programming is a paradigm shift that many developers refuse to adapt, especially those used to most other server side programming languages that work synchronously.

To make good use of resources it is probably better to implement a PHP engine that uses multi-threading instead of asynchronous programming.

That is what for instance the Facebook HipHop compiler does. It generates an executable program that works as multi-threaded Web server. This way you can run PHP code very efficiently with low memory consumption, great parallelism level, and you do not need to rewrite your code to run asynchronously using callback functions.

6. PHP Success Causes the Envy of Others

PHP is a very successful programming language to develop Web applications. The problem of success is that triggers the envy of others.

In LOTR, the Hobbits get the power of The One True Ring. That triggered the envy of Gollum the troll. He became so desperate to get the ring that he did everything to attack the Hobbits Bilbo and then Frodo to take the ring from them at any cost.

This reminds me the people that keep campaigning against PHP. It is a bit silly but it is evident that most of those prefer some other language. They seem to campaign against PHP in the hope that their preferred language gets as popular, never stopping to use hate speech against PHP.

It seems that they do not get why PHP got so popular. It was certainly not by having its developers campaigning against other languages.

In the word of its creator, Rasmus Lerdorf, PHP was created to solve the Web problem. It may sound odd but Rasmus is a not big fan of writing code, as he admits. He is a very pragmatic person. So he created the language to solve his Web problems. Then others joined to make it better.

Some people prefer other languages that already existed when PHP was created. Still those languages did not succeed on the Web as PHP because they were not focused on Web development. Those languages often need huge frameworks to do things that PHP provides built-in.

So, if other languages are not as successful as PHP for Web development, blame it on the creators of those languages. It is certainly not PHP developers fault.

Admittedly things are even a bit ironic. Let me explain. One of the most successful PHP applications is undoubtedly Wordpress. The ironic part is that some developers that prefer other languages, when they create their sites, they use Wordpress to create their blogs.

Even within the PHP community, Wordpress usage is also a bit ironic. Some of the most prude PHP developers keep preaching the use of object oriented programming as a mandatory practice, all the design patterns you can stuff in your projects, and use bloated frameworks that require loads of code to create even the simplest things.

Wordpress programming is not particularly beautiful. Nowadays it uses some OOP classes but great part of it is made of global code. The plug-in system relies on global functions. That is not very convenient because global code makes it harder to organize your PHP projects, as you need to keep avoiding the collision of the names of of global variables and functions.

Despite this fact, guess what blog system many of those prude PHP developers use? Wordpress of course.

A few years ago I had the pleasure to personally meet Matt Mullenweg, the creator of Wordpress. He is a very different from Rasmus Lerdorf, the creator of PHP. But they have something very important in common, they are very pragmatic.

They focused on solving their problems and do not seem to care much if their code is beautiful or not in the eyes of prude developers. And this is what matters for success, get things done and fast. By the way, that is the very same reason why Mark Zuckerberg decided to stick with PHP for Facebook development.

Unfortunately developers that are fans of other languages often do not get this point. Just recently a well known developer decided to create a new forum system project. He wanted to be as popular as Wordpress, but for forums.

I am not going to name names because my point is not to embarrass anybody with this article. I deeply respect that developer, despite I do not agree with several of his opinions.

The fact is that he did not choose the traditional PHP and MySQL duo to develop his forum system. He decided to use Ruby and PostgreSQL.

Part of the success of Wordpress was due to the use of PHP and MySQL. This duo is available in every hosting company at the cheapest prices. This fact made PHP solutions affordable to anybody that wants to have a Web site.

If you want to have cheap Web hosting based on Ruby and PostgreSQL that is going to be a hell to find. It is possible, but there is much less offer and not at the same prices because the lack of competition keeps the prices higher. That is a basic economy principle.

Another point is that writing Wordpress plug-ins is relatively easy. This lead to the fact that loads of plug-ins were developed to customize Wordpress to do practically anything, to the point that nowadays it is not just a blog system.

Could a system based on Ruby and PostgreSQL be as successful as another based on PHP and MySQL? I don't know, but I doubt it. Maybe I am wrong and the future will prove things can be different.

Anyway, I am not concerned with the success of other people's projects. I am just puzzled by the fact that some developers are so obsessed with campaigning against PHP that they do not mind compromising the success of their projects just because they prefer a different less popular language.

Your Comments

As mentioned in the beginning, the comparison between languages and LOTR characters is something amusing that I decided to do just for pure fun. This article is just meant to express my opinion and does not necessarily reflect the opinions of other PHP developers.

Whether you agree or not, feel free to post a comment to express your opinions regarding these matters of language comparisons and the correspondence with the LOTR characters.

If you want to express disagreement, that is fine, just try to be civilized and avoid taking it personally.




You need to be a registered user or login to post a comment

Login Immediately with your account on:



Comments:

10. Funny - Moses Romero (2015-06-04 20:44)
compliments to the author... - 0 replies
Read the whole comment and replies

9. pHp is Prince of Web Development - Chris Morton (2013-02-20 08:08)
and ASP.net sux eggs... - 0 replies
Read the whole comment and replies

7. Gollum is not a Troll - Ralf Strehle (2013-02-19 00:21)
musings about the One Ring... - 1 reply
Read the whole comment and replies

8. Teamwork Comparison - Corey Avis (2013-02-19 00:21)
Teamwork is crucial... - 1 reply
Read the whole comment and replies

4. Asynchronous programming isn't a hell :/ - Spencer Andrew Lockhart (2013-02-18 23:20)
No matter how you look at it, HTTP requires asynchronous code.... - 1 reply
Read the whole comment and replies

3. Look at the down vote - Said Bakr (2013-02-18 23:20)
Some people refuses the idea that PHP is scripted C... - 2 replies
Read the whole comment and replies

6. pointers - Frederik Yssing (2013-02-18 23:19)
php... - 1 reply
Read the whole comment and replies

5. Well said - Savoul Pelister (2013-02-18 22:57)
PHP is a great success and some cant digest that.... - 1 reply
Read the whole comment and replies

1. 6-Reasons-Why-PHP-is-a-Hobbit - kanuj bhatnagar (2013-02-18 22:40)
6-Reasons-Why-PHP-is-a-Hobbit... - 1 reply
Read the whole comment and replies

2. Good points - Kevin Donnelly (2013-02-18 14:27)
Pragmatism should rule!... - 1 reply
Read the whole comment and replies



  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog 6 Reasons Why PHP is ...   Post a comment Post a comment   See comments See comments (19)   Trackbacks (0)