It’s been a year already since I am a system developer focusing on a desktop application. Even I’m not so familiar with this PHP but still I discover a dark side on it. I know PHP is quite easy to learn and to make program from it but I think PHP in an incomplete programming language based on my research. Why? Lets see. I have here a helpful notes coming from one of the expert.
1) No need to define and declare variable - In most of the programming language especially to the Object Oriented programming language, you have to declare the type of variable and define it before to be used in the code but in php you don’t have declare the type of variable before using. Although, it make easy for the programmer but its a bad practice at all for a genuine programming concept.
2) No Strict data conversion - Well as you see in java, if you try to con cat a integer variable with a string variable you’ve to convert it into string variable before con cating with string otherwise compiler throws exception. But, in php if you’ve to do so you don’t have to do any kind of data conversation, which you might say easy for programmers but what i say thats bad practice for programmers.
3) Bad Recursion - Recursion is the mechanism in which a function calls itself. This is a powerful feature which can make something complex something simple. An example of a function using recursion is quick sort. Unfortunately, PHP is not good at recursion. Zeev, one or the developers of PHP, says this: “PHP 4.0 (Zend) uses the stack for intensive data, rather than using the heap. That means that its tolerance recursive functions is significantly lower than that of other languages.” . A good programming language should provide good recursion support.
4) No namespaces - Suppose someone creates a PHP-module that can read files. One of the functions in this module is called read. And someone Else’s module can read web pages and also contains a function read. Then it is impossible to use these modules together because PHP will not know which read function you want.
An easy solution to this is namespaces. It was a suggested feature for PHP 5, but unfortunately it didn’t make it. Now, without namespaces, every function has to be prefixed with the module name, to prevent name collisions. This leads to terrible long function names like xsl_xsltprocessor_transform_to_xml which makes code harder to write and read.
5) In consequent function naming convention - Some function names consist of more than one word. There are three conventions for combining these words:
a. Glued together: getbidsbyday
b. Separated with underscores: get_bids_by_day
c. Camel case: getBidsByDay
Most Languages choose one of these variants, like java uses Camel case but PHP uses all of them. For example, it you want to convert special characters to HTML entities, you use the function htmlentities (Words glued together). If you want to do the opposite, you use its little brother function html_entity_decode. For some reason the words are now separated by underscores. Why is this bad? You know there is a function named striptags. Or was it strip_tags or stripTags?
Every time you have to look up what the notation is or wait for an error to occur and then open the php manual and search the function’s name.
6) Seldom use of Framework - A website without a framework which grows will eventually become a maintenance nightmare. A framework can make a lot of work easier. The most popular model for a framework is the MVC-model, in which layout, business logic and interaction with the database are separated.
Many PHP web sites don’t use the MVC-model. They don’t even use a framework. Although some PHP frameworks do exist (like Zend php framework, cakephp, Symfony). You can also write your own articles or manuals about PHP don’t say a word about frameworks. On the other
hand, JSP-developers use frameworks like Struts and ASP-developers use .Net, it looks like the concept of a framework is largely unknown by PHP developers.
Note : MVC stands for Model View Controller.
7) Slow - People thinks that Java is slow but it will be hard to know you that PHP is much slower! Look at this Computer Language Shootout. So how can PHP be used on all these popular websites with lots of visitors? It all because of caching. These sites use MCache and APC to get performance. It doesn’t proof anything about PHP, only that it’s cachable.
Based on the article above it is clearly stated that as true fan of programming language php really have a lot of rules and environment that a programming language has. Therefore for me as a programming language php sucks.
