Hi all,
I know this has been discussed before, but I'll try again.
We have following coding standard
-
Function names for user-level functions should be enclosed with in
the PHP_FUNCTION() macro. They should be in lowercase, with words
underscore delimited, with care taken to minimize the letter count.
Abbreviations should not be used when they greatly decrease the
readability of the function name itself::Good:
'mcrypt_enc_self_test'
'mysql_list_fields'Ok:
'mcrypt_module_get_algo_supported_key_sizes'
(could be 'mcrypt_mod_get_algo_sup_key_sizes'?)
'get_html_translation_table'
(could be 'html_get_trans_table'?)Bad:
'hw_GetObjectByQueryCollObj'
'pg_setclientencoding'
'jf_n_s_i'
https://github.com/php/php-src/blob/master/CODING_STANDARDS
There are many functions that violate this for historical reason.
Since PHP has function alias feature by default, function names that
violate this standard could be renamed and keep historic names as aliases.
We may keep alias 10 or 20 years or even forever.
Good IDE can suggest correct names, but keeping inconsistent historic
function names forever damages PHP future in the long run, IMHO.
Any comments?
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
There are many functions that violate this for historical reason.
Since PHP has function alias feature by default, function names that
violate this standard could be renamed and keep historic names as aliases.
There was a fork at some point (few months (years?) ago) that tried
something like that.. Noone cared.
I have a local alias list='ls' cause I never remember that command to
list the contents of a directory.
I tried to fix it upstream, but ...
-Hannes
There are many functions that violate this for historical reason.
Since PHP has function alias feature by default, function names that
violate this standard could be renamed and keep historic names as aliases.There was a fork at some point (few months (years?) ago) that tried
something like that.. Noone cared.I have a local alias list='ls' cause I never remember that command to
list the contents of a directory.
I tried to fix it upstream, but ...-Hannes
When redesigning for PHP6, shouldn't most functions move to a class or
namespace in the first place?
But even if you restrict it to better names, it's a step forward I
appreciate.
--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
When redesigning for PHP6, shouldn't most functions move to a class or
namespace in the first place?
You make it sound like such a redesign is an obvious and achievable goal
for the next "major" release of PHP. Neither PHP 5 nor the abandoned PHP
6 branch (Unicode strings, plus the features which were released as 5.3
and 5.4 instead) attempted anything so radical, and the more you change,
the harder it is to persuade people to migrate.
I suspect this has been discussed a lot of times, although I've only
joined the list recently. A search through the archives before taking
this discussion further would probably avoid repeating arguments that
have been had before, unless anyone has a good summary somewhere?
Not that I'm against moving towards consistency per se, but I wouldn't
want to assume that whatever stopped it gaining traction in the past no
longer applies.
Regards,
--
Rowan Collins
[IMSoP]
When redesigning for PHP6, shouldn't most functions move to a class or
namespace in the first place?You make it sound like such a redesign is an obvious and achievable goal
for the next "major" release of PHP. Neither PHP 5 nor the abandoned PHP
6 branch (Unicode strings, plus the features which were released as 5.3
and 5.4 instead) attempted anything so radical, and the more you change,
the harder it is to persuade people to migrate.I suspect this has been discussed a lot of times, although I've only
joined the list recently. A search through the archives before taking
this discussion further would probably avoid repeating arguments that
have been had before, unless anyone has a good summary somewhere?Not that I'm against moving towards consistency per se, but I wouldn't
want to assume that whatever stopped it gaining traction in the past no
longer applies.
You also need to realize that there is consistency. It is just
consistency from a different angle. PHP from day one was always a very
thin wrapper on top of dozens, now hundreds, of underlying libraries.
The function names and argument order, for the most part, were taken
directly from these underlying libraries. So if you were familiar with
MySQL's C API, for example, you would instantly be able to navigate
PHP's mysql functions to the point where we barely needed PHP MySQL
documentation because MySQL's C library documentation covered it
function for function. And for many of the str functions (the ones
without an underscore), try typing: man
strlen/strchr/strrchr/strtok/strpbr/strspn... at your Linux command line
prompt.
This approach covers the majority of the functions in PHP. The others
are somewhat haphazard because it was not always obvious how to name
these given there was no underlying API to mimic.
So, whenever I see these, "let's just rename everything" posts, I never
see the fact that most of these functions are deeply ingrained in the
muscle memories of a lot of people addressed. And it is in our muscle
memories, not because of PHP, but because we still live in a world
written in C. As soon as you venture outside the world of PHP and
scripting languages, you hit this world.
That doesn't mean we can't try to address this, but simply renaming
everything is not the answer.
-Rasmus
When redesigning for PHP6, shouldn't most functions move to a class or
namespace in the first place?
You make it sound like such a redesign is an obvious and achievable goal
for the next "major" release of PHP. Neither PHP 5 nor the abandoned PHP
6 branch (Unicode strings, plus the features which were released as 5.3
and 5.4 instead) attempted anything so radical, and the more you change,
the harder it is to persuade people to migrate.I suspect this has been discussed a lot of times, although I've only
joined the list recently. A search through the archives before taking
this discussion further would probably avoid repeating arguments that
have been had before, unless anyone has a good summary somewhere?Not that I'm against moving towards consistency per se, but I wouldn't
want to assume that whatever stopped it gaining traction in the past no
longer applies.
You also need to realize that there is consistency. It is just
consistency from a different angle. PHP from day one was always a very
thin wrapper on top of dozens, now hundreds, of underlying libraries.
The function names and argument order, for the most part, were taken
directly from these underlying libraries. So if you were familiar with
MySQL's C API, for example, you would instantly be able to navigate
PHP's mysql functions to the point where we barely needed PHP MySQL
documentation because MySQL's C library documentation covered it
function for function. And for many of the str functions (the ones
without an underscore), try typing: man
strlen/strchr/strrchr/strtok/strpbr/strspn... at your Linux command line
prompt.This approach covers the majority of the functions in PHP. The others
are somewhat haphazard because it was not always obvious how to name
these given there was no underlying API to mimic.So, whenever I see these, "let's just rename everything" posts, I never
see the fact that most of these functions are deeply ingrained in the
muscle memories of a lot of people addressed. And it is in our muscle
memories, not because of PHP, but because we still live in a world
written in C. As soon as you venture outside the world of PHP and
scripting languages, you hit this world.That doesn't mean we can't try to address this, but simply renaming
everything is not the answer.-Rasmus
Rasmus, I know you've made this point many times and it is valid
historically, but I am not convinced it's valid in the day to day
practice of most PHP developers. Only a tiny fraction of the PHP
developers I know have any knowledge of C, POSIX, etc., and I think all
of them are on this list (or were until recently). While it's great
that, for example, ext/mysql is virtually identical to The MySQL C APIs,
that is really no consolation for someone who has never looked at (nor
needed to, nor had any desire to) the MySQL C bindings.
I'm pretty sure most PHP developers' second language isn't C; odds are
it's Javascript, and after that either Python or Ruby. (I have no firm
data to back that up; it's just my gut feeling based on the developers I
interact with across the community.)
I agree that "rename all the things" doesn't help, for BC reasons if
nothing else; even with huge language improvements in a major version,
it still needs to be possible to run well-behaved code across several
contiguous versions or adoption will be nil. That means strlen()
,
strrchr()
, etc. are not going anywhere.
What I'd suggest instead, and I am not the first to suggest, is to leave
the existing functions in place; let them be happy. Then in
PHP.nextMajor (whatever that is), add new well-developed, thought-out,
probably OOP, namespaced routines for strings, arrays/collections, etc.
Those should be based on trends, standards, and conventions that are not
older than half the people on this list.
Replacing \strlen() with \string_length() has no real value, I agree.
However, (as an example) offering
$string->length()
"some string"->length()
$iterable_including_arrays->map(function($a){})->filter(function($a) {});
now that's worth doing, and worth making big changes for. But that
can/should be done without touching any of the existing functions,
because we don't want to break BC there for userspace code. If one
method happens to internally sub-call to the other in the engine, meh, I
don't care and neither does anyone else in userspace.
--Larry Garfield
When redesigning for PHP6, shouldn't most functions move to a class
or
namespace in the first place?
You make it sound like such a redesign is an obvious and achievable
goal
for the next "major" release of PHP. Neither PHP 5 nor the abandoned
PHP
6 branch (Unicode strings, plus the features which were released as
5.3
and 5.4 instead) attempted anything so radical, and the more you
change,
the harder it is to persuade people to migrate.I suspect this has been discussed a lot of times, although I've only
joined the list recently. A search through the archives before taking
this discussion further would probably avoid repeating arguments that
have been had before, unless anyone has a good summary somewhere?Not that I'm against moving towards consistency per se, but I
wouldn't
want to assume that whatever stopped it gaining traction in the past
no
longer applies.
You also need to realize that there is consistency. It is just
consistency from a different angle. PHP from day one was always a very
thin wrapper on top of dozens, now hundreds, of underlying libraries.
The function names and argument order, for the most part, were taken
directly from these underlying libraries. So if you were familiar with
MySQL's C API, for example, you would instantly be able to navigate
PHP's mysql functions to the point where we barely needed PHP MySQL
documentation because MySQL's C library documentation covered it
function for function. And for many of the str functions (the ones
without an underscore), try typing: man
strlen/strchr/strrchr/strtok/strpbr/strspn... at your Linux command
line
prompt.This approach covers the majority of the functions in PHP. The others
are somewhat haphazard because it was not always obvious how to name
these given there was no underlying API to mimic.So, whenever I see these, "let's just rename everything" posts, I
never
see the fact that most of these functions are deeply ingrained in the
muscle memories of a lot of people addressed. And it is in our muscle
memories, not because of PHP, but because we still live in a world
written in C. As soon as you venture outside the world of PHP and
scripting languages, you hit this world.That doesn't mean we can't try to address this, but simply renaming
everything is not the answer.-Rasmus
Rasmus, I know you've made this point many times and it is valid
historically, but I am not convinced it's valid in the day to day
practice of most PHP developers. Only a tiny fraction of the PHP
developers I know have any knowledge of C, POSIX, etc., and I think
all of them are on this list (or were until recently). While it's
great that, for example, ext/mysql is virtually identical to The MySQL
C APIs, that is really no consolation for someone who has never looked
at (nor needed to, nor had any desire to) the MySQL C bindings.I'm pretty sure most PHP developers' second language isn't C; odds are
it's Javascript, and after that either Python or Ruby. (I have no
firm data to back that up; it's just my gut feeling based on the
developers I interact with across the community.)I agree that "rename all the things" doesn't help, for BC reasons if
nothing else; even with huge language improvements in a major version,
it still needs to be possible to run well-behaved code across several
contiguous versions or adoption will be nil. That meansstrlen()
,
strrchr()
, etc. are not going anywhere.What I'd suggest instead, and I am not the first to suggest, is to
leave the existing functions in place; let them be happy. Then in
PHP.nextMajor (whatever that is), add new well-developed, thought-out,
probably OOP, namespaced routines for strings, arrays/collections,
etc. Those should be based on trends, standards, and conventions that
are not older than half the people on this list.Replacing \strlen() with \string_length() has no real value, I agree.
However, (as an example) offering$string->length()
"some string"->length()
$iterable_including_arrays->map(function($a){})->filter(function($a)
{});now that's worth doing, and worth making big changes for. But that
can/should be done without touching any of the existing functions,
because we don't want to break BC there for userspace code. If one
method happens to internally sub-call to the other in the engine, meh,
I don't care and neither does anyone else in userspace.--Larry Garfield
I would consider myself one of those php developers. I know very little
c, and java. Javascript is my second language after php. Most php
developers have yet to move towards 5.3 and don't know how to even use
namespaces or what they are. They often use wordpress or drupal which
are very slow to adapt.
Considering how slow and hard it is for most php developers to migrate
to new versions of php I do not think creating aliases or changing the
names would be beneficial. Different developers would use different
aliases and it would confuse a lot of php developers.
IMO the best solution is to have more SPL objects in php 6. People can
either use the old functional php or the new OO php and the OO would
have more consistent names.
--Robert Parker
I've done PHP, C, Javascript, and C# for 15 years now. I greatly prefer
PHP. Putting types, classes and functions behind a namespace seems the
most usable. Usually documentation is easier to understand since the
related information is always behind a namespace. Also using Pierre's
"init_set('PHP5_FUNC_COMPAT',
true);" to define the current functions (although the default should be
true) would allow older code to work without changes. Moving to namespaces
would allow better consistent naming. Although this point can be moot
because of IDEs, however it does force a developer to know what classes and
functions are going to be running in their application.
Moving strictly to an OO language would remove some of the easy for
beginners to start and easy to prototype features of the language.
Timothy Rhodes
When redesigning for PHP6, shouldn't most functions move to a class or
namespace in the first place?You make it sound like such a redesign is an obvious and achievable goal
for the next "major" release of PHP. Neither PHP 5 nor the abandoned PHP
6 branch (Unicode strings, plus the features which were released as 5.3
and 5.4 instead) attempted anything so radical, and the more you change,
the harder it is to persuade people to migrate.I suspect this has been discussed a lot of times, although I've only
joined the list recently. A search through the archives before taking
this discussion further would probably avoid repeating arguments that
have been had before, unless anyone has a good summary somewhere?Not that I'm against moving towards consistency per se, but I wouldn't
want to assume that whatever stopped it gaining traction in the past no
longer applies.You also need to realize that there is consistency. It is just
consistency from a different angle. PHP from day one was always a very
thin wrapper on top of dozens, now hundreds, of underlying libraries.
The function names and argument order, for the most part, were taken
directly from these underlying libraries. So if you were familiar with
MySQL's C API, for example, you would instantly be able to navigate
PHP's mysql functions to the point where we barely needed PHP MySQL
documentation because MySQL's C library documentation covered it
function for function. And for many of the str functions (the ones
without an underscore), try typing: man
strlen/strchr/strrchr/strtok/strpbr/strspn... at your Linux command line
prompt.This approach covers the majority of the functions in PHP. The others
are somewhat haphazard because it was not always obvious how to name
these given there was no underlying API to mimic.So, whenever I see these, "let's just rename everything" posts, I never
see the fact that most of these functions are deeply ingrained in the
muscle memories of a lot of people addressed. And it is in our muscle
memories, not because of PHP, but because we still live in a world
written in C. As soon as you venture outside the world of PHP and
scripting languages, you hit this world.That doesn't mean we can't try to address this, but simply renaming
everything is not the answer.-Rasmus
Rasmus, I know you've made this point many times and it is valid
historically, but I am not convinced it's valid in the day to day
practice of most PHP developers. Only a tiny fraction of the PHP
developers I know have any knowledge of C, POSIX, etc., and I think
all of them are on this list (or were until recently). While it's
great that, for example, ext/mysql is virtually identical to The MySQL
C APIs, that is really no consolation for someone who has never looked
at (nor needed to, nor had any desire to) the MySQL C bindings.I'm pretty sure most PHP developers' second language isn't C; odds are
it's Javascript, and after that either Python or Ruby. (I have no
firm data to back that up; it's just my gut feeling based on the
developers I interact with across the community.)I agree that "rename all the things" doesn't help, for BC reasons if
nothing else; even with huge language improvements in a major version,
it still needs to be possible to run well-behaved code across several
contiguous versions or adoption will be nil. That meansstrlen()
,
strrchr()
, etc. are not going anywhere.What I'd suggest instead, and I am not the first to suggest, is to
leave the existing functions in place; let them be happy. Then in
PHP.nextMajor (whatever that is), add new well-developed, thought-out,
probably OOP, namespaced routines for strings, arrays/collections,
etc. Those should be based on trends, standards, and conventions that
are not older than half the people on this list.Replacing \strlen() with \string_length() has no real value, I agree.
However, (as an example) offering$string->length()
"some string"->length()
$iterable_including_arrays->map(function($a){})->filter(function($a) {});now that's worth doing, and worth making big changes for. But that
can/should be done without touching any of the existing functions,
because we don't want to break BC there for userspace code. If one
method happens to internally sub-call to the other in the engine, meh,
I don't care and neither does anyone else in userspace.--Larry Garfield
I would consider myself one of those php developers. I know very little c,
and java. Javascript is my second language after php. Most php developers
have yet to move towards 5.3 and don't know how to even use namespaces or
what they are. They often use wordpress or drupal which are very slow to
adapt.Considering how slow and hard it is for most php developers to migrate to
new versions of php I do not think creating aliases or changing the names
would be beneficial. Different developers would use different aliases and
it would confuse a lot of php developers.IMO the best solution is to have more SPL objects in php 6. People can
either use the old functional php or the new OO php and the OO would have
more consistent names.--Robert Parker
I've done PHP, C, Javascript, and C# for 15 years now. I greatly prefer
PHP. Putting types, classes and functions behind a namespace seems the
most usable. Usually documentation is easier to understand since the
related information is always behind a namespace. Also using Pierre's
"init_set('PHP5_FUNC_COMPAT',
true);" to define the current functions (although the default should be
true) would allow older code to work without changes. Moving to
namespaces
would allow better consistent naming. Although this point can be moot
because of IDEs, however it does force a developer to know what classes
and
functions are going to be running in their application.Moving strictly to an OO language would remove some of the easy for
beginners to start and easy to prototype features of the language.Timothy Rhodes
On Thu, Jan 2, 2014 at 11:49 AM, Robert Parker rparker@yamiko.org
wrote:When redesigning for PHP6, shouldn't most functions move to a
class or
namespace in the first place?You make it sound like such a redesign is an obvious and achievable
goal
for the next "major" release of PHP. Neither PHP 5 nor the
abandoned PHP
6 branch (Unicode strings, plus the features which were released as
5.3
and 5.4 instead) attempted anything so radical, and the more you
change,
the harder it is to persuade people to migrate.I suspect this has been discussed a lot of times, although I've
only
joined the list recently. A search through the archives before
taking
this discussion further would probably avoid repeating arguments
that
have been had before, unless anyone has a good summary somewhere?Not that I'm against moving towards consistency per se, but I
wouldn't
want to assume that whatever stopped it gaining traction in the
past no
longer applies.You also need to realize that there is consistency. It is just
consistency from a different angle. PHP from day one was always a
very
thin wrapper on top of dozens, now hundreds, of underlying
libraries.
The function names and argument order, for the most part, were taken
directly from these underlying libraries. So if you were familiar
with
MySQL's C API, for example, you would instantly be able to navigate
PHP's mysql functions to the point where we barely needed PHP MySQL
documentation because MySQL's C library documentation covered it
function for function. And for many of the str functions (the ones
without an underscore), try typing: man
strlen/strchr/strrchr/strtok/strpbr/strspn... at your Linux command
line
prompt.This approach covers the majority of the functions in PHP. The
others
are somewhat haphazard because it was not always obvious how to name
these given there was no underlying API to mimic.So, whenever I see these, "let's just rename everything" posts, I
never
see the fact that most of these functions are deeply ingrained in
the
muscle memories of a lot of people addressed. And it is in our
muscle
memories, not because of PHP, but because we still live in a world
written in C. As soon as you venture outside the world of PHP and
scripting languages, you hit this world.That doesn't mean we can't try to address this, but simply renaming
everything is not the answer.-Rasmus
Rasmus, I know you've made this point many times and it is valid
historically, but I am not convinced it's valid in the day to day
practice of most PHP developers. Only a tiny fraction of the PHP
developers I know have any knowledge of C, POSIX, etc., and I think
all of them are on this list (or were until recently). While it's
great that, for example, ext/mysql is virtually identical to The
MySQL
C APIs, that is really no consolation for someone who has never
looked
at (nor needed to, nor had any desire to) the MySQL C bindings.I'm pretty sure most PHP developers' second language isn't C; odds
are
it's Javascript, and after that either Python or Ruby. (I have no
firm data to back that up; it's just my gut feeling based on the
developers I interact with across the community.)I agree that "rename all the things" doesn't help, for BC reasons if
nothing else; even with huge language improvements in a major
version,
it still needs to be possible to run well-behaved code across several
contiguous versions or adoption will be nil. That meansstrlen()
,
strrchr()
, etc. are not going anywhere.What I'd suggest instead, and I am not the first to suggest, is to
leave the existing functions in place; let them be happy. Then in
PHP.nextMajor (whatever that is), add new well-developed,
thought-out,
probably OOP, namespaced routines for strings, arrays/collections,
etc. Those should be based on trends, standards, and conventions
that
are not older than half the people on this list.Replacing \strlen() with \string_length() has no real value, I agree.
However, (as an example) offering$string->length()
"some string"->length()
$iterable_including_arrays->map(function($a){})->filter(function($a)
{});now that's worth doing, and worth making big changes for. But that
can/should be done without touching any of the existing functions,
because we don't want to break BC there for userspace code. If one
method happens to internally sub-call to the other in the engine,
meh,
I don't care and neither does anyone else in userspace.--Larry Garfield
I would consider myself one of those php developers. I know very
little c,
and java. Javascript is my second language after php. Most php
developers
have yet to move towards 5.3 and don't know how to even use namespaces
or
what they are. They often use wordpress or drupal which are very slow
to
adapt.Considering how slow and hard it is for most php developers to migrate
to
new versions of php I do not think creating aliases or changing the
names
would be beneficial. Different developers would use different aliases
and
it would confuse a lot of php developers.IMO the best solution is to have more SPL objects in php 6. People can
either use the old functional php or the new OO php and the OO would
have
more consistent names.--Robert Parker
--
I was not implying an OO only language. I love how php is not strictly
OO. The point I was trying to get across is that most php developers
will not adapt until unless they absolutely have too. Changing functions
would be a huge deal to these people. using a tool is probably out of
the question for them unless it was a gui based tool. Allowing different
names would be confusing to them also. IDEs wouln't help IMO because
they don't use them.
I have been using PHP for about 5 years and just started my career as a
web developer. TBH I have only once meet someone who uses version
control and knows what namespaces are. only a few people used an IDE or
knew what an IDE was. I know there's a lot of great php developers out
there but I do not think the make up the majority. Maybe it's
demographics. I live in OR USA.
I think we should leave the functions as they are and include more SPL
objects. The SPL would be more consistent for the people who do OOP.
I've done PHP, C, Javascript, and C# for 15 years now. I greatly prefer
PHP. Putting types, classes and functions behind a namespace seems the
most usable. Usually documentation is easier to understand since the
related information is always behind a namespace. Also using Pierre's
"init_set('PHP5_FUNC_COMPAT',
true);" to define the current functions (although the default should be
true) would allow older code to work without changes. Moving to namespaces
would allow better consistent naming. Although this point can be moot
because of IDEs, however it does force a developer to know what classes
and
functions are going to be running in their application.Moving strictly to an OO language would remove some of the easy for
beginners to start and easy to prototype features of the language.Timothy Rhodes
When redesigning for PHP6, shouldn't most functions move to a class
or
namespace in the first place?You make it sound like such a redesign is an obvious and achievable
goal
for the next "major" release of PHP. Neither PHP 5 nor the abandoned
PHP
6 branch (Unicode strings, plus the features which were released as
5.3
and 5.4 instead) attempted anything so radical, and the more you
change,
the harder it is to persuade people to migrate.I suspect this has been discussed a lot of times, although I've only
joined the list recently. A search through the archives before taking
this discussion further would probably avoid repeating arguments that
have been had before, unless anyone has a good summary somewhere?Not that I'm against moving towards consistency per se, but I wouldn't
want to assume that whatever stopped it gaining traction in the past
no
longer applies.You also need to realize that there is consistency. It is just
consistency from a different angle. PHP from day one was always a very
thin wrapper on top of dozens, now hundreds, of underlying libraries.
The function names and argument order, for the most part, were taken
directly from these underlying libraries. So if you were familiar with
MySQL's C API, for example, you would instantly be able to navigate
PHP's mysql functions to the point where we barely needed PHP MySQL
documentation because MySQL's C library documentation covered it
function for function. And for many of the str functions (the ones
without an underscore), try typing: man
strlen/strchr/strrchr/strtok/strpbr/strspn... at your Linux command
line
prompt.This approach covers the majority of the functions in PHP. The others
are somewhat haphazard because it was not always obvious how to name
these given there was no underlying API to mimic.So, whenever I see these, "let's just rename everything" posts, I never
see the fact that most of these functions are deeply ingrained in the
muscle memories of a lot of people addressed. And it is in our muscle
memories, not because of PHP, but because we still live in a world
written in C. As soon as you venture outside the world of PHP and
scripting languages, you hit this world.That doesn't mean we can't try to address this, but simply renaming
everything is not the answer.-Rasmus
Rasmus, I know you've made this point many times and it is valid
historically, but I am not convinced it's valid in the day to day
practice of most PHP developers. Only a tiny fraction of the PHP
developers I know have any knowledge of C, POSIX, etc., and I think
all of them are on this list (or were until recently). While it's
great that, for example, ext/mysql is virtually identical to The MySQL
C APIs, that is really no consolation for someone who has never looked
at (nor needed to, nor had any desire to) the MySQL C bindings.I'm pretty sure most PHP developers' second language isn't C; odds are
it's Javascript, and after that either Python or Ruby. (I have no
firm data to back that up; it's just my gut feeling based on the
developers I interact with across the community.)I agree that "rename all the things" doesn't help, for BC reasons if
nothing else; even with huge language improvements in a major version,
it still needs to be possible to run well-behaved code across several
contiguous versions or adoption will be nil. That meansstrlen()
,
strrchr()
, etc. are not going anywhere.What I'd suggest instead, and I am not the first to suggest, is to
leave the existing functions in place; let them be happy. Then in
PHP.nextMajor (whatever that is), add new well-developed, thought-out,
probably OOP, namespaced routines for strings, arrays/collections,
etc. Those should be based on trends, standards, and conventions that
are not older than half the people on this list.Replacing \strlen() with \string_length() has no real value, I agree.
However, (as an example) offering$string->length()
"some string"->length()
$iterable_including_arrays->map(function($a){})->filter(function($a)
{});now that's worth doing, and worth making big changes for. But that
can/should be done without touching any of the existing functions,
because we don't want to break BC there for userspace code. If one
method happens to internally sub-call to the other in the engine, meh,
I don't care and neither does anyone else in userspace.--Larry Garfield
I would consider myself one of those php developers. I know very little
c,
and java. Javascript is my second language after php. Most php developers
have yet to move towards 5.3 and don't know how to even use namespaces or
what they are. They often use wordpress or drupal which are very slow to
adapt.Considering how slow and hard it is for most php developers to migrate to
new versions of php I do not think creating aliases or changing the names
would be beneficial. Different developers would use different aliases and
it would confuse a lot of php developers.IMO the best solution is to have more SPL objects in php 6. People can
either use the old functional php or the new OO php and the OO would have
more consistent names.--Robert Parker
--
I was not implying an OO only language. I love how php is not strictly OO.
The point I was trying to get across is that most php developers will not
adapt until unless they absolutely have too. Changing functions would be a
huge deal to these people. using a tool is probably out of the question for
them unless it was a gui based tool. Allowing different names would be
confusing to them also. IDEs wouln't help IMO because they don't use them.I have been using PHP for about 5 years and just started my career as a web
developer. TBH I have only once meet someone who uses version control and
knows what namespaces are. only a few people used an IDE or knew what an IDE
was. I know there's a lot of great php developers out there but I do not
think the make up the majority. Maybe it's demographics. I live in OR USA.I think we should leave the functions as they are and include more SPL
objects. The SPL would be more consistent for the people who do OOP.--
(This not PHP specific nor it's targeted any specific person or group)
So, the argument of having a bad language is that if the people who
use it are bad then it should stay bad forever? Shouldn't a language
strive to be better and better, promote good practices and enhance the
way people program not just write code?
And if it's that hard to run "php -5to6 /path/to/file.php" then I
guess one needs to wonder if he's really in the right business. Yes,
you may have a tool that is using some fancy interface, but CLI itself
is also a GUI on it's own.
Maybe making the whole thing consistent is coming a bit too late now
in the game, at least for old stuff and considering the spread of PHP
there's going to be lots of people frustrated about changes. Something
like this shouldn't be treated lightly nor should it be done without a
form of automated migration (again, engine support is not that
solution). But on the other hand, sticking to a solution because it's
yours or because you got accustomed to it it's not something a
programmer should do either.
As for PHP6 to come to life and be adopted, besides a single 'oh look,
PHP6 is here with all the functions renamed / parameter shifted
around' it has to come with more then that, HHVM integration is a good
start, seeing how it's holding pretty well in benchmarks and finally
it's being considered as something that might be looked into in the
future, something that a year ago was a: 'oh no, no'.
Regards,
Florin
Florin Patan / @dlsniper
https://github.com/dlsniper
http://www.linkedin.com/in/florinpatan
As for PHP6 to come to life and be adopted, besides a single 'oh look,
PHP6 is here with all the functions renamed / parameter shifted
around' it has to come with more then that, HHVM integration is a good
start, seeing how it's holding pretty well in benchmarks and finally
it's being considered as something that might be looked into in the
future, something that a year ago was a: 'oh no, no'.
Because it was a completely different thing then which FB also realized
and completely changed gears to be more in line with PHP. Now that they
have done that it is much more interesting to us. If they hadn't, it
would still be an 'oh no, no' as you so eloquently and mockingly put it.
-Rasmus
HI all,
I would consider myself one of those php developers. I know very little c,
and java. Javascript is my second language after php. Most php developers
have yet to move towards 5.3 and don't know how to even use namespaces or
what they are. They often use wordpress or drupal which are very slow to
adapt.Considering how slow and hard it is for most php developers to migrate to
new versions of php I do not think creating aliases or changing the names
would be beneficial. Different developers would use different aliases and
it would confuse a lot of php developers.
This proposal does not intend to force users to adopt new names, but ensure
PHP popularity in the long run.
Are new users willing to learn language that have full of inconsistent
names
even for basic/standard/default functions?
My intention to have consistent function names for old function is
- to ensure PHP as attractive language to learn even 10 or 20 years later.
I agree that adoption of new feature is slow. If we made function names
consistent now, there would be codes around uses historic names 10 years
later, but it does not matter for the purpose of this proposal.
De facto Standard names such as strchr()
would be acceptable names even
20 years from now. Other functions such as GD functions are better to have
consistent names.
Please consider this proposal is for new users that will learn PHP from now
or
in the future.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
HI all,
I would consider myself one of those php developers. I know very little c,
and java. Javascript is my second language after php. Most php developers
have yet to move towards 5.3 and don't know how to even use namespaces or
what they are. They often use wordpress or drupal which are very slow to
adapt.Considering how slow and hard it is for most php developers to migrate to
new versions of php I do not think creating aliases or changing the names
would be beneficial. Different developers would use different aliases and
it would confuse a lot of php developers.This proposal does not intend to force users to adopt new names, but ensure
PHP popularity in the long run.Are new users willing to learn language that have full of inconsistent
names
even for basic/standard/default functions?My intention to have consistent function names for old function is
- to ensure PHP as attractive language to learn even 10 or 20 years later.
I agree that adoption of new feature is slow. If we made function names
consistent now, there would be codes around uses historic names 10 years
later, but it does not matter for the purpose of this proposal.De facto Standard names such as
strchr()
would be acceptable names even
20 years from now. Other functions such as GD functions are better to have
consistent names.Please consider this proposal is for new users that will learn PHP from now
or
in the future.Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
If you look at golang you'll see they have 'go fix'
http://golang.org/cmd/fix/ which helps mitigate the effects of
language changes automatically.
I suppose it wouldn't be a problem with having a tool that can
generate an AST out of a .php file and dump it back to a newer syntax
(as long as only the function / method / classes name and parameter
order is changing).
The issue I see is that people are stuck into the: 'bbbut it's using
the underlying uber-duper library and if a dozen people know about it
then it must be a good thing' approach.
Also, having a flag in the engine, with some ini_set(blah, true) seems
like a poor decision imo. Fix the problem at the source, don't clutter
the engine because the php users are too lazy to run an automated
tool.
And yes, I do suggest that PHP should start to impose a certain
formatting, since it would be needed by this tool, but if you look
past the initial: ':(((( I want my tabs / spaces back' or whatever, in
a couple of days / weeks everyone would forget about the formatting
issues and just focus on the code.
@Yasuo, if you really want to keep PHP attractive maybe you should
look on what golang is doing because imo they served every other
languages a lesson in tooling and not only.
Florin Patan / @dlsniper
https://github.com/dlsniper
http://www.linkedin.com/in/florinpatan
Hi Florin,
@Yasuo, if you really want to keep PHP attractive maybe you should
look on what golang is doing because imo they served every other
languages a lesson in tooling and not only.
Thanks.
I'm not familiar with Go yet, but I have an idea for DbC (design by
contract) for PHP.
Anyway, I'll learn it soon :)
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi Florin,
@Yasuo, if you really want to keep PHP attractive maybe you should
look on what golang is doing because imo they served every other
languages a lesson in tooling and not only.Thanks.
I'm not familiar with Go yet, but I have an idea for DbC (design by
contract) for PHP.
Anyway, I'll learn it soon :)--
Yasuo Ohgaki
yohgaki@ohgaki.net
Also Pythons' 2to3 might be interesting to check out:
http://docs.python.org/2/library/2to3.html
Cheers.
Florin Patan / @dlsniper
https://github.com/dlsniper
http://www.linkedin.com/in/florinpatan
I suppose it wouldn't be a problem with having a tool that can
generate an AST out of a .php file and dump it back to a newer syntax
(as long as only the function / method / classes name and parameter
order is changing).
Don't forget that there are various ways to do what could loosely be
described as "reflection" or "meta-programming" in PHP - e.g. given
call_user_func_array($func, $args) we may need to correct the name
stored in the string $func, or the order of items in the array $args.
These are very hard to even detect with an automated tool, let alone fix
- indeed, I doubt it is even theoretically possible in many cases. That
leaves you with either code that needs painstaking manual upgrades, or a
runtime compatibility mode.
Both of these come with a cost to the community at large - many people
want to distribute (or internally manage) code that is both backwards
and forwards compatible, i.e. runs on as many past and future versions
of the platform as possible. That's impossible to do with a hard
compatibility break, and tricky if the compatibility breaks are subtle
(such as new function names/aliases) as you have to keep testing and
removing the new names until you no longer need to support the old versions.
A more fundamental restructuring (e.g. an OO implementation of "basic"
operations) could more happily sit alongside the existing functionality,
with code very obviously using either one style or the other, and
compatibility easy to maintain over the longer term.
Regards,
--
Rowan Collins
[IMSoP]
Hi all,
I know this has been discussed before, but I'll try again.
We have following coding standard
- Function names for user-level functions should be enclosed with in
the PHP_FUNCTION() macro. They should be in lowercase, with words
underscore delimited, with care taken to minimize the letter count.
Abbreviations should not be used when they greatly decrease the
readability of the function name itself::
There are a couple of solutions to this problem.
-
Change all the existing functions signatures. Bad idea per se as we can
forget any fast adoption, if any at all. Will be very painful to migrate
existing code -
Add aliases all around.
Not a big fan of that one either. It clutters the php NS a lot without
factual gains -
Try to implement nickic's prototype to add methods to scalar related
types, should work with complex types as well
I would prefer to give 3. a try, while it could be tricky to implement a
technically acceptable solution.
Pros:
. It will bring consistent APIs
. does not add dozen of aliases for little gains
. fully BC
. fits more to current development habits
Cons:
. still have to be careful by designing the new "methods"
Cheers,
Pierre
Hi Folks,
I really like the idea from Larry Garfield or Pierre Joye's proposal (3).
We now do have some things cluttered, and it does not matter because
of what this is cluttered or if it's only the C world shining through.
Programmatically spoken, to me and many OO folks, these things are
inconsitently named and the strlen("somesting")... syntax is very
1980s to have.
Anyways, any change should not break existing code, but must strive
for new code being written to be more maintainable, readable and
OOP-like.
Either these functions must live in this space forever (and can get
proper aliases or mappings to OO-compliant syntax), or, if one tends
to disable them, we could have some switch in INI or in a script,
enabling all of them back again, like
init_set('PHP5_FUNC_COMPAT', true);
For old projects that depend on them, the main PHP include would then
include this flag and the functions would be made available.
Cheers,
Nils
2014/1/2 Pierre Joye pierre.php@gmail.com:
Hi all,
I know this has been discussed before, but I'll try again.
We have following coding standard
- Function names for user-level functions should be enclosed with in
the PHP_FUNCTION() macro. They should be in lowercase, with words
underscore delimited, with care taken to minimize the letter count.
Abbreviations should not be used when they greatly decrease the
readability of the function name itself::There are a couple of solutions to this problem.
Change all the existing functions signatures. Bad idea per se as we can
forget any fast adoption, if any at all. Will be very painful to migrate
existing codeAdd aliases all around.
Not a big fan of that one either. It clutters the php NS a lot without
factual gainsTry to implement nickic's prototype to add methods to scalar related
types, should work with complex types as wellI would prefer to give 3. a try, while it could be tricky to implement a
technically acceptable solution.Pros:
. It will bring consistent APIs
. does not add dozen of aliases for little gains
. fully BC
. fits more to current development habitsCons:
. still have to be careful by designing the new "methods"Cheers,
Pierre
I know this has been discussed before, but I'll try again.
We have following coding standard
Function names for user-level functions should be enclosed with in
the PHP_FUNCTION() macro. They should be in lowercase, with words
underscore delimited, with care taken to minimize the letter count.
Abbreviations should not be used when they greatly decrease the
readability of the function name itself::Good:
'mcrypt_enc_self_test'
'mysql_list_fields'Ok:
'mcrypt_module_get_algo_supported_key_sizes'
(could be 'mcrypt_mod_get_algo_sup_key_sizes'?)
'get_html_translation_table'
(could be 'html_get_trans_table'?)Bad:
'hw_GetObjectByQueryCollObj'
'pg_setclientencoding'
'jf_n_s_i'https://github.com/php/php-src/blob/master/CODING_STANDARDS
There are many functions that violate this for historical reason.
Since PHP has function alias feature by default, function names that
violate this standard could be renamed and keep historic names as aliases.We may keep alias 10 or 20 years or even forever.
Good IDE can suggest correct names, but keeping inconsistent historic
function names forever damages PHP future in the long run, IMHO.Any comments?
Added RFC for this.
https://wiki.php.net/rfc/consistent-names
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Added RFC for this.
You seem pretty eager to make RFCs ;)
You should probably announce it to the list directly as well.
--
Andrea Faulds
http://ajf.me/
Hi Andrea,
Added RFC for this.
You seem pretty eager to make RFCs ;)
You should probably announce it to the list directly as well.
I just don't want to forget about it :)
I made it as reminder. Since we are 5.6 release phase, it might
be better bring up this after 5.6 release.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net