This just in, people still use the most popular programming language on the web, the size of which makes all other web programming languages niche choices by comparison.
Honestly, I don't understand what all the complaining is about. It just seems like a lot of language snobbery to me. I used PHP on my small website because every cheap web host out there supports it, there's tons of example code, and it's easy to learn if you have a C/C++ background. It seems to work just fine. Is it suitable for a gigantic website like Facebook? I have no idea really, and I don't care, just like I don't care that bash shell scripts probably aren't suitable for writing, for instance, a full-featured application like a spreadsheet or a video editor, as shell scripts work quite well for the things I do use them for.
Honestly, I don't understand what all the complaining is about. It just seems like a lot of language snobbery to me.
As someone who works with PHP every working day: It's a language that wasn't designed, it was congealed. Its lack of design is very evident as soon as you start trying to build anything interesting with it. It was something that was created to solve a short-term problem for one guy, and more-or-less accidentally grew into what it is today. What structures it does have are poor attempts at imitating other languages.
Some examples of what went wrong: - Arrays and hashes are the same data structure, for no readily apparent reason. Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c,...]" like everyone else. - All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not. - For a long time, OOP was an afterthought. - Unlike other scripting languages like Python, Ruby, and Perl, PHP can't figure out which files to include for you when you reference something outside of the current file. Instead, it offers a global facility called an "autoloader" that allows you to write your own code to tell it how to find it, which completely breaks when multiple libraries have competing autoloaders trying to pick up two different classes with the same name. - Library functions display no consistency whatsoever. Some are camelCase, some are under_scored. Some search functions put the needle before the haystack, some the other way around. - Some operators are funky: Values can be equal without being the same thing, for example. - A significant number of errors, instead of generating exceptions that can be caught and handled, generate fatal errors, which crash your application no matter what. By comparison, Perl, Python, Ruby, and Java allow you to handle almost any error.
I could go on, but the point is there's real reasons for hating PHP.
Its pretty interesting reading. However he used a carpenter analogy which renders any argument invalid. If he had used a car analogy I would have believed everything he's written.
How many of these are still problems now, as opposed to in earlier versions of the language/interpreter? Perl is another language that wasn't all that well designed at first, but was added onto later as it grew into popularity and was used in roles that were unthinkable in its early days.
It is pretty obvious that PHP started out small and grew into its present form, which can be seen with the inconsistency with library function names; obviously they didn't want to break compatibility arbitrarily so they st
There are answers to most of your gripes....except search function needle/haystack ordering. That one bugs me too, as I can never remember which function uses which order.
As someone who also works with PHP every working day, I'd just like to respond to your examples of "what went wrong":
- Arrays and hashes are the same data structure, for no readily apparent reason. Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c,...]" like everyone else.
So? Does this gripe have any practical implications? Or is it just a whine for a whine's sake? Also, as of PHP 5.4 (which has been March 2012 BTW), you CAN use the [a,b,c] syntax to create arrays.
- All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not.
Again - so what? You presumably learned how PHP variables work, so you're doing OK. Don't worry about Perl when you're using PHP.
- For a long time, OOP was an afterthought.
But it's not an afterthought now. Or are you still using PHP 4?
- Unlike other scripting languages like Python, Ruby, and Perl, PHP can't figure out which files to include for you when you reference something outside of the current file. Instead, it offers a global facility called an "autoloader" that allows you to write your own code to tell it how to find it, which completely breaks when multiple libraries have competing autoloaders trying to pick up two different classes with the same name.
Agree... the snobby sophomoric programmers come out and jump on the bandwagon against what is probably the most widely used language to develop websites with, and claim it's not a good language to develop websites in... it's laughable. It's surely not my favorite language, but it does what it needs to do, it does it relatively simply (that seems to be their problem - if it's easy it can't be good), is well supported. When I switched my website scripting from PERL to PHP it was fantastic; now I use python,
Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c,...]" like everyone else.
So? Does this gripe have any practical implications?
Yes there is: without syntax highlighting, I can't tell at a glance whether I'm looking at a data structure or a function call, I have to read it more carefully.
- All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not.
Again - so what? You presumably learned how PHP variables work, so you're doing OK. Don't worry about Perl when you're using PHP.
It's harder for me to tell at a glance whether I'm dealing with a numeric array, an associative array (what the rest of the world calls a hash), an object, or a scalar value (e.g. a string or integer). To make matters even more challenging, the culture of the PHP community tries to make it so you can hand it any of those and it will try to convert i
Or sometimes not: For example, I tracked down a fatal error that was occurring because a default argument (an array) was being manipulated inside of a function. It turned out that what PHP was doing was treating that default argument as a static value the first time, and the second time the function was called it was crashing because it was trying to access the first run's value on the stack. I was able to work around it, but that's not a bug in the program, that's a bug in the PHP interpreter.
Honestly, I don't understand what all the complaining is about. It just seems like a lot of language snobbery to me.
As someone who works with PHP every working day: It's a language that wasn't designed, it was congealed. Its lack of design is very evident as soon as you start trying to build anything interesting with it. It was something that was created to solve a short-term problem for one guy, and more-or-less accidentally grew into what it is today. What structures it does have are poor attempts at imitating other languages.
Some examples of what went wrong:
- Arrays and hashes are the same data structure, for no readily apparent reason. Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c,...]" like everyone else.
- All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not.
- For a long time, OOP was an afterthought.
- Unlike other scripting languages like Python, Ruby, and Perl, PHP can't figure out which files to include for you when you reference something outside of the current file. Instead, it offers a global facility called an "autoloader" that allows you to write your own code to tell it how to find it, which completely breaks when multiple libraries have competing autoloaders trying to pick up two different classes with the same name.
- Library functions display no consistency whatsoever. Some are camelCase, some are under_scored. Some search functions put the needle before the haystack, some the other way around.
- Some operators are funky: Values can be equal without being the same thing, for example.
- A significant number of errors, instead of generating exceptions that can be caught and handled, generate fatal errors, which crash your application no matter what. By comparison, Perl, Python, Ruby, and Java allow you to handle almost any error.
I could go on, but the point is there's real reasons for hating PHP.
You could go on forever. Every day that I work on PHP code, I discover another absuridity in this moronic language. Here is today's: take the php function intval, which is meant to parse a string and return an integer:
- if you pass it an object, it emits an E_NOTICE and returns 1
- if you pass it NULL, an array(), and perhaps other things, who knows, it returns 0
- if you pass it a garbage string that is not a number it returns 0
- if you pass it a number with garbage appended it returns the number (e.g., "123aaaa" returns 123)
- if you pass it an overly large number it returns MAXINT
Apparently it did not occur to the people designing this that using valid return values to indicate error conditions is not a good idea.
Add to this, the fact that to know what a PHP API function REALLY does, you often have to read the comments under the API documentation page so you can find out of all the weirdnesses and special cases that the documentation does not mention.
Then perhaps you should be using the companion function is_numeric() on the variable before attempting to convert it and then you wouldn't have this problem of vague return values!
Then perhaps you should be using the companion function is_numeric() on the variable before attempting to convert it and then you wouldn't have this problem of vague return values!
Sure, there are always ways to get stuff to work despite the language and API's bad design, I myself get stuff done in PHP when I have to and hey, it beats writing machine code by punching holes in punch cards, but that does not mean the design is not bad and harmful to productive development... Unless you can find a rational reason why intval on an object should return 1, while intval on an array returns 0, and for so many other equally absurd decisions in the language, runtime and API. Try giving this a r
The better question is why are you passing an object or an array into intval? It says right in the docs that you shouldn't pass an object into that function.
If the php API made any sense, intval would either return NULL or raise an exception when you pass it a value that is not a valid number. You cannot use a number (0 or 1 or MAXINT, depending on the input) to indicate an error in a function that has a non-error output domain that includes all integer values.
The sad part is that both of the two big languages for web development are like this (with JavaScript) being the other one. When you need to write software that's reasonably maintainable, flexible and secure, having a language that's consistent and predictable is pretty much required.
Is it suitable for a gigantic website like Facebook?
Yes. Facebook is actually implemented in PHP. At one point they used a compiler to compile PHP directly to machine code. Today they have an alternative to Zend called the HipHop Virtual Machine [facebook.com] (HHVM.)
It's also harder to learn how to do things WELL in PHP. PHP is full of gotchas that complicate programs and catch even veteran programmers, ending up as bugs.
It is a bad language as far as languages go. It's ONLY upside, in today's world, is it's ubiquity, which is not really much of a bragging point.
Node, or Python/ruby with a good framework (which unsurprisingly, the php frameworks are now emulating), is a better choice for someone starting a new project, hands down.
Facebook? (Score:0, Insightful)
People still use PHP outside of Facebook? And, honestly, they're not even really using it with their cross compilers.
Re:Facebook? (Score:5, Interesting)
Re:Facebook? (Score:5, Insightful)
Honestly, I don't understand what all the complaining is about. It just seems like a lot of language snobbery to me. I used PHP on my small website because every cheap web host out there supports it, there's tons of example code, and it's easy to learn if you have a C/C++ background. It seems to work just fine. Is it suitable for a gigantic website like Facebook? I have no idea really, and I don't care, just like I don't care that bash shell scripts probably aren't suitable for writing, for instance, a full-featured application like a spreadsheet or a video editor, as shell scripts work quite well for the things I do use them for.
Re:Facebook? (Score:5, Insightful)
Honestly, I don't understand what all the complaining is about. It just seems like a lot of language snobbery to me.
As someone who works with PHP every working day: It's a language that wasn't designed, it was congealed. Its lack of design is very evident as soon as you start trying to build anything interesting with it. It was something that was created to solve a short-term problem for one guy, and more-or-less accidentally grew into what it is today. What structures it does have are poor attempts at imitating other languages.
Some examples of what went wrong: ...]" like everyone else.
- Arrays and hashes are the same data structure, for no readily apparent reason. Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c,
- All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not.
- For a long time, OOP was an afterthought.
- Unlike other scripting languages like Python, Ruby, and Perl, PHP can't figure out which files to include for you when you reference something outside of the current file. Instead, it offers a global facility called an "autoloader" that allows you to write your own code to tell it how to find it, which completely breaks when multiple libraries have competing autoloaders trying to pick up two different classes with the same name.
- Library functions display no consistency whatsoever. Some are camelCase, some are under_scored. Some search functions put the needle before the haystack, some the other way around.
- Some operators are funky: Values can be equal without being the same thing, for example.
- A significant number of errors, instead of generating exceptions that can be caught and handled, generate fatal errors, which crash your application no matter what. By comparison, Perl, Python, Ruby, and Java allow you to handle almost any error.
I could go on, but the point is there's real reasons for hating PHP.
Re: (Score:2)
Better then 'Moose knuckle' (camelToe's fat ugly sister).
Re:Facebook? (Score:5, Interesting)
Someone did go on, and on, and on, on this topic. Interesting read that makes never want to go near PHP again:
http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ [veekun.com]
Re: (Score:2)
And don't forget his follow-up: http://me.veekun.com/blog/2012/07/28/quick-doesnt-mean-dirty/ [veekun.com]
Unicode (Score:2)
Please tell us how PHP rocks to handle Unicode...
Re: (Score:2)
Re: (Score:2)
How many of these are still problems now, as opposed to in earlier versions of the language/interpreter? Perl is another language that wasn't all that well designed at first, but was added onto later as it grew into popularity and was used in roles that were unthinkable in its early days.
It is pretty obvious that PHP started out small and grew into its present form, which can be seen with the inconsistency with library function names; obviously they didn't want to break compatibility arbitrarily so they st
Re: (Score:2)
PHP Array Short Syntax [php.net]
There are answers to most of your gripes....except search function needle/haystack ordering. That one bugs me too, as I can never remember which function uses which order.
Re: (Score:2)
- Arrays and hashes are the same data structure, for no readily apparent reason. Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c, ...]" like everyone else.
So? Does this gripe have any practical implications? Or is it just a whine for a whine's sake? Also, as of PHP 5.4 (which has been March 2012 BTW), you CAN use the [a,b,c] syntax to create arrays.
- All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not.
Again - so what? You presumably learned how PHP variables work, so you're doing OK. Don't worry about Perl when you're using PHP.
- For a long time, OOP was an afterthought.
But it's not an afterthought now. Or are you still using PHP 4?
- Unlike other scripting languages like Python, Ruby, and Perl, PHP can't figure out which files to include for you when you reference something outside of the current file. Instead, it offers a global facility called an "autoloader" that allows you to write your own code to tell it how to find it, which completely breaks when multiple libraries have competing autoloaders trying to pick up two different classes with the same name.
Again,
Re: (Score:2)
Agree... the snobby sophomoric programmers come out and jump on the bandwagon against what is probably the most widely used language to develop websites with, and claim it's not a good language to develop websites in... it's laughable. It's surely not my favorite language, but it does what it needs to do, it does it relatively simply (that seems to be their problem - if it's easy it can't be good), is well supported. When I switched my website scripting from PERL to PHP it was fantastic; now I use python,
Re: (Score:2)
Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c, ...]" like everyone else.
So? Does this gripe have any practical implications?
Yes there is: without syntax highlighting, I can't tell at a glance whether I'm looking at a data structure or a function call, I have to read it more carefully.
- All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not.
Again - so what? You presumably learned how PHP variables work, so you're doing OK. Don't worry about Perl when you're using PHP.
It's harder for me to tell at a glance whether I'm dealing with a numeric array, an associative array (what the rest of the world calls a hash), an object, or a scalar value (e.g. a string or integer). To make matters even more challenging, the culture of the PHP community tries to make it so you can hand it any of those and it will try to convert i
Re: (Score:2)
Or sometimes not: For example, I tracked down a fatal error that was occurring because a default argument (an array) was being manipulated inside of a function. It turned out that what PHP was doing was treating that default argument as a static value the first time, and the second time the function was called it was crashing because it was trying to access the first run's value on the stack. I was able to work around it, but that's not a bug in the program, that's a bug in the PHP interpreter.
Wouldn't the
Re: (Score:2)
That's what you might think, but (in at least this version of PHP) this crashed the application (apologies if /. screws up the formatting):
class Foo { ...
public function bar($arg=array()) {
$arg[] = 'bar';
}
}
While this worked fine:
class Foo {
public function bar($arg=null) {
if ($arg === null) {
The list of absuridities just never ends... (Score:5, Insightful)
Honestly, I don't understand what all the complaining is about. It just seems like a lot of language snobbery to me.
As someone who works with PHP every working day: It's a language that wasn't designed, it was congealed. Its lack of design is very evident as soon as you start trying to build anything interesting with it. It was something that was created to solve a short-term problem for one guy, and more-or-less accidentally grew into what it is today. What structures it does have are poor attempts at imitating other languages.
Some examples of what went wrong: - Arrays and hashes are the same data structure, for no readily apparent reason. Also, the simplest way of using that data structure is "array(a,b,c,...)", not "[a,b,c, ...]" like everyone else.
- All variables start with $, in imitation of Perl, but don't use the @ or % prefixes the way Perl does, instead just pretending everything's a scalar even though it's not.
- For a long time, OOP was an afterthought.
- Unlike other scripting languages like Python, Ruby, and Perl, PHP can't figure out which files to include for you when you reference something outside of the current file. Instead, it offers a global facility called an "autoloader" that allows you to write your own code to tell it how to find it, which completely breaks when multiple libraries have competing autoloaders trying to pick up two different classes with the same name.
- Library functions display no consistency whatsoever. Some are camelCase, some are under_scored. Some search functions put the needle before the haystack, some the other way around.
- Some operators are funky: Values can be equal without being the same thing, for example.
- A significant number of errors, instead of generating exceptions that can be caught and handled, generate fatal errors, which crash your application no matter what. By comparison, Perl, Python, Ruby, and Java allow you to handle almost any error.
I could go on, but the point is there's real reasons for hating PHP.
You could go on forever. Every day that I work on PHP code, I discover another absuridity in this moronic language. Here is today's: take the php function intval, which is meant to parse a string and return an integer:
- if you pass it an object, it emits an E_NOTICE and returns 1
- if you pass it NULL, an array(), and perhaps other things, who knows, it returns 0
- if you pass it a garbage string that is not a number it returns 0
- if you pass it a number with garbage appended it returns the number (e.g., "123aaaa" returns 123)
- if you pass it an overly large number it returns MAXINT
Apparently it did not occur to the people designing this that using valid return values to indicate error conditions is not a good idea.
Add to this, the fact that to know what a PHP API function REALLY does, you often have to read the comments under the API documentation page so you can find out of all the weirdnesses and special cases that the documentation does not mention.
Re: (Score:2)
Then perhaps you should be using the companion function is_numeric() on the variable before attempting to convert it and then you wouldn't have this problem of vague return values!
Re: (Score:2)
Then perhaps you should be using the companion function is_numeric() on the variable before attempting to convert it and then you wouldn't have this problem of vague return values!
Sure, there are always ways to get stuff to work despite the language and API's bad design, I myself get stuff done in PHP when I have to and hey, it beats writing machine code by punching holes in punch cards, but that does not mean the design is not bad and harmful to productive development... Unless you can find a rational reason why intval on an object should return 1, while intval on an array returns 0, and for so many other equally absurd decisions in the language, runtime and API. Try giving this a r
Re: (Score:2)
The better question is why are you passing an object or an array into intval? It says right in the docs that you shouldn't pass an object into that function.
If the php API made any sense, intval would either return NULL or raise an exception when you pass it a value that is not a valid number. You cannot use a number (0 or 1 or MAXINT, depending on the input) to indicate an error in a function that has a non-error output domain that includes all integer values.
Re: (Score:3)
Re: (Score:1)
+1 to this.
Re: (Score:2)
The sad part is that both of the two big languages for web development are like this (with JavaScript) being the other one. When you need to write software that's reasonably maintainable, flexible and secure, having a language that's consistent and predictable is pretty much required.
Re: (Score:2)
Is it suitable for a gigantic website like Facebook?
Yes. Facebook is actually implemented in PHP. At one point they used a compiler to compile PHP directly to machine code. Today they have an alternative to Zend called the HipHop Virtual Machine [facebook.com] (HHVM.)
Re: (Score:1)
It's also harder to learn how to do things WELL in PHP. PHP is full of gotchas that complicate programs and catch even veteran programmers, ending up as bugs.
It is a bad language as far as languages go. It's ONLY upside, in today's world, is it's ubiquity, which is not really much of a bragging point.
Node, or Python/ruby with a good framework (which unsurprisingly, the php frameworks are now emulating), is a better choice for someone starting a new project, hands down.
Re: (Score:3)
I so know what my next shell script should be.
Re: (Score:2)
Re: (Score:1)
Honestly, I don't understand what all the complaining is about. It just seems like a lot of language snobbery to me.
Ah yes, the mark of an amateur. Dismissing concerns about good language design principles as snobbery or elitism.
Only in the amateur world of PHP and in the GOP are things like education considered elitism and should be shunned.
PHP is never the right answer as folks from Facebook learned the hard way. http://www.quora.com/Quora-Infrastructure/Why-did-Quora-choose-Python-for-its-development/answer/Adam-DAngelo [quora.com]