Login   Register  
PHP Classes
elePHPant
Icontem

At some point it will matter

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PHP Classes blog  >  Will it ever Matter i...  >  All threads  >  At some point it will matter  >  (Un) Subscribe thread alerts  
Subject:At some point it will matter
Summary:PHP is good in a way, but it's not eternal
Messages:3
Author:Patkos Csaba
Date:2012-05-07 22:44:39
Update:2012-05-09 09:31:59
 

  1. At some point it will matter   Reply   Report abuse  
Picture of Patkos Csaba
Patkos Csaba
2012-05-07 23:35:07
At work, I am working on a project mostly written in PHP. It has a few hundred thousands of lines of code. And I can say that PHP sucks. But... it also does it's job.

I personally think that PHP is so popular, and it will be for the next few years, because it is very easy to use it for simple sites, small interactive webapps and it is also easy to learn.

But... when you start to use it in a more complicated way, for far more complex stuff than simple webapps, you realize that it is a severely limited language. Have you ever seen a UNIX daemon written in PHP? I bet you didn't. Not because it's impossible or hard to write one, but because anything running more than a few minutes and written in PHP starts to seriously leak memory. PHP is for top-dow quickly executed code.

I could go on with other examples, but my point is not to trash PHP. My point is, that when you have a large project which is more than just a webapp, you may be better off to find a language that's working properly both on the system side and the web side. Ruby&Rails does this pretty well, Java also tries to keep up, Perl kind of falls behind because of the stupid syntax and the lack of proper IDEs.

As for the syntax of the PHP code, 5.4 finally provided some things that were long awaited, but still, if you compare the aspect of a PHP code with other modern languages... well, it sucks. If you are trying to truly use OOP with PHP, other languages do it much better. Even the official documentation of PHP says that it's not a proper OOP language.

PS: I do not want to start any kind of flame here. So please take this post properly.

  2. Re: At some point it will matter   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2012-05-08 00:13:08 - In reply to message 1 from Patkos Csaba
There is a misunderstanding regarding memory usage.

PHP allocates the memory as needed. However, if PHP freed the memory to the OS, the memory is not released until the process ends. That is the usual behavior in Unix/Linux and Windows.

There is no problem using PHP as a daemon. The PHPClasses site runs many daemons in the background all written in PHP. Things like newsletter deliveries run for hours/days as a daemon using PHP scripts.

Anyway, there are differences in memory management between PHP as Web server module then from the command line (CLI).

For efficiency reasons, PHP as Web server module allocates much larger memory blocks at once when more memory is needed. This may lead to more memory waste but makes PHP run faster due to less memory reallocation calls.

As when it runs as CLI, PHP allocates smaller memory blocks that lead to less memory waste in the long run.

Other than that, if you feel there are other important aspects that PHP sucks, you always have the chance to propose solutions and contribute code to implement them. If you do not do that, there is not much moral to complain that PHP sucks.

  3. Re: At some point it will matter   Reply   Report abuse  
Picture of Federico Franco Jaramillo
Federico Franco Jaramillo
2012-05-09 09:31:59 - In reply to message 1 from Patkos Csaba
I think that there's no point in saying that PHP sucks because it is not an OOP language or because it doesn't behave well if the program runs more than a few minutes.

PHP was not thought as an OOP language and doesn't pretends to be, it implements it to the point that works for most of us. PHP was not designed to make daemons or applications that run for hours.

The problem is not in the design of PHP but in the design of the application, if you need pure OOP or you are building a system that is more complex than a web app ¿what you do using PHP? You chose the wrong programmung language.