PHP 5.4.0 released
PHP 5.4.0 released
Posted Mar 2, 2012 21:49 UTC (Fri) by Kit (guest, #55925)In reply to: PHP 5.4.0 released by HelloWorld
Parent article: PHP 5.4.0 released
Posted Mar 2, 2012 22:22 UTC (Fri)
by khim (subscriber, #9252)
[Link] (3 responses)
It was discussed many times. PHP is completely build around violation of Rule of Repair - that's what makes it “suitable for non-developers” and that some thing also means it's turing tarpit. It's much easier to create half-working prototype in PHP, but to create production-quality code you need not only fight the task at hand but you need to somehow curb this insane tendency to “help you”… by adding security holes to perfectly valid algorithm. Think about it: how many things may fail if the result of sort() is not, in fact, sorted? Regular expressions are pretty fundamental - yet PHP screws them, too. And so on.
Posted Mar 3, 2012 0:03 UTC (Sat)
by rfunk (subscriber, #4054)
[Link] (2 responses)
- Rule of Repair violation. The only place I really see this is in the fact that it's a loosely-typed (and dynamically-typed) language with implicit conversion. While these attributes certainly annoy programmers used to a different type of language, there's nothing inherently wrong with them.
- Turing tarpit. Not even close; in fact it's more of a kitchen-sink language, with everything thrown in with little regard to consistency.
- "help you by adding security holes". Very true, but most of this can be avoided with proper php.ini configuration (though the existence of such a thing is itself a big problem) combined with a "good parts" approach to the language. This is where a novice really causes havoc with PHP, and why I cringe at its common "non-programmer" uses.
- Regular expressions. OK, so they don't perform as well as they could. So what? If you want performance you're looking in the wrong place anyway, and if you're coming from Perl and want a little more speed you just need to use regexes a little less.
All that said, I do think PHP deserves quite a bit of ridicule. It's the most wildly inconsistent language I've ever seen taken seriously, didn't gain anonymous functions (sorta) until the last major release (despite having array-transformation functions that need that sort of thing), and only now is getting a sane array syntax. My years doing Ruby instead were great (except for deployment/sysadmin), and these days I'm much happier when I can do Javascript (including some server-side) than when I'm doing PHP.
Posted Mar 3, 2012 1:00 UTC (Sat)
by elanthis (guest, #6227)
[Link] (1 responses)
1) Identifiers magically turn into strings, mostly I believe because function handlers have just been strings until relatively recently.
echo FOO; // prints FOO
2) Magic quotes. Yes, they're finally gone, but the fact that some dork put them in there in the first place proves that said dork had no business designing, implementing, distributing, and promoting a language.
Posted Mar 3, 2012 14:56 UTC (Sat)
by rfunk (subscriber, #4054)
[Link]
I loosely put magic quotes in the "help you by adding security holes" category. I'm glad they're finally gone, but I agree that their existence says nothing good about the language designer, or at least the language's aspirations beyond "Personal Home Pages".
Posted Mar 3, 2012 2:42 UTC (Sat)
by HelloWorld (guest, #56129)
[Link] (8 responses)
But please, answer me one question: what is PHP actually better at than the alternatives I've pointed out? Because I can't think of anything.
Posted Mar 3, 2012 11:19 UTC (Sat)
by ggiunta (guest, #30983)
[Link] (7 responses)
1. It's easy
About 1:
Developers moaned about language inconsistencies since about forever, but the fact is that this is not a big problem as some think it is.
I can pick up most php libraries / frameworks out there, plug them in my app, and if I find a problem debug it and patch it in half an hour. This might be true for other languages, but definitely not Java or Perl.
Loose typing is actually a good choice 99% of the time when writing an app. When writing a framework/library it's probably the opposite. But how many developers are writing apps compared to frameworks?
Heck, even the choice not to have private/protected/public members in classes (for php4) really makes sense in the context of an application. How many times are you going to subclass a class which is specific to the business-logic problem at hand? If you're not going to subclass, all the time you spend thinking about this particular aspect is wasted.
Making the language clean up for yourself at the end of every web page means that things like global variables, generally despised in other languages, are not a bad practice anymore. Purists yell when they see it, but it's only because they have not yet understood the scoping implication of the one-page-one-scrip approach.
About 2:
Want to hack a bit of script in an html page? super fast.
About 3:
I like my hashes to be as simple as arrays. I rarely mix them up - depending on context (or the value of the variable at hand) I can figure out which one of the two is in use. So my array construct is slower than in any other known language. Thing is, for making websites the page speed is nowadays wasted mostly 1-in frontend rendering of all the js and css, and 2-in the db query or nosql fetch. Array manipulation is gonna be 0.1% of it.
Posted Mar 4, 2012 1:57 UTC (Sun)
by tialaramex (subscriber, #21167)
[Link] (3 responses)
PHP encourages spaghetti, encourages bad practices like using string concatenation instead of parameter binding, even encourages the "copy paste" approach to code-reuse. And so on through a litany of maintenance-hostile behaviours.
It has taken long painful years to beat the worst security mis-features out of PHP. It may be decades before the knock-on effects reach the many PHP "applications" (if piles of accumulated PHP may be so-called) that have grown up while such mis-features existed.
Posted Mar 4, 2012 12:59 UTC (Sun)
by DG (subscriber, #16978)
[Link] (1 responses)
I'm not sure why you think PHP encourages copy+paste coding more than any other language. If it does, it's probably because of it's low barrier to entry which results in some less skilled/proficient people writing it.
Posted Mar 4, 2012 15:41 UTC (Sun)
by anselm (subscriber, #2796)
[Link]
Anything is maintainable if you're investing enough care and effort. People are maintaining large assembly language programs, after all. The real question is whether maintaining something in PHP or assembly language is worth the trouble when there are lots of other approaches that let you achieve the same level of maintainability with less effort (while probably also improving all sorts of other quality metrics to boot). In the case of assembly language, most people have figured out for themselves what they prefer, which is why there are much fewer large assembly language programs around than there used to be.
Having said that, PHP is great. It is the best thing since the invention of sliced bread. Everybody should be using PHP all the time. It would make us Django people look so much more competent and efficient by comparison.
Posted Mar 4, 2012 17:45 UTC (Sun)
by man_ls (guest, #15091)
[Link]
Posted Mar 4, 2012 16:26 UTC (Sun)
by HelloWorld (guest, #56129)
[Link] (2 responses)
About 2: embedding Python (or Ruby or Perl) is trivial using modules such as Spyce. And of course, Python has had lambdas, closures and proper OOP for way longer than PHP.
About 3: there's no sensible reason for mixing up arrays with dictionaries, they're simply different things. That doesn't imply that one is harder to use than the other (as can be seen in Python).
So sorry, but I don't buy those arguments. IMO, PHP does nothing better than the alternatives I've listed, and you haven't proven otherwise.
Posted Mar 5, 2012 9:07 UTC (Mon)
by ggiunta (guest, #30983)
[Link] (1 responses)
But to each its own, I guess
Posted Mar 5, 2012 12:40 UTC (Mon)
by HelloWorld (guest, #56129)
[Link]
PHP 5.4.0 released
PHP 5.4.0 released
PHP 5.4.0 released
PHP 5.4.0 released
PHP 5.4.0 released
PHP 5.4.0 released
2. It's powerful
3. It's fast enough for most tasks
Q: Is it find(haystack, needle), or find(needle, haystack)? A: I do not care. I can not remember syntax of all functions in the language anyway, not to mention frameworks, but the online documentation for that function is one click away. And if I'm using an IDE, I get a tooltip to tell me.
Think about the function validatePassword(string $p1, string $p2) versus validatePassword($username, $password)
. Which one is typesafe? Which one is gonna be abused by the caller?
Want to code purely oop? can be done.
Like lambdas and closure? Can be done too (ok, not the best implementation out there, but still...)
PHP 5.4.0 released
PHP 5.4.0 released
PHP 5.4.0 released
PHP is maintainable - if you set about it in the right way using good software engineering practices - code style guidelines, unit tests, reviews, CI etc.
IME proper engineering is not harder to do in PHP than in other languages; and some things like, you know, serving web pages is actually easier. I have not worked with Python or Ruby frameworks though; only with Java frameworks which grow more byzantine by the year. But people are even suggesting Scala here, so I guess their tolerance for the bizarre must be quite high.
PHP 5.4.0 released
PHP 5.4.0 released
PHP 5.4.0 released
PHP 5.4.0 released
Perl has had *everything* for years that is "new" in PHP 5.4. Same thing with the 5.3 release. Plus it has proper Unicode support which PHP lacks to this day.
Also, I am not the one who started this discussion by asserting random stuff like PHP being irreplaceable, Kit is the one who should explain why he things this is so.