Monday, July 11, 2011

scatter thought about programming language popularity

What is the most popular web programming language? For backend, we have a lot of options like python, c#, java etc. But no doubt, PHP is the answer to the question. For frontend, we still have some options, but javascript obviously wins.

However, if we are only talking about languages, in my opinion, both PHP and javascript are awful. 

If you know how Brendan Eich created javascript, you probably will get disappointed to this language. This is what he said about javascript: ok, back to JavaScript popularity. We know certain Ajax libraries are popular. Is JavaScript popular? It's hard to say. Some Ajax developers profess (and demonstrate) love for it. Yet many curse it, including me. I still think of it as a quickie love-child of C and Self. Dr. Johnson's words come to mind: "the part that is good is not original, and the part that is original is not good."

PHP, even PHP5, you can easily find lots of awful parts from it. Simple example:
class AwfulTest
public function showOff()
echo __CLASS__;

//this works!

This simple example shows a couple of awful parts of PHP:
1. An instance method can be called statically as a class method, which should not be allowed(i believe)
2. Without any warning message you might expect, even, your error reporting is E_ALL. E_ALL doesn't really mean 'all', to show the warning message, you have to explicitly turn on E_STRICT. 

However, even they are awful, it doesn't stop them becoming the most popular programming languages. So what are the reasons to their popularity?

The first reason, obviously, they are easy to pick up. Compared with learning other languages like java or c++, the learning curve for PHP & javascript is flat. I think this is the reason that most people believe why they are popular. But i think the following reasons contribute more. 

Second, they only try to solve one problem, or i should say they only focus on one thing: web programming. PHP at backend and javascript at frontend but both of them are designed to solve web programming issues.

Third, web itself. Web's popularity helps php & js become popular. If PHP and JS were focusing on desktop programming issues, they would never become that popular today. Fortunately, they are designed to solve web programming issues.

According to these reasons, if we want to use other 'better' languages to replace them, these languages must have these features: 1.Easy to learn; 2.Easy to solve web programming issues. Also, the pre requsite is web must still keep popular or even more popular.

So what other languages may become more popular than PHP in web programming? Based on the above criteria, none. Other languages may be better in other aspects, but at the moment i can't find one language especially designed for web programming and also as easy as PHP. Python? Obviously not designed for web programming. Is Ruby designed for web programming at the beginning? i don't think so. They are all general-purpose and try to be able to do everything. PHP is declared to be general purpose, but, obviously, web is what it focuses on. Anyone is trying to use PHP GTK to create desktop application?

To the frontend, we have flash/flex/actionscript and sliverlight and javafx. They are designed for frontend. But my opinion, none of them was designed to solve the most common issue at frontend: DOM manipulation. And none of them is as easy to learn as javascript(Although they are not hard).

The interesting thing is, now I believe the language that can most likely replace PHP is javascript! 

No comments: