PHP is the dream of a one-man team that gets paid by the hour. Get contract, slap something together that makes the client willing to pay, throw it all away and do it again when the client wants a change.
I've also hacked up a bunch of open source projects (wordpress, joomla). No tests, so you never know what you've fucked up, and you spend more time checking for regressions than actually adding that one feature you want. That's not how you do large scale software development, that's how you add pack on billable hours by charging your client for the same work 100 times.
Really, it's boils down to taste more than anything else. I've yet to see a tasteful application written in PHP.
If I were to summarize it with one anti-pattern, it's that PHP encourages people to mix unrelated parts of the program into one place, making testing, maintenance, and understanding nearly impossible. I should be able to test your app's interface without having a database. I should be able to write a database query without reading any code that touches HTML. And it's something I never see in PHP code.
Really, you judge PHP off of Wordpress and Joomla?
I work with WP, I'm the first to recognize it's an old codebase with all defects this entails, but popularity has value. Value that PHP critics dismiss too lightly.
So the answer is No, you don't have any experience with professional PHP, and you haven't used it in more than half a decade. Could have just said that.
Haha, you are actually the problem you complain about.
Half assed "developers" who try to build anything large scale with WP or Joomla, people who can't be bothered to keep up with the changes that happened in the past 5-10 years but still complain about how shitty everything is.
$productid = "0x4zz5";
print $productid + 4;
If printing "8" is your idea of a working interpretation of that code, then PHP is the language for you.If not, then PHP doesn't work. End of story.
So, you'd probably be pretty ornery too when other people had more discipline to use the language without shooting their foot and were also employing it successfully. You'd probably want to make assumptions, and word hard to belittle them. Insult them.
And they'll talk about beauty. And zen. And wonder, and joy in a language. And they'll gloss over the major problems that it suffers from. They'll imagine all is well. And they'll try and tell you that nothing good can come from the tool they once used to shoot themselves in the foot.
Just walk away. Because you still have two feet.
print $productid . 4;You missed the problem as well. Don't ask for trouble by creating broken situations.
Of course, it is better to manually convert.
It's the computer equivalent of a bozo worker who does something random everytime they don't know how to do their job, and then tries to hide any consequences while whistling innocently.
The whole total function has something that it's expected to do, some value that it returns in the end - and if it can't do that then any returned value is useless and wrong anyway; and automatic, silent type conversion is the worst possible choice of action, since it not only doesn't work, returning a value that you didn't intend (as other options); but in addition makes the actual bug hard to find and potentially corrupts a lot of stored data before you find the bug.
I wish I could use static typing too, but when I can't I use vars that are somewhat intuitive.
Implicit type conversion is evil, and I don't see how PHP's sin of favouring string -> number over number -> string is any worse than, say:
// Javascript
console.log(+(+!![]+(+[]+[]))); // outputs the number 10
Or: // C, Java
float celsius, fahrenheit1, fahrenheit2;
celsius = 100;
fahrenheit1 = celsius * 9 / 5 + 32;
fahrenheit2 = 9 / 5 * celsius + 32;
assert(fahrenheit1 == 212); // OK
assert(fahrenheit2 == 212); // Oops! It's 132. What happened?harshreality argued that, because PHP's implicit type conversion leads to weird behaviour, "PHP doesn't work. End of story."
In that case, nearly every widely used language (with the possible exception of Python 3) "doesn't work. End of story." That's not a very interesting or useful story to tell.
As I said earlier, I agree that implicit type-conversion is evil. But if I refused to use flawed tools...