PHP Classes

Inconsistency of functions

Recommend this page to a friend!

      PHP Classes blog  >  Top 10 Wrong Ideas Ab...  >  All threads  >  Inconsistency of functions  >  (Un) Subscribe thread alerts  
Subject:Inconsistency of functions
Summary:Other reasons for not liking PHP
Author:Emmanuel Seyman
Date:2011-08-21 23:57:08
Update:2011-08-22 01:23:41

  1. Inconsistency of functions   Reply   Report abuse  
Picture of Emmanuel Seyman Emmanuel Seyman - 2011-08-22 00:59:48
There are a few things about PHP that I don't like that aren't in the article. Here are the most important ones:

1) Number of functions gives me a list of 5439 functions. I'm sorry but this is way too many for me to remember. I have to have the documentation on hand every time I modify a php program and it slows me down to no end. Contrast this with 285 functions in Perl core.

2) Inconsistent function naming
This would be half as bad if there was some consistency in the naming of PHP functions. There isn't. Some functions use "2" while others use "to". Underscores are used any which way. System calls are used except when they aren't. Function names are sometimes <verb><object> (base64_decode, var_dump)and sometimes <object><verb> (create_function, recode_string).

3) Redundancy
Again, this might not be so much of a problem if there was one function for one activity. Unfortunately, this isn't the case. PHP has 16 functions for sorting, 10 for walking a list and 14 for printing/writing. This requires reading the documentation every time I use a function which slows my writing code to a crawl.

  2. Re: Inconsistency of functions   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2011-08-22 01:23:41 - In reply to message 1 from Emmanuel Seyman
The point of the article was not about things that may be wrong in PHP, but rather wrong ideas about PHP that some people have.

Anyway, regarding the number of functions, that is the reflex that PHP has many extensions. It could have less functions if it had less extensions, but then it would be less useful. Other than that, if you do not want to look-up the PHP documentation to get the correct function names and parameters, you can always use an IDE that provides function auto-complete support.

As for function inconsistency, that is the result that PHP is the result of contributions of hundreds of developers that use different conventions. Still, some inconsistencies are being fixed, like the function names that are getting alias with and without underscores.

As for apparent redundancy, that is also the result of contributions of different developers that prefer different approaches to do similar things. Different alternatives for same purpose address the preferences of different groups of users that like different styles. You just need to adopt one style that you like and forget the rest.