Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Bug PHP Programming

The PHP Singularity 622

An anonymous reader writes "Jeff Atwood at Coding Horror has a post about the awfulness of PHP — or, rather, a post about posts about the awfulness of PHP. He points out that PHP has been the whipping boy for the developer community for years, and while everybody seems happy to complain about it, nobody seems willing to do anything about it. He writes, 'From my perspective, the point of all these "PHP is broken" rants is not just to complain, but to help educate and potentially warn off new coders starting new codebases. Some fine, even historic work has been done in PHP despite the madness, unquestionably. But now we need to work together to fix what is broken. The best way to fix the PHP problem at this point is to make the alternatives so outstanding that the choice of the better hammer becomes obvious.'"
This discussion has been archived. No new comments can be posted.

The PHP Singularity

Comments Filter:
  • Really? (Score:4, Insightful)

    by Anonymous Coward on Friday June 29, 2012 @12:20PM (#40495201)

    What kind of bullshit logic is that? Something is broken, everyone hates it, so let's put all our efforts in making the alternatives better? How about contributing to PHP and fixing what you're bitching about instead of, well, bitching about it? You know, it's open-source and all.

  • by betterunixthanunix ( 980855 ) on Friday June 29, 2012 @12:24PM (#40495245)
    It is not as though there is no other choice. The only two things that need to be done are (a) stop writing new PHP code and (b) start migrating old PHP code to better languages. We can do web development in Python, Haskell, various Lisps, Scala, and several others. There is no "fixing" necessary, just phasing out -- and the only code related to PHP that needs to be written, if any, would be interfaces for better languages, so that old, impossible-to-rewrite code can be extended with something that is not PHP.
  • Re:Really? (Score:4, Insightful)

    by Anonymous Coward on Friday June 29, 2012 @12:24PM (#40495251)

    The problem lies at its core [php.net]. You can't fix people.

  • and (Score:3, Insightful)

    by Anonymous Coward on Friday June 29, 2012 @12:26PM (#40495291)

    if one is happy with PHP and has still not encountered peculiar problems?

  • by Anonymous Coward on Friday June 29, 2012 @12:27PM (#40495311)

    PHP is a language for getting thing done. Just like any toolbox, you can build great or terrible things with it. It's like perl in that way (and I've done plenty of both). If you code well, there's very little to complain about with PHP. I've hired java guys onto my php projects before, and they were up and running in a week or so because we were coding with some structure instead of slapping together hacks.

    And personally, I wouldn't want it any other way. I don't want language designers deciding they know what I want to do better than me. What I want, is the flexibility to build things as I see fit, and to do so quickly. Production is my goal. If you can help me build my projects elegantly/etc, then great, but getting it built quickly is always my priority.

  • by Ziest ( 143204 ) on Friday June 29, 2012 @12:29PM (#40495333) Homepage

    if php is broken what is javascript?

    A disaster.

  • by Anonymous Coward on Friday June 29, 2012 @12:32PM (#40495359)

    Any good programmer will be able to make awesome PHP code. Bad PHP written applications are just the result of lack of passion, knowledge, and in some cases don't forget it, pressure from the customer. Combine bad programming skills, no experience with other OOP languages, pressure and "I don't care how it is done, I've done it and it works that's enough"... and you get the result. I'm tired to read and hear that PHP is shit. -- ParaBug

  • Obligitory (Score:3, Insightful)

    by ArhcAngel ( 247594 ) on Friday June 29, 2012 @12:33PM (#40495379)
    Just replace standards with languages. [xkcd.com]
  • Re:Really? (Score:5, Insightful)

    by MightyMartian ( 840721 ) on Friday June 29, 2012 @12:33PM (#40495385) Journal

    Indeed. For years now it's been patiently explained over and over and over again what needs to be fixed, and the core team just keeps perpetuating the same crappy nonsense. Since there are other perfectly good languages out there, I see no point in anyone, say, forking PHP.

  • Re:Really? (Score:4, Insightful)

    by Anonymous Coward on Friday June 29, 2012 @12:35PM (#40495427)

    If I announce that I'm going to try to cross the Atlantic in an inflatable dinghy, there are two possible responses which a reasonable observer could have:

    1. Tell me I am an idiot and going to kill myself, and to use a proper boat instead, of which many excellent designs are readily available.
    2. Help me design and build the world's most awesome rubber dinghy, which, in the end, is still a rubber dinghy and still probably going to get me killed.

  • Re:Really? (Score:5, Insightful)

    by Richard_at_work ( 517087 ) on Friday June 29, 2012 @12:36PM (#40495441)

    That's what major version bumps are for. Make it a breaking change, rather than make it something that festers in the codebase forever. If the method is broken, then the solution is not to let apps continue to use it.

    Make it a breaking change, bump the major version up, force people to upgrade through obsolescence and we would be in a much better situation.

  • by MightyMartian ( 840721 ) on Friday June 29, 2012 @12:38PM (#40495465) Journal

    It's a broken tool that one has to put a considerable amount of effort into to write tolerably decent apps. It's libraries couldn't be worse than if someone took a print out of the specs, stuck dynamite in the middle and then tried to reassemble them. Coding in PHP has got to be one of the miserable experiences I have had, the only thing being worse is trying to fix someone else's PHP code.

  • Re:Really? (Score:4, Insightful)

    by Richard_at_work ( 517087 ) on Friday June 29, 2012 @12:40PM (#40495499)

    From what I've heard, that's pretty much what Facebook did - start off with PHP and eventually evolved their own language from it.

  • by wonkey_monkey ( 2592601 ) on Friday June 29, 2012 @12:40PM (#40495501) Homepage
    In what way does it "live in the browser"?
  • Re:Really? (Score:5, Insightful)

    by billcopc ( 196330 ) <vrillco@yahoo.com> on Friday June 29, 2012 @12:41PM (#40495527) Homepage

    The problem with "fixing" PHP is it breaks compatibility with existing code. Not all of it, but a lot of it, because it was either written by complete imbeciles who just happened to get lucky, or brilliant coders who worked around PHP's perversions.

    I'd like to think I fit in the latter category. I actually really like PHP because it's so dumb and open-ended, it lets me code whatever the hell I want without forcing much functional-programming hipster crap down my throat (I'm staring at you: Python/Ruby/Haskell/Scala/Clojure).

    Yes, it's messy, and yes, it could greatly benefit from a concerted cleanup effort, but given it's install base and the mind-numbing amount of public code in use, it's hard to justify the pain in fixing all that stuff. Just think of the tens of millions of sites running some spinoff of PhpBB, the countless MediaWikis, nearly every torrent tracker, and all those pages of horrible code written by the aforementioned imbeciles. That's a lot of pain to satisfy a few pedants. Clearly, PHP works "well enough" for most of us.

    That said, nothing's stopping people from forking it, fixing that code, and releasing it as something new. If it's better than PHP and helps me land paying work, or make my own projects easier to develop and maintain, I'll happily use it. Ah, but that would require these people to stop posting inflammatory linkbait on their canned Wordpress blogs and actually practice what they preach...

  • by EmperorOfCanada ( 1332175 ) on Friday June 29, 2012 @12:49PM (#40495639)
    I would be less quick to blame PHP than blame the fact that many PHP programmers come from "Web" developers. People who started with MS Paint and some HTML, then some CSS and then jammed in some PHP. After a while they got pretty good at small PHP 50 line programs. But when faced with huge projects people like this just aren't prepared. A great programmer could use PHP just as well as any other language.

    But the second half is that PHP should be bad at times. Often a simple unstructured script is the best. It needs to do a simple thing quickly and well. There is no need for templating, language abstraction, unit testing, separation of data, logic, and view. So if you are a bank deploying a mission critical system then it should be rigorous and perfect. But if your blog about car tires needs a widget that reads from your odometer then hack away.

    I would say that all arguments that condemn PHP should whither under the light that Facebook was developed primarily in PHP with MySQL. Even now they have their Hip Hop that converts PHP to C++. Arguing against PHP is like saying that Carbon Fiber is a better material than steel for car frames. Absolutely true but most cars are still successfully made from steel for a wide variety of reasons. Next time I need to win an F1 challenge and it had better be Carbon Fiber. But for the next ride to the grocery store and I just don't care.
    So to circle around one could argue that the best cars are made from this or that but the reality is that what made the truly terrible cars terrible was that the designer would have made a terrible car out of anything. So teach a "better" language to the people making messes with PHP and you will just have a different kind of mess.
  • by Angst Badger ( 8636 ) on Friday June 29, 2012 @12:49PM (#40495647)

    I've programmed in every major language and several minor ones from the 1970's to the present day, never mind design methodologies. They all have their relative strengths and weaknesses, but at the end of the day, the only thing that really recommends one over the other is a) what's available, and b) what you're most familiar with. No widely used language is "broken" any more than any natural spoken language is broken. No one ever says, hey, this novel would be much easier to write if we were taking advantage of the greater expressive power of Indonesian instead of kludgy old Lithuanian.

    Aside from juvenile cliquishness and fashion obsession, every language flamefest starts with people obsessing on some awkward feature of the dominant language du jour, and then concluding that all of their problems would be solved if we all switched to some other language without that awkward feature. Of course, tomorrow's language (or methodology, editor, coding standard, platform) has its own awkward qualities that will only become apparent once it collides with the real world on a large scale, setting the stage for the day after tomorrow's language. Rarely does anyone pull their head out of their compiler/interpreter long enough to recognize that it's the real world that's awkward, and no amount of switching between fundamentally equivalent machine-parseable languages is going to change that.

    Instead, we keep implementing the same stuff over and over in one language after another until the pace of real progress slows so much that we can actually get excited that the document viewer we're trying to port everything over to is receiving a "major" new features in HTML5 that will allow it to get a little closer to matching the desktop GUI functionality of twenty years ago, only not as well and with the added requirement of several orders of magnitude more hardware power required to keep it going.

    But by all means, let's get rid of PHP if that makes it easier to imagine that we're doing something besides reinventing the same old wheel and doing it badly.

  • Re:Really? (Score:5, Insightful)

    by Java Pimp ( 98454 ) on Friday June 29, 2012 @12:50PM (#40495649) Homepage

    I don't know. It looks like some guy has code that sends uninitialized or null values which to me would invoke undefined behavior and is then bitching about when that behavior changes.

    From the thread: We are passing a (possibly uninitialized, or null-valued) variable to the function, in hundreds of places

    Sounds to me like this guy has other issues he should be worrying about.

  • by ewieling ( 90662 ) <user&devnull,net> on Friday June 29, 2012 @12:50PM (#40495657)
    The C-like syntax and wrappers for all sorts of handy stuff like POSIX threading, sockets, SSL, etc is why I like PHP. My biggest issue with PHP is that these functions are poorly documented (especially the SSL wrappers). I am not a language purist, I want something easy to use, gives me access to all the nifty stuff Unix can provide, and doesn't make me learn an entirely new syntax. If I was a professional programmer I might feel differently, but for MY needs at my job and for personal projects PHP is a good tool.
  • Re:Really? (Score:5, Insightful)

    by Anonymous Coward on Friday June 29, 2012 @12:50PM (#40495659)

    Poor example. Someone goes bananas when incorrect and inconsistant behaviour ( returning a number from a number formatting function when passed something that is not a number) is changed to correct behaviour consistent with the rest of php core (returning something that is not a number), after months of pre-releases and 'this is going to break buggy code' announcements, after everybody else has fixed their buggy code, and starts name calling, rather than:
    a) fixing their own buggy code or
    b) not upgrading the minor version on affected systems until their code is fixed

    This looks like a problem with the submitter, not the PHP team.

  • by codepunk ( 167897 ) on Friday June 29, 2012 @12:52PM (#40495687)

    The biggest problem I have with python is that it spoils me. Writing python for a couple of weeks then having to jump back into a C syntax language causes me pain. It takes a few days again to get over the fact that I am constantly having to type cruft just so the compiler knows what I mean.

  • by melonman ( 608440 ) on Friday June 29, 2012 @12:53PM (#40495695) Journal

    The assumption in TFA seems to be that PHP does something that couldn't be done otherwise now, or does it more easily, or something. But I don't think that's true. There are alternative languages and alternative ecosystems now. IMO, most PHP coders don't use PHP because they have looked at the alternatives and decided PHP is the best choice, or the least bad choice, or any other choice. People use PHP because either

    1: It was forced upon them for some reason or

    2: It was the first thing they found and it was good enough

    If that's the case, it's irrelevant how fantastic the alternatives are.

    Also, while PHP code can be truly terrible, people who are determined to write terrible code will do so whatever the tool. You can use almost anything as a hammer if you try hard enough. The myth that The One Right Language somehow makes bad programmers good is still alive, especially within the Python community, but it's stll a myth.

    When good programmers have no choice but to use PHP, they'll find a way to build something that is workmanlike even if it isn't beautiful. When bad programmers program, the result is going to be bad regardless of the language.

  • Re:Really? (Score:5, Insightful)

    by jythie ( 914043 ) on Friday June 29, 2012 @12:57PM (#40495741)
    Actually, I would put the fault on the complainer here....

    Yeah, it sucks when languages and APIs change, but it happens and if one is going to be upgrading one should take such things as a given. This is why, when you have an environment where consistency is important, language and library upgrades are big deals that are scheduled with time allocated them.. otherwise freeze your versions unless there is a compelling reason with significant measurable benefit to upgrading... crow, I still keep VMs around in case I need to go back and work with earlier checkouts with known dependencies/versions.
  • by Anonymous Coward on Friday June 29, 2012 @12:58PM (#40495765)

    Python has *always* been obviously better than PHP (or perl, etc.) But if you have no skills, you look for the easiest path: the goal is to get the project going.

    If your expertise is Perl, climbing the Python learning curve, gentle as it may be, isn't attractive, and becomes less so as your available time to engage in such things narrows. And so your project $sucks @terribly $$ and looks like APL But it works fine because you know how all that perl weirdness operates:


            $_ = shift;
            tr/+/ /;
            s/%(..)/pack('c', hex($1))/eg;
            return($_);

    For a new user with no skills (which really seems to be the primary group that ends up using it), the availability of PHP examples and the ease of putting a canned site up seem to be the primary enticements. Slap a canned site up, and bam, there you are. *Now* you can learn how it works (which accounts of a lot of strange things on the web, but I digress.)

    So better isn't really the issue. Easier is the bottom line, it seems to me. Where are the canned sites in Python? For that matter where are the canned sites in Perl or Ruby or whatever?

    If "better" were all it took, no one would be running Windows, for instance, but that's not the case.

    Mind you... *I'm* not running windows, and I long ago abandoned Perl for Python (and I'm so glad I did), but I'm someone who actually has the time to explore and make choices without someone else hovering over my shoulder or otherwise being compromised. I don't think that's very common.

  • by ggpauly ( 263626 ) on Friday June 29, 2012 @12:58PM (#40495767) Homepage

    The World's Most Misunderstood Programming Language

    http://javascript.crockford.com/javascript.html [crockford.com]

  • Re:Really? (Score:5, Insightful)

    by SolitaryMan ( 538416 ) on Friday June 29, 2012 @01:02PM (#40495847) Homepage Journal

    I honestly don't see how this demonstrates any problem with PHP people.

    The guy was using some function in what appears to me as the wrong way (failed to validate inputs) and was relying on some edge-case behaviour. Now this edge-case behaviour has changed and made the mistake in his code more apparent.

    I hate PHP and try to avoid it like plague, but this guy got what he was asking for.

  • by edremy ( 36408 ) on Friday June 29, 2012 @01:09PM (#40495935) Journal
    It was a wonderous language. It was (for the time) very easy to use, powerful and understandable. Millions of lines of code were written in it because it *worked*.

    Fortran's pretty similar- nobody here is going to hold it up as a language marvel, but it was- it fit the niche of "powerful number processor" very well. Perl is noted for being a complete mess, but if you need a quick script to massage some text nothing is better. BASIC fit into its niche as well, and frankly so does PHP

    None of them were "elegant" in the sense of LISP, Smalltalk or Haskell. How are those doing by the way?

  • Re:Really? (Score:4, Insightful)

    by _xeno_ ( 155264 ) on Friday June 29, 2012 @01:18PM (#40496107) Homepage Journal

    The guy was using some function in what appears to me as the wrong way (failed to validate inputs) and was relying on some edge-case behaviour. Now this edge-case behaviour has changed and made the mistake in his code more apparent.

    One of the things I hate about PHP was the number of times that calling a function with bad data "just works" even though it really shouldn't. (Primarily because it effectively dumps the checking onto you.) That looks like a perfect example - if you try and format a thing that isn't a number, it "works" and returns 0. Huh? That's not right. That should be an error.

    And now, it is! It notices the error, and returns NULL instead of pretending that a string is a number. Great!

    Someone elsewhere in this thread was complaining about mysql_escape_string and mysql_real_escape_string, and how they should have just fixed mysql_escape_string. It sounds like the person filing the bug report would have rather they created a real_number_format function rather than fix a bug in the existing number_format function.

  • by alex67500 ( 1609333 ) on Friday June 29, 2012 @01:19PM (#40496127)

    Ever since programming languages existed, they have been classified in 2 categories:
    - Those every one bitches about,
    - and those nobody uses...

  • Re:Really? (Score:5, Insightful)

    by Anonymous Coward on Friday June 29, 2012 @01:29PM (#40496291)

    But that's a valid fix. PHP has been enforcing basic type constraints on internal functions for years. And before that it was throwing up E_STRICT warnigns (that people ignored).
    So now that these strict warnings are causing issues because of bad coding practices. You should -always- know what type your variable should be in a context -- saying "it could be an empty string, null, uninitialized, or a number" means you have more serious issues in your program logic to address.

  • Re:Really? (Score:5, Insightful)

    by omnichad ( 1198475 ) on Friday June 29, 2012 @01:30PM (#40496309) Homepage

    No, 0 is not NULL. But "" cast as an INT could be considered NULL. It's not an INT. The parameter of 0 means 0 digits after the decimal. Why they don't just round or floor/ceil instead, I don't know. But first things first - you need to pass in a number to format a number.

  • Re:Really? (Score:5, Insightful)

    by 228e2 ( 934443 ) on Friday June 29, 2012 @01:31PM (#40496325)
    Because that what they say they will return. Regardless if you pass in unchecked arguments.

    How can you properly debug code if documented fuctions dont behave in the way documented and acts inconsistantly??
  • Re:Really? (Score:4, Insightful)

    by Qzukk ( 229616 ) on Friday June 29, 2012 @01:35PM (#40496367) Journal

    This is the real solution, because let's face it: not everyone needs a java instance running with -MmmXxWTFBBQMemory 500000000 and 60000 classes to run a forum. People use PHP when they neither need nor want "application servers", they want it to just work.

    Make a mod_pdr (or at least a fastcgi-compatible script executor where nobody has to implement the fastcgi protocol by hand for every single script like python or ruby), and you'll have the attention of the hosting people. They don't want to have to babysit 50000 different users' rails or tomcat instances, so they don't offer them.

  • by billcopc ( 196330 ) <vrillco@yahoo.com> on Friday June 29, 2012 @01:38PM (#40496413) Homepage

    This.

    PHP feels natural for me, as a C guy. The library functions lack consistency, but then neither do 3rd party C libraries. You just learn how to work them and get on with your billable day. I can look at just about any PHP code and figure it out pretty quickly. A lot of it is written by mental midgets, but it is familiar enough that I can jump in and fix whatever needs to be done.

    Meanwhile, all those other, functional languages venture so far off the beaten path as to make them look like gibberish. They often strike me as the product of overexcited college grads. It's like a little kid who just learned a new swear word and starts using it ten times in every sentence. Closures this, aspects that, ooh look ma I'm using list operators... academic functionality makes for cute sample code, but those of us with actual jobs have more pressing things to do than learn a new language and syntax. At the very least, PHP offers a good online manual with some very handy user-contributed snippets. Sure, some of them are ass and could benefit from some karma/moderation system, but I've often found a little 10-line function in those comments that saved me an hour of poking around, or that I could patch up and post my improved version. That right there beats all those "Look how easy RoR is" screencasts that ignore all the actual things programmers need to know to write secure, production-ready code.

  • by defcon-11 ( 2181232 ) on Friday June 29, 2012 @01:50PM (#40496629)
    No, to write good PHP code you have to be both a good coder and a PHP expert, otherwise its inconsistencies and corner cases will bite you in the ass. On the other hand, a good coder can write good code in Python, Ruby, .net, and java, because those languages generally do what you expect them too, and you're not going to accidentally open a massive security flaw by having an incorrect setting in php.ini or forgetting to pass the right parameters into get_file_contents.
  • Re:and (Score:4, Insightful)

    by billcopc ( 196330 ) <vrillco@yahoo.com> on Friday June 29, 2012 @01:50PM (#40496639) Homepage

    Welcome to the club.

    Some of us are getting shit done with PHP. To me, that's all that matters. If all these whiners got together, forked PHP into something cleaner and faster and posted THAT to their shitty blogs, I'd be all over it.

    Programming isn't about having the prettiest language. It's about accomplishing whatever it is you need accomplished, using whichever tool gets you there in the most efficient manner. These "solutions" provided by PHP haters are the equivalent of saying "I'm scared of big trucks, so here's a purple unicycle driven by an albino puppy who can bark the first 400 digits of Pi in reverse", when the problem was "I gotta move 83 tons of unobtainium from here to there by Tuesday".

  • Re:Really? (Score:4, Insightful)

    by iamgnat ( 1015755 ) on Friday June 29, 2012 @01:53PM (#40496671)

    Actually for once I agree with the PHP team here. My biggest complaint with PHP is that many functions give you an arbitrary result when you feed bad data to it rather than return something obvious to show you are trying to do something stupid. In this case the user should be checking to see if the result was NULL and handle the error appropriately rather than happily accepting 0 and not knowing if there was an error or if that was the correct result. Basically he is refusing to validate his input and wanting PHP to do it for him (in a bad way) which is the core of problems like SQL Injection attacks.

    The formatting in DateTime is a perfect example of their absurdity where if you specify 'Y' (4 digit year) in your format but give it a less than 4 digit value (say 12 instead of 2012) it happily makes the assumption that you left out leading zeros (e.g. 12 = 0012). Even better is that if you give a month value greater than 12, it translates that into extra year(s) (int(val/12)) that gets added to the supplied year and then makes the month the remainder (e.g. 19/27/2012 against m/d/Y = 07/27/2013). If I screwed something up, I want to know about it so I can deal with it.

    Then there is the inconsistent error handling functions. Most errors return NULL or false. Of that cross section most don't give you any kind of feedback as to what the error is (though the ones that give you no control and write to STDOUT/ERR really piss me off). The language has Exceptions built in. Use them!!!

    And my personal pet peeve is how it handles the __FILE__ macro if there are symlinks in the path. Contrary to every other language it translates those links so that you can't see the ACTUAL path used to reference the file in question. Even though PHP has functions to translate links in paths the developers continue to claim this is as it should be and refuse to fix it.

  • Re:Really? (Score:5, Insightful)

    by Crudely_Indecent ( 739699 ) on Friday June 29, 2012 @01:54PM (#40496679) Journal

    Just because someone has been successfully writing bad code for years is not a good reason for the maintaners of the language to enable him to write bad code. The changes were available for testing long before the final version was released. He could have spoken up during the RC phase, but he didn't. He should have tested his code against the RC version and started fixing issues in his code before the final release. Instead, he just installed the new release and started bitching.

    Go ahead and send the link. They'll read that bug report and say to themselves "Why was he sending an empty string to number_format? What did he expect?"

    And they will realize that they've been doing it right all along.

  • by Zamphatta ( 1760346 ) on Friday June 29, 2012 @02:24PM (#40497089) Homepage
    Is this modded -1 & "offtopic" because the 1st word is "Python"?!? C'mon mods, at least read the first sentence before spending your mod points. This guy spells out exactly why I got into PHP. It was 1999, and I was struggling for months to write some good PERL scripts. Once I switched to a webhost with PHP, I made things work in less than a month. That's what's RIGHT about PHP for websites. That's why nobody really fixes it even though everybody complains "it's broken".... which is a ridiculous concept, since it gets things done quickly when you have little skills. So PHP should really be talked called "the gateway drug" to more hardcore coding, 'cause that's what it is for most people. If you expect it to be as awesome as Python, C, PERL, Ruby, etc, then you're totally misunderstanding PHP and yes -- you'll see it as broken.
  • by leonbloy ( 812294 ) on Friday June 29, 2012 @02:27PM (#40497139)

    Ever since programming languages existed, they have been classified in 2 categories: - Those every one bitches about, - and those nobody uses...

    Sounds clever, but it's plainly false.

    C, Java, C# are among the most used languages today. Very few serious programmers will say that they are stupid or awful. And, many criticisms aside, most programmers respect them - even love them. I program in all these languages, I like them all, and I hate PHP with passion. It's not an issue of popularity; PHP, its community, its history, all of it, is a tale of terror.

  • Re:Really? (Score:4, Insightful)

    by Raenex ( 947668 ) on Friday June 29, 2012 @02:50PM (#40497469)

    Just because someone has been successfully writing bad code for years is not a good reason for the maintaners of the language to enable him to write bad code.

    This is what happens when you start with a sloppy language. People depend on the sloppy behavior, and if you then decide to become more strict, you break people's code. The right way to do this is deprecate the function and introduce a new one.

    Go ahead and send the link. They'll read that bug report and say to themselves "Why was he sending an empty string to number_format? What did he expect?"

    "We are passing a (possibly uninitialized, or null-valued) variable to the function, in hundreds of places and web pages, and we would not expect such a fundamental function to suddenly return a different result."

    So they were depending on existing behavior. Is this shocking? In a language like PHP?

    He could have spoken up during the RC phase, but he didn't.

    "I get it. Yours is bigger, you've worked better, you are at the cutting edge of everything, and you have infinite resources to test every new version of every piece of software in your stack."

    How many people can honestly say they keep up with alpha or beta releases for software they depend on and provide feedback? I've never worked in such an environment.

    There is one very funny bit in that link, where he asks Rasmus to "escalate" the issue.

  • Re:Really? (Score:4, Insightful)

    by myurr ( 468709 ) on Friday June 29, 2012 @03:09PM (#40497729)

    Yes throwing an error would be better than an inconsistent or, for some developers at least judging by the comments, an illogical result. If the input doesn't make sense then throwing an error is the only sensible way of dealing with it. This will flag the issue to the developer rather than leaving the possibility of an edge case bug sat in the code. But it would appear the PHP devs don't think like that and instead like to preach that their arbitrary way of doing things is better than some other arbitrary way of doing things.

  • Re:Really? (Score:5, Insightful)

    by anonymov ( 1768712 ) on Friday June 29, 2012 @03:17PM (#40497867)

    That's not a good example. You want a good example of PHP core team competence, check this saga about fixing an integer overflow bug [perl.org], for example.

    Or just contemplate about how 20 year old language didn't have the ability to chain method calls and field lookups on objects returned by functions until release 5.4 - it was a _syntax_ error before.

    Or how strings are compared as numbers in unexpected places. I'm not talking about "42" == 42, I'm talking about "42" == "42.0", or "10" == "0xa". Well, using == in PHP is discouraged for reasons like this one anyways (which in itself is quite telling), but check this one out - if we have $x = array('42'), in_array('42.000000000000001', $x) will be true. Can't check this at the moment, but IIRC it's still there in PHP 5.4

    It's bad design through and through. It was OK when it was an hobby project for templating a small homepage, but then it started growing and instead of designing features it got ad-hocs piled on ad-hocs.

  • Very few serious programmers will say that they are stupid or awful.

    Huh? Have you just fallen off the turnip truck?

    C: Unsafe at any speed. Un-bound-checked array, null pointers, etc, etc. Many people HATE C because it's unsafe, though they grudgingly admit that it's sometimes a necessary evil for system programming.

    C++: Overly complex, insane learning curve, no garbage collection. There are no shortage of people who hate C++.

    And Java is possibly your most absurd point. Overly verbose to the extreme, slow, insane memory requirements, slow, crazy libraries, and slow (please don't bother to claim that isn't slow).

  • by ewieling ( 90662 ) <user&devnull,net> on Friday June 29, 2012 @03:40PM (#40498173)
    I hate pointers in C, the lack of regular expressions in C, and string handling in C. I think of PHP as "like C without all the stuff I hate about C". I'm sure language purists will be astonished by that statement. I realize PHP isn't fast, but it seems to be fast enough for the stuff we use it for.
  • I notice that most (not you, obviously) of the PHP defenders are posting as A/C. :)

    There is no doubt that PHP has some deep flaws, but they give you an escape from a lot of the flaws. It's possible to have a reasonable codebase written in PHP if you have good experience in the language.

    The main reason I like PHP is that it's ubiquitous. I learned a long time ago that it SUCKS to work in an unpopular environment, even if it has some sort of theoretical advantage. It's hard to find information, libraries are nonexistent or buggy, programmers are hard to find or expensive, etc, etc.

    As I see it, there are only four viable language if you want to stay mainstream: Java, C++, C# and PHP. If you want to avoid Microsoft, you're down to three. If you hate Java's verbosity, slowness and pain, as I do, you're down to two. And if you want quick productivity and rapid development for entrepreneurial reasons, that eliminates C++ and also eliminates Java again, and that leaves one to rule them all: PHP.

    I don't particularly like PHP. But it does have a lot of modern language features, and it's really easy to get code written and out. And it's reliable, if you put in the work to establish a framework (E_STRICT, turn on exceptions, etc).

    I would love to see a better mainstream language emerge, but PHP just plain wins out for certain purposes. If I was working for a large organization with plenty of time and money, I'd probably pick C++ or Java. But for a small, hungry organization, it's hard to beat PHP, which was forged by necessity. And I wish I could beat it, because it does have some pretty big flaws.

  • by fredrik70 ( 161208 ) on Friday June 29, 2012 @04:48PM (#40499115) Homepage

    indeed , PHP can very much be 'good enough'. Nowadays I prefer other languages, but i struggle to understand the hate towards php. Yeah, it might have some warts, but it has a standard lib that does pretty much al you can ask for and it runs on pretty much all webhosters.

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...