PHP 5.2.0 Released
ShaunC writes "The PHP Group and Zend have released PHP 5.2.0, and upgrades are encouraged. The 5.2.0 update offers several security fixes, including patches for a couple recently announced buffer overflows in input parsing. This release also includes a number of library upgrades, bug fixes, and default bundling of the popular JSON extension to help with AJAX development. See the full changelog for more details."
When are they going to fix the insanity of all the string function names?
...a PHP story!
"PHP is a toy language" trolls in 3... 2... 1...
Basilisk Digital
Our company does web hosting, and every single time we get an enquiry involving PHP it comes with a caveat along the lines of "but I need version 4.x.y with version z of the q module and safe mode turned off". The best one yet was someone who wanted us to promise never to upgrade PHP because his XSLT module needs pre-version 4.4 - a bit of googling revealed that there's a whole section of the PHP community hunting for servers that will never upgrade for that reason. We never ever get this with perl, because backwards compatibility works over decades.
Virtually serving coffee
I'm sure this will be modded as flamebait, but I'm going to ask it anyway. Which is better Perl or PHP? What are the pros and cons of each?
I'm waiting for PHP to have uniform exception handling (like, EVERY error raises an exception), and to have an "ensure" mechanism so that code always runs even after an exception is raised (maybe I'm dense, but what is the purpose of exception handling without this basic feature?)
Some other things that would be nice would include the ability to create and pass anonymous functions in an easy way (i.e., not as strings, dammit), with closures, so that I can pass blocks to functions like, I dunno, almost every other dynamic language? So I can sort by a user-defined function in 1-2 lines, instead of 5-10?
CAN SOMEONE PLEASE FIX THE VARIABLE REFERENCE NONSENSE? I saw some code that began "foreach ($foo as &$bar)" and it somehow managed to replace every element of $foo with $foo[0], even though it never assigned anything.. which I simply can't comprehend.
How about making the PHP display tag automatically HTML-escape it's contents?? Use a longer opening tag for non-escaped content. This would make things SO much easier for the programmer and would pretty much eliminate great swaths of XSS.
Can we make it possible so that any two random PHP installations have the same language features?? The php.ini file is the WORK OF SATAN HIMSELF. Every PHP app I've shipped has to come with a detailed list of which php.ini flags have to be on or off. Feh.
I better stop now, or my HEAD WILL POP OFF.
Well, I'll say something nice about PHP too, how about these:
1) the completely flat function namespace means the documentation at php.net is fairly easy to use.
2) the phenomenal amount of crappy PHP code out there makes my mediocre programming skills look positively GOD-LIKE, so if I ever think I'll go hungry, I can just get a job as a PHP programmer (preferably, the ONLY PHP programmer in the org, otherwise I'll have to deal with the unwashed masses who wrote the stuff in the first place, and will be forced to slit my wrists [or his]).
See Mom, I can end with something nice, even about a crappy language like PHP!
Oops.
The sooner you fall behind, the more time you have to catch up.
It's easy to solve that problem. Start multiple PHP FastCGI daemons. Everyone of a different version/configuration. A customer wants some other PHP version/config? Just connect to another PHP FastCGI daemon for their virtual host.
It doesn't have to be like this. All we need to do is make sure we keep talking.
Well... there are multiple engines for including Perl in a web page like Mason and Apache::ASP.
But the Perl world is moving away from code-in-html. Generally, it is considered a better idea to isolate UI and logic from each other. The web frameworks for Perl, like e.g. Catalyst and Jifty, generally use Template engines like HTML::Template and Template Toolkit (Google/cpan yourself.)
Karma: Excellent (My Karma? I wish...:-( )
What language/runtime combination are other PHP users looking to switch to?
Perl, Python and Ruby zealots need not respond!
One man's insanity is another man's business opportunity.
Verily, it is far better to maintain the insanity, at a reasonable price, than to set about fixing it.
Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
Urbanradar,
Your comment pisses me off, but there's something I want to say all the same: I think you are, essentially, right. Whatever one's woes with PHP might be, they don't justify trolling and unsubstantiated mouthing off. Besides, "toy language" is a purely inflammatory statement that doesn't even have any factual content.
However.
However, the implicit underlying assumption I think I perceive in your comment -- that PHP criticism must be trolling -- annoys me a lot. Please allow me to expand on this.
You see, one constant characteristic of the Internet in general is the noise. Look here on Slashdot: do you read all the comments on any given story?
The noise is a bigger problem than you'd think. The noise means that it's hard to get heard. It means that to be heard, unless you're a remarkable writer (which I, and most people, aren't), you have to exaggerate your message. "PHP is a toy language" is one such exaggeration; and perhaps even actually worthy of being modded up if followed with factual information to support it. And much likelier to catch a moderator's attention with its use of strong language.
Which you would, undoubtedly, consider a troll all the same, wouldn't you?
As you can probably guess by now, I have crates of such information against PHP. (In my defense, I do try hard to gather evidence against my own tools of choice as well, for two reasons. One, being aware of their own idiosyncrasies allows me to work better with them. Two, it's a simple matter of intellectual honesty.)
The vagaries of life have landed me into a managerial-ish position in a small company that develops and hosts large-scale PHP websites. My responsibility here is twofold: ensuring that the sites work, and ensuring that they keep working.
I didn't know PHP before joining this company; I had a generally positive opinion of it beforehand, from reading Slashdot. So I got to discover it through that new role.
Let us just say, to put it mildly, that my opinion of PHP has quickly become very poor.
I think that managing a language's design and development is one of those jobs that's freaking damn hard. It takes a LOT of experience, critical thinking, introspection, knowing to prioritize issues, knowing to tap into the decades of experience in language design to understand what works and what doesn't, why, and in what context. And different people with different backgrounds and objectives are more or less successful with it.
And I don't feel the people behind PHP -- I'm sorry, guys, I don't know how to put it nicely... -- are doing the best possible job of it.
More precisely, my primary issue with PHP is its culture as a project. Cultures are inherently difficult to describe, but if I had to put it in a few words, I'd call it the "Works for me" culture.
Simply put, the sort of attitude that PHP seems to encourage -- by which I mean, the shortest-path-to-arrival approach to doing most things in PHP -- work fine for the developper producing the code, but are formally broken in a way that WILL come back to bite the ass of whomever poor dude is in charge of keeping the thing working.
For instance: I understand PHP uses a function based on the tolower() C call to make method calls case insensitive, and leaves it at it. It works for them, doesn't it? Except that in the real world, it breaks. Deploying PHP sites on servers that use a Turkish locale yields blank pages. The workaround is to never use that particular locale. Easy, isn't it? No, it isn't: PHP's gettext functions for dynamic translation require the locale to be set appropriately (unlike that of other languages). And I have my Turkish clients on the phone a lot.
Until recently, before the introduction of PDO, the canonical native way of addressing databases was to use PHP functions named after the database itself (mysql_*, etc, making the process of migrating databases, or creating a site that may have to be deployed client-side on varying database backends, an utte
-- B.
This sig does in fact not have the property it claims not to have.
Easier for some to rewrite htmlentities() as html_entities() in PHP than deal with buildconf fuckage!
This post explains most of my issues with PHP far more eloquently than I ever could.
Totally agree 100%. Another example: did you ever use nl2br() to convert newlines into <br> elements? It's an extremely common thing to do. In a minor patch release, they changed the function to generate XHTML instead of HTML. In one stroke, everybody who thought they were generating valid HTML had errors in their code. This might not sound that bad, until you realise that nl2br() can appear a lot in large projects, there's no way to get the old behaviour of nl2br() back, and if you have a decent QA process in place, you'd be being notified of the errors across all the websites you maintain. You end up having to go back and change all your code to use generic string replacement functions.
Now, maybe you might say that it's a sensible thing to change (I disagree, there should be different functions for HTML and XHTML), but at the very least, they should have put a change in semantics in a major version update, not sneaked it in between 4.0.4 and 4.0.5.
It's not really the design of the language that's the real problem (although it's not pretty), it's the cavalier attitude from people who don't seem to take a professional attitude to their work that really grates.
Bogtha Bogtha Bogtha
I agree that PHP can encourage a quick-and-dirty approach, and that the language is not perfect. The function naming and lack of namespaces are poor, and internationalization has a long way to go.
That being said, I believe it is possible to create high quality, professional, maintainable code with PHP. If it wasn't the case, large companies such as Yahoo wouldn't be adopting it. PHP has an emphasis on productivity, and it doesn't attempt to enforce good practices in the language structure itself. But it also doesn't prevent a skilled programmer from using good practices. If you are having so many difficulties with your projects, you may want to take a look at who is writing the code.
I'm not discounting that you have some valid points, but I also think your view is overly harsh. I've worked in many different languages, and they all have their faults. I find myself favoring PHP because it allows me to get good work done efficiently.
I'm using pike right now. I actually started writing a web framework for pike. If you don't mind having to write statically typed code, but getting run time type errors anyways, then pike is a good choice. If you need strong typing though, then keep looking. Ocaml is nice if you can tolerate its syntax, but I personally find:
function arg1 arg2 arg3;
to be a terrible mistake, as
function(arg1, arg2, arg3);
is much clearer.
Notice that the last line employs your syntax, and works the same as the curried function call in the line immediately above it.
Of course, curried functions are often very useful. Anyone who did actually know OCaml would clearly understand the power of partial function application, and thus would find your idea completely lacking.
Your post is complete and utter nonsense. Did you even bother to read my post? Yes, I do know ocaml. No, you cannot use a C style syntax for function calls (unless you work some camlp4 magic). Passing a single argument that happens to be a tuple is not the same as passing 3 args. You even pointed out how dumb your response is in your response! If you define all your functions to take tuples, currying is gone.
I don't want to pass my functions tuples, I want to pass it the seperate args. I just wish ocaml used a readable syntax, like I said. Trying to use C style function call syntax in ocaml gives you ENTIRELY different behaviour, and its not in any way the equivilent of calling the function with seperate args. My complaint is that the syntax for calling functions:
func arg arg arg
is much less readable than the tried and true C style:
func(arg, arg, arg)
Wishing the syntax was nicer is not the same as not knowing the language, next time try using your brain before you use your keyboard. How can you write a reply that actually points out how stupid the reply you're writing is, and yet still click the submit button anyways?
You've convinced me even further that you know next to nothing about OCaml, and just as little about C.
:= to be =. I'll give you credit, you're not as much of a jackass as he is. Long story short, the rest of us developers shunned his sorry ass, and threw out his code. He was gone after the next code review.
First of all, the semantics of C functions does not include support for currying. So if you want C-style functions in OCaml, accepting your parameters as a tuple in OCaml offers the exact same semantics as a C function call.
Second of all, the C-style function syntax is far more verbose. At the very lease, one more character is needed. In your example, three further characters are needed. It gets worse as the number of arguments that are passed increases. That's just not an efficient thing to be doing.
If you can't adapt to such a minor syntax variation, then you just plain shouldn't be a software developer. You remind me of an old Pascal hack programmer I worked with on an Objective-C project at one firm. The stupid fucker couldn't handle using Objective-C's = operator for assignment, so he'd use a preprocessor macro to define
I try to give ACs the benefit of the doubt, and the first reply was just barely sane enough to get me to bite, well done. But you can't just go jumping way overboard like that, its WAY too obvious you are trolling now. Try to stay subtle, or at least turn up the crazy a little more gradually.
That's just the thing a sissy like yourself would do: run away. The facts smacked your sorry ass down to the ground, brother. You don't know OCaml. You don't know C. And since you can't face those truths, you just have to cry "OmG!!!#!!@! Tr0LL!!!@!" and scurry away.
Stay away from OCaml. We don't need idiots like you making stupid technical suggestions, especially when you don't have any idea as to how infeasible and just plain fucking stupid your proposals are. Go back to fingerpainting, you dumb little twit. That is, if you can handle it.
Thing is, familiar implementations of C++ (including GCC on Windows) will bloat your executable by 200 KB if you use std::cin and std::cout of <iostream>, even if you strip it (gcc -s). It's especially a problem when trying to make a web server on a custom embedded OS that runs on a machine with 4 MB of RAM. Is this a problem peculiar to GNU C++?
Since every version of php breaks compatibility somewhere, how hard would it be to rename all functions to maintain consistency in php6 or 7?
PHP has got to be the most inconsistent language out there. Check out this list
* Arguments and return values are extremely inconsistent
* PHP has separate functions for case insensitive operations
* PHP has inconsistent function naming
* PHP has no lexical scope
* PHP has too many functions in the core
* PHP lacks abstraction and takes TIMTOWTDI to bad extremes
Open Source Java Web Forum with LDAP authentication