i had some knowledge with php and asp, but i was not an advanced one. recently i decide to learn php in more depth. because i like open source and i see a lot of fans trying to make it better than before.
and im reading a book for it.
first thing that bother my mind is function names.
i want to know why functions (not all of them though) have no meaningful names in them? why they select a chop() name for a function? it have no mean
another thing is naming abbreviations
for example if i want to work with files, i have: fread(), readfile(), fpassthru(), file() functions. some of them use “file” (like: readfile, file) and some of them use “f” as abbreviations (like: fread(), fpassthru()) .
and as you see none of them tells you what they do if you are not familiar with them.
also for reading from file i have: fgets(), fgetss(), fgetcsv(). again, name tells you nothing. for example if you see fgetss() for the first time, you cant say what is the difference between fgets() or fgetss().
another problem i see in functions is name convention. for example we have file_exist() and filesize(). why in some function there is an underline between names and in some of them there isn’t?
if i know some language like c or delphi, i expect when i use filesize(), there is a function name fileexist() not file_exist(), or vice versa.
also i noticed that php still haven’t got unicode support for function names and some others but asp had it a long time ago.
i know unicode support probably needs huge code to be implemented, so its not a big deal in my mind if php haven’t got it since.
but names of function is a simple thing to fix and it should be straightforward for those who are going to learn php.
as far as i know, asp have a better naming and almost all of them gives you some idea about what they do.
i was a fan of php and when we debate with my friend, i was in php side and against asp. but these things is something that i dont know why php developer wont fix.
the next thing that i couldnt figure out is new features, i looked in changelog of php 5.3, and i see its now support for closures and true anonymous functions, i know it has its use, but lets face it, doesnt something like this make our code much less readable?
i saw an example about it in wikipedia:
Code: Select all
function getAdder($x)
{
return function ($y) use ($x) {
return $x + $y;
};
}
$adder = getAdder(8);
echo $adder(2); // prints “10″ok about C, yes it is heavily on C syntax, but php should not have filesize because C have no filesize at all as far as i know, so if we want to be like C, we should have file_size(). because C use underline in such a functions. example is file_exist()
all i read in programing source in computer science, they say one parameter for a good language is a good naming convention.
and for a language like php (my be loved one
if you say we should support backward compatibility, i say at least make these bad names an old feature, so they will be fixed in next versions.
just like globals removed. or magic quotes that going to be removed.
another thing is parameter order, for example when you work with strings we have to function,
explode:
array explode ( string $delimiter , string $string [, int $limit ] )
and strtok:
string strtok ( string $str , string $delimiter )
so which one? delimetter before string or after.
i know these are not such a big thing, but i think they can fix it very easily
these things that i see are bothering me when i compare them with asp,
can someone please correct me if im wrong? i like php alot and i need to know the reason why these things still exist.
i hope i could make my mean clear.