PHP – a bad programming language – Dark side of PHP
I’m a web developer by profession and have been involved in PHP development for last three years. PHP is very easy to learn and program in. But what i think, PHP is a incomplete programming language as well as a bad programming language which gives bad practice for the programmers.I can point out why a most popular programming language used in Internet sucks and have a lots of dark side…
1) No need to define and declare variable – In most of the programming language, you have to declare the 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 ita 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 thnat 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.
Finally, Php is easy to learn and development cost is low compared to other technology but being a true fan of programming language what i feel is that it sucks as a programming language.
Popularity: 3% [?]