Slashdot Mirror


The PHP Singularity

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.'"

125 of 622 comments (clear)

  1. Recursive? by Anonymous Coward · · Score: 5, Funny

    And now, a post about a post about posts about the awfulness of PHP.

    Which would make these comments posts about a post about a post about posts about the awfulness of PHP.

    ---
    Recursion: First you curse, then you curse again.

    1. Re:Recursive? by arth1 · · Score: 5, Informative

      PHP itself is an acronym for PHP: Hypertext Preprocessor.. But then what does "PHP" stand for?

      It's an old joke, already trite by the time PHP came out.

      GNU = GNU is Not Unix
      Wine = Wine Is Not an Emulator
      PNG = PNG is Not Gif (later backronymed to Portable Network Graphics)
      LAME = LAME Ain't an MP3 Encoder
      VISA = VISA International Service Association

    2. Re:Recursive? by ChunderDownunder · · Score: 2

      Don't give me turtles!

      No, silly, ElePHPants.

    3. Re:Recursive? by bruce_the_loon · · Score: 5, Informative

      PHP was originally Personal Home Page Toolkit, then backronymed into the new meaning.

      --
      Trying to become famous by taking photos. Visit my homepage please.
    4. Re:Recursive? by datavirtue · · Score: 4, Funny

      yo dawg.

      --
      I object to power without constructive purpose. --Spock
    5. Re:Recursive? by Anonymous Coward · · Score: 5, Funny

      BING = BING is not Google.

    6. Re:Recursive? by DdJ · · Score: 2

      Yeah, when I started using it (back before PHP 3.0), it was actually called "PHP/FI", which stood for "personal home page / forms interface".

    7. Re:Recursive? by Jorl17 · · Score: 2

      Wine was originally WINdows Emulator, but they changed it for at least two obvious reasons.

      --
      Have you heard about SoylentNews?
    8. Re:Recursive? by multicoregeneral · · Score: 2

      Can you blame them?

      --
      This signature intentionally left blank.
  2. Really? by Anonymous Coward · · Score: 4, Insightful

    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.

    1. Re:Really? by Anonymous Coward · · Score: 4, Insightful

      The problem lies at its core. You can't fix people.

    2. Re:Really? by Richard_at_work · · Score: 4, Informative

      PHP is well beyond fixing - mysql_escape_string and mysql_real_escape_string prove it, otherwise the first method would have been fixed rather than "replaced".

      The best you can hope for these days is overlaying a framework.

    3. Re:Really? by mfarah · · Score: 5, Interesting

      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.

      An important part of fixing something is being able to recognize when it's better to throw it away and build it again. PHP has so many problems, in each layer down to the bottom, it's way past the "We can fix it if we apply ourselves": it's better to throw it away and build it again. Something like a new scripting language called PDR ("PHP Done Right").

      --
      "Trust me - I know what I'm doing."
      - Sledge Hammer
    4. Re:Really? by JDG1980 · · Score: 3, Informative

      PHP is well beyond fixing - mysql_escape_string and mysql_real_escape_string prove it, otherwise the first method would have been fixed rather than "replaced".

      They had to do it this way for backward compatibility. If they changed the way it works, then any program that relied on the existing (buggy) behavior would break as a result.

    5. Re:Really? by MightyMartian · · Score: 4, Insightful

      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.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    6. Re:Really? by Ghostworks · · Score: 2

      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.

      The unspoken argument here is that the complainers are no longer trying to contribute to PHP by providing feedback. Rather, they have determined that PHP is fundamentally terrible at doing the work it's been recruited to do. Fixing it to be "the best possible wrong tool for the job" would not be productive.

      Because it looks like it should work, you don't have the benefit of understanding that it doesn't until you've wasted your time using it and have probably committed a good deal of your project to it trying to make it work. Hence, most people using it today are less concerned with improving future iterations than they are with killing the damn thing by warning people away from it. Because if nobody uses it, nobody has to support it.

      If this still sounds peculiar to you, remember this is pretty much exactly what happened to kick off the second browser wars. IE sucked, people complained constantly, Microsoft did nothing (because why would they?), and eventually enough talented people were fed up to get the old Mozilla code up to speed.

    7. Re:Really? by Anonymous Coward · · Score: 4, Insightful

      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.

    8. Re:Really? by Richard_at_work · · Score: 4, Insightful

      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.

    9. Re:Really? by Richard_at_work · · Score: 3, Insightful

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

    10. Re:Really? by billcopc · · Score: 5, Insightful

      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...

      --
      -Billco, Fnarg.com
    11. Re:Really? by beelsebob · · Score: 3, Interesting

      Because no amount of polishing turd will make it into gold. PHP has some fundamentally wrong assumptions in its design, you can't fix it without just making it something that isn't PHP.

    12. Re:Really? by Java+Pimp · · Score: 4, Insightful

      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.

      --
      Ascalante: Your bride is over 3,000 years old.
      Kull: She told me she was 19!
    13. Re:Really? by Anonymous Coward · · Score: 5, Insightful

      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.

    14. Re:Really? by jythie · · Score: 5, Insightful

      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.

    15. Re:Really? by wkcole · · Score: 2

      Why contribute to a project that has such a solid record of recklessly incompetent leadership? Why work to prop up an ecosystem that has developed into a vast toxic swamp?

      The advantages of PHP have always been reducible to the fact that it is relatively easy for non-programmers to understand. It's accessible for people who don't have a mindset for or interest in computer science. That's not inherently a bad thing, but it is risky. As with VB before it, it is true that any crazy idiot can code in PHP, so many of them do. The choices made over the years by many in the PHP community (led from the top) to keep it an easy, accessible, and forgiving platform in order to grow rather than improve the community have had predictable results. The debacle of the recent release bungles and the ongoing failure to either obviate Suhosin for 5.4.x or make it work is demonstrative evidence that the guiding spirit of the PHP universe is still one of reckless incompetence.

    16. Re:Really? by SolitaryMan · · Score: 4, Insightful

      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.

      --
      May Peace Prevail On Earth
    17. Re:Really? by Charliemopps · · Score: 2

      0 is not NULL.
      Period.
      It's a bug, the submitter is correct.

    18. Re:Really? by _xeno_ · · Score: 3, Insightful

      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.

      --
      You are in a maze of twisty little relative jumps, all alike.
    19. Re:Really? by PCM2 · · Score: 2

      The advantages of PHP have always been reducible to the fact that it is relatively easy for non-programmers to understand.

      I would add that it's widely available. Pretty much any $4/month hosting plan is going to have PHP available. I'll warrant that this has caused some people to use PHP for Web sites when they might not otherwise have done so.

      --
      Breakfast served all day!
    20. Re:Really? by Anonymous Coward · · Score: 5, Insightful

      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.

    21. Re:Really? by omnichad · · Score: 5, Insightful

      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.

    22. Re:Really? by 228e2 · · Score: 5, Insightful

      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??

      --
      Since when does being a Socialist mean 'someone who has a different opinion than me'?
    23. Re:Really? by Qzukk · · Score: 3, Insightful

      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.

      --
      If I have been able to see further than others, it is because I bought a pair of binoculars.
    24. Re:Really? by eddy+the+lip · · Score: 2

      We already have fixed versions of PHP the language. They're called Python and Ruby.

      We just need to work on the deployment.

      This is exactly it. I write nearly all my code in PHP, and it is not for a love of the language. I switched to PHP from perl (after taking a good, long (and longing) look at python) for two simple reasons:

      • * it was deployed everywhere
      • * enough of the basics were included that I didn't need to worry about whether a database library would be on the server, or some form of image manipulation, etc. There is too much crap in PHP, but at least I don't have to spend weeks convincing some sysadmin that, yes, I really do need to query a db, and would you please compile the extension?

      It pains me to no end that my bread and butter is made with a language I don't particularly care for, but in the end, I can at least get things done with it.

      --

      This is the voice of World Control. I bring you Peace.

    25. Re:Really? by Cow+Jones · · Score: 2

      Actually, I would put the fault on the complainer here....

      So would I.
      I especially like how he asked Rasmus Lerdorf to "escalate this bug to someone"...

      CJ

      --

      Ah, arrogance and stupidity, all in the same package. How efficient of you. -- Londo Mollari
    26. Re:Really? by iamgnat · · Score: 4, Insightful

      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.

    27. Re:Really? by Crudely_Indecent · · Score: 4, Insightful

      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.

      --


      "Lame" - Galaxar
    28. Re:Really? by billcopc · · Score: 2

      I knew an admin who'd work on PHP for doing his server maintenance. He hated PHP on web based applications. You kinda remind me of him.

      Yep, I do that too. Most of the time, when I need a small bullshit script for something, it's PHP. The DB integration and no-brainer multi-dimensional arrays make it way too easy to do so many things. I even wrote a bunch of MAME tools with it, because it was the easiest language for quickly parsing ROM parent relationships into a tree and running various operations on the archives with the same fine-grained control as C, but the immediacy and simplicity of shell scripts.

      --
      -Billco, Fnarg.com
    29. Re:Really? by Crudely_Indecent · · Score: 2

      The PHP manual doesn't say that it will return 0, it says that it will return a formatted version of the $number input. When that input variable isn't a float as the function expects, exactly what is the function supposed to return?

      http://us2.php.net/manual/en/function.number-format.php
      string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )

      Maybe it should cause a fatal error because the input did not meet the criteria, would that be better?

      --


      "Lame" - Galaxar
    30. Re:Really? by shutdown+-p+now · · Score: 2

      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).

      Who's forcing "functional programming hipster crap" down your throat in Python? Have you even tried coding in it?

    31. Re:Really? by NonUniqueNickname · · Score: 2

      Fork?

      Fork You!

    32. Re:Really? by TheLink · · Score: 2

      In SQL null for numbers is NULL.

      In other areas, null for numbers might be NaN: http://en.wikipedia.org/wiki/NaN

      --
    33. Re:Really? by Raenex · · Score: 3, Insightful

      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.

    34. Re:Really? by Golthur · · Score: 3, Informative

      Maybe it should cause a fatal error because the input did not meet the criteria, would that be better?

      Yes, it would be. Silently failing is one of PHP's most common and egregious sins. I'd rather it fail and fail loudly, so bugs like this can get fixed during development.

      --
      Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
    35. Re:Really? by Grishnakh · · Score: 2

      This is a very important point that all the elitists here keep forgetting about. Want to set up a small, low-volume website on the cheap? There's a ton of less-than $5/month shared hosting providers out there, and all they seem to support are Perl and PHP, so PHP is the choice by default. I keep seeing posts here saying "use Python!", but I don't see much support for Python in the cheap hosting providers, let alone Java.

    36. Re:Really? by myurr · · Score: 3, Insightful

      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.

    37. Re:Really? by anonymov · · Score: 4, Insightful

      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, 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.

    38. Re:Really? by allo · · Score: 2

      but it should only happen automatic, when the input is sane.

    39. Re:Really? by eddy+the+lip · · Score: 2

      When you admin the server, this is great. I usually do these days, but do still occasionally deploy on shared servers, or servers that are severely locked down. Sure, it's kind of a bullshit restriction, but it's one of the reasons a poor, but ubiquitous, technology sometimes wins out.

      As an aside, we were recently approached by a large organization to redevelop their website. One of the things they want is to move away from Ruby on Rails because they were having too hard a time finding qualified developers. I know - you can find them - but when you are a non-tech company making these kinds of decisions, you do want to make sure you can find qualified devs without *too* much fuss.

      I guess just a point in the "not about the technology" department :/

      --

      This is the voice of World Control. I bring you Peace.

    40. Re:Really? by fbartho · · Score: 2

      Got any links? I thought that Facebook's PHP was just a different compiler with the same, but faster, library stack?

      --
      Gravity Sucks
    41. Re:Really? by Crudely_Indecent · · Score: 2

      PHP is well documented. in another reply, I provided a link to the number_format function.

      it expects a float, not a null or a string. the documentation is very clear.

      --


      "Lame" - Galaxar
    42. Re:Really? by radio4fan · · Score: 2

      Silently failing is one of PHP's most common and egregious sins.

      It doesn't silently fail. It generates a warning:

      Warning: number_format() expects parameter 1 to be double, string given in /foo/bar/baz.php on line X

      I'd rather it fail and fail loudly, so bugs like this can get fixed during development.

      Which is why you don't disable warnings.

      Maybe you want php to treat warnings as errors? No problem:

      set_error_handler().

  3. if php is broken what is javascript? by Anonymous Coward · · Score: 4, Interesting

    if php is broken what is javascript?

    1. Re:if php is broken what is javascript? by Ziest · · Score: 3, Insightful

      if php is broken what is javascript?

      A disaster.

      --
      Another day closer to redwood heaven
    2. Re:if php is broken what is javascript? by Anonymous Coward · · Score: 2, Funny

      Client-side misery.

    3. Re:if php is broken what is javascript? by ggpauly · · Score: 3, Insightful

      The World's Most Misunderstood Programming Language

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

      --
      Verbum caro factum est
    4. Re:if php is broken what is javascript? by Korin43 · · Score: 2

      if php is broken what is javascript?

      Still better than PHP?

    5. Re:if php is broken what is javascript? by canadiannomad · · Score: 2

      The World's Most Misunderstood Programming Language

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

      I strongly agree with this. Most people who complain about JavaScript never fully learned it, and hate the DOM (the DOM isn't really JavaScripts fault)
      I've been working with Node.js for a while, and love it compared to PHP. It's faster too, and my code can run client or serverside depending on the needs/abilities of the browser, bonus!

      --
      Hmm, the humour and sarcasm seem to have been be lost on you.
    6. Re:if php is broken what is javascript? by VGPowerlord · · Score: 3, Interesting

      if php is broken what is javascript?

      If you've ever played Secret of Monkey Island, look at the poster of the woman near the bar.

      "When there's only one candidate, there's only one choice."

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    7. Re:if php is broken what is javascript? by shutdown+-p+now · · Score: 2

      If you're doing a crazy dance with the global namespace, you are doing it wrong. Function scope works if you understand it.

      Using a lambda that is called immediately just to create a new scope is a hack, plain and simple.

      It isn't C, stop comparing it to C, really has nothing to do with C.

      I'm not comparing it with C. I'm comparing it with every other language out there that has the same features. They all do it the same way, except for JS.

      For example, the only language that has similarly stupid scoping rules (where the scope of any local is the entire function, even if it's declared inside a nested block) for locals as JS is VB6. But at least VB6 didn't have closures!

      Why are you leaving out semicolons, that is bad practice

      You miss the point. I'm not leaving out semicolons, I like them where I put them. The problem with JS is that it will silently and automatically put semicolons in certain places where it thinks that I've missed one, where I actually did not. The most common example is:

      return
      {
        foo: "bar";
      };

      It'll insert a semicolon after "return", even though I don't want it there. Again, it's the only curly braces language that does anything like that.

  4. and by Anonymous Coward · · Score: 3, Insightful

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

    1. Re:and by billcopc · · Score: 3, Insightful

      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".

      --
      -Billco, Fnarg.com
  5. Perhaps it is not broken and horrible by Anonymous Coward · · Score: 4, Insightful

    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.

    1. Re:Perhaps it is not broken and horrible by Anonymous Coward · · Score: 3, Informative

      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 might be misinterpreting you here, but this sounds like a point responsed to in PHP: A Fractal of Bad Design:-

      Do not tell me that "good developers can write good code in any language", or bad developers blah blah. That doesn't mean anything. A good carpenter can drive in a nail with either a rock or a hammer, but how many carpenters do you see bashing stuff with rocks? Part of what makes a good developer is the ability to choose the tools that work best.

      You also said:-

      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.

      I also think the problem a lot of people have with PHP is its inconsistent and illogical bad design, which isn't the same thing as flexibility. I don't think having a logically designed language necessarily means one that forces its philosophy on you. I'll note that the fractal post referenced above also states that:-

      I assert that the following qualities are important for making a language productive and useful, and PHP violates them with wild abandon. If you canâ(TM)t agree that these are crucial, well, I canâ(TM)t imagine how weâ(TM)ll ever agree on much.

      * A language must be predictable. Itâ(TM)s a medium for expressing human ideas and having a computer execute them, so itâ(TM)s critical that a humanâ(TM)s understanding of a program actually be correct.

      * A language must be consistent. Similar things should look similar, different things different. Knowing part of the language should aid in learning and understanding the rest.

      * A language must be concise. New languages exist to reduce the boilerplate inherent in old languages. (We could all write machine code.) A language must thus strive to avoid introducing new boilerplate of its own.

      * A language must be reliable. Languages are tools for solving problems; they should minimize any new problems they introduce. Any âoegotchasâ are massive distractions.

      * A language must be debuggable. When something goes wrong, the programmer has to fix it, and we need all the help we can get.
       

      (Apologies for the cut-and-paste splotches, but I don't have time to fix them right now)

    2. Re:Perhaps it is not broken and horrible by Jesus_666 · · Score: 2

      PHP is a screwed-up language. However, it's a screwed-up language that is very easy to get into. It's the Basic of web development languages. In order to compete, your language must be more straightforward than Basic - at least as far as beginners are concerned. While frameworks like Django or Rails are very nice and automate a lot of stuff, they are much more complex than "write 'echo $bar' to output some text". That's why PHP has such a solid grasp of the beginners' market: One file with three lines (two of which are boilerplate) is all you need to get a working Hello World implementation and it's obvious how to progress from there. "One file, one script" is messy but easy to get started with.

      And, of course, other languages are not free from utter nonsense, either. For instance, Python can convert base-n numerical strings (with 1 <= n <= 36) to integers but it can only convert integers to numerical strings of the bases 2, 8, 10 and 16. Why? Nobody knows. Of course Python doesn't get anywhere near PHP's level of idiosyncrasy but the combination of "unlike PHP, $LANGUAGE is consistent"-type rhethoric and inconsistencies in the language does turn one off when trying to move away from PHP. (Although in my case it was just a small part of a general incompatibility between me and Python; I seem to mesh better with Ruby, though.)

      Before someone asks why I needed to generate arbitrary-base numeric strings: Legacy interfaces.

      (I'd also like to mention that PHP is debuggable with a third-party extension. If third-party extensions don't count then Python and Ruby aren't web languages; neither Django nor Rails are part of the default package. In fact, AFAICT Python and Ruby also require third-party packages for remote debugging support.)

      --
      USE HOT GRITS WITH STATUE OF NATALIE PORTMAN (NAKED AND PETRIFIED)
  6. Re:Fix? I think you mean, "migrate" by JDG1980 · · Score: 3, Interesting

    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.

    None of these languages use standard C-style syntax. That syntax is one of several reasons why PHP is so ubiquitous: any reasonably competent C/C++/Java programmer can adapt to it quickly.

  7. Good programmer = good PHP code by Anonymous Coward · · Score: 4, Insightful

    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

    1. Re:Good programmer = good PHP code by hugortega · · Score: 2

      ... and that's true for ANY other language. The main problem is about bad developers, not bad languages.

    2. Re:Good programmer = good PHP code by defcon-11 · · Score: 4, Insightful

      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.

  8. Obligitory by ArhcAngel · · Score: 2, Insightful
    --
    "A person is smart. People are dumb, panicky dangerous animals and you know it." - K
  9. PHP has only its members to blame by mlwmohawk · · Score: 4, Interesting

    Years ago I was involved with PHP, and the core developers have no real interest in making anything better, or, more specifically, accepting any criticism. I'm not the only developer to be pissed off when decisions are made "off line" and passed down. There was no sense of community. In conversations with other would be contributors, the general consensus was the PHP was headed up by a bunch of pissy children.

    Don't get me wrong, I think PHP is a powerful environment and a lot of things have been done with it, but it suffers from a lack of rigour. If they could decide *what* the hell the language wanted to be, that would be helpful. If they could clean up the extensions API that would be helpful too. PHP's extensions are so powerful but there is no abstraction, your extension is essentially a PHP internal module.

    All in all, PHP has had power and potential for years, but the reason why ruby even had a shot was that the PHP project can't get its act together to address, or even acknowledge, its short comings.

  10. PHP alternatives by Compaqt · · Score: 5, Interesting

    The one big redeeming feature of PHP is you set up a single DB server (or even multimaster) plus multiple webservers, and bam! You're sharing objects/sessions among the webservers. Doesn't matter what webserver the next request hits, the session's there.

    By contrast, that simple thing is something that other environments struggle with. I remember ads for "Share Java POJOs" as if that was a huge deal, and the CEO of some firm that did that said people told him that was a godsend. I'd imagine it's the same for Python and Ruby.

    1. Java. Huge memory footprint. Admins hate it because it doesn't conform to certain Unix conventions.

    Try this: Download any one of a number of open-source Java CMSs or ERM systems. Then watch the Java exceptions flow down your console screen. Good luck figuring them out. Static analysis rules, except when it doesn't.

    Java's great if you're writing an desktop app for geologists trying to find oil or a backend bank system. For your average, ho-hum, billion-dollar website: not so much.

    2. Ruby: You go to war with the webserver they give you, not the one you want.

    3. Python: Great language and library. A shame it was hobbled by the whitespace issue, which meant that some programmers didn't check it out who should have. Anyway, it's hard for Beta to get traction against VHS.

    Anotherwords, PHP is good enough. "Worse is better."

    Since the three environments above are monolithic, if there's a problem, it's a problem for every client logged in. PHP, by contrast, follows a Unix minimalist philosophy: if a PHP FCGI instance (or even an Apache mod_php instance) crashes, it's just that one instance. No problem, user hits F5, reloads, PHP's stateless, you get the session back, keep calm and carry on.

    When Marc Zuckerberg or a number of other entrepreneurs started hacking out Facebook, they started out with PHP, just because it's light and fast, and easy to get something up on the wall. Nobody cares about the elegance of Python or Ruby, it's all about time to market.

    Finally, nothing about "you can't debug PHP", in today's discussion, please. You can very well step through PHP code. Use Netbeans and something like xdebug. Or Eclipse.

    PHP: Paraphrasing Churchill, it's bad, but the alternatives are worse.

    --
    I'm not a lawyer, but I play one on the Internet. Blog
    1. Re:PHP alternatives by codepunk · · Score: 3, Insightful

      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.

      --


      Got Code?
    2. Re:PHP alternatives by phantomfive · · Score: 2

      I think you've basically made his point. PHP is painful, but it sticks around because of the difficulties in the alternatives.

      He is trying to say that improving the alternatives is easier than fixing PHP.

      --
      "First they came for the slanderers and i said nothing."
    3. Re:PHP alternatives by DiegoBravo · · Score: 2

      Java, Ruby, Python... Perl... none of these were invented for serving dynamic web pages. PHP did.

    4. Re:PHP alternatives by gbjbaanb · · Score: 2

      amen to this - the reason (listen up other language guys) is that it's just there, ready to go. Want to write an app, just drop a php file in a directory on your webserver and ... well, that's it.

      PHP is like the old personal computers of yesteryear, the ones that booted into a BASIC prompt.

      My experiences with Ruby and Python have been quite less than satisfactory, ruby required a hell of a lot of hassle to get going, installing passenger, making a symlink in the apache vhost directory to the ruby code files, setting up the right directives, finding various cutting-edge gems that weren't in any repository and then I couldn't really do much in the way of debugging.

      Python was the same - first I had to install the correct version for the app I was working with, then play hunt-the-eggs.

      The whole reason PHP is so popular is because it is the only real "just works" environment. If anything, all the other languages need to understand this - its not the language syntax (they all have niggles) or the performance (the other script ones are just as bad, the JIT ones suck up resources), its the ease of getting it going.

    5. Re:PHP alternatives by Reality+Master+101 · · Score: 3, Insightful

      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.

      --
      Sometimes it's best to just let stupid people be stupid.
  11. Re:Good things about PHP by wonkey_monkey · · Score: 3, Insightful

    In what way does it "live in the browser"?

    --
    systemd is Roko's Basilisk.
  12. Thats it! I am leaving by Billly+Gates · · Score: 5, Funny

    Going to Perl where I can get a simple concise syntax that is always the same among different programmers and does not have any idiosyncracies and enforced consitancy everywhere.

    1. Re:Thats it! I am leaving by ParaBug · · Score: 2

      Switching to Perl would be perfect in a single developer environment. I could reuse a lot of my work. The problem is that with almost all the teams I have worked with, either as an internal or as a consultant, the only person speaking fluently Perl was me. I would appreciate to hear what others have experienced (and I'm even willing to relocate ;) ) if I'm wrong. In web agencies, newly graduated and 2-5 years experienced developers mostly do not know Perl and are not even interested in it. I had more chance with IT guys, or anyone really working with *nix systems (not 5 minute Ubuntu install clowns). Maybe Ruby On Rails would be a better alternative to get more additional team members interested?

      --
      ParaBug
  13. Lousy Developers by KalvinB · · Score: 2

    If PHP were as awful as the author claims, "Some fine, even historic work has been done in PHP" would not be possible.

    Coders without the most basic grasp of object oriented designed, initial variable initialization, white-space use, code flow, etc are the problem. Languages that try to force coders to not be retarded are not the answer. It's very easy to spot coders you should never hire if they use a language that lets them reveal their ignorance and lack of organization skills.

    It's far easier to modernize code while maintaining the same core language than it is to completely start from scratch with a new language.

    While PHP's OO functionality is pretty lousy up until 5.3 when it finally got late static binding, it is perfectly sufficient and no excuse for crappy spaghetti code.

    1. Re:Lousy Developers by MightyMartian · · Score: 2

      Millions of lines of fine, historic code were written in COBOL, but I don't exactly here anyone declaring it a wondrous language.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    2. Re:Lousy Developers by edremy · · Score: 3, Insightful
      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?

      --
      "Seven Deadly Sins? I thought it was a to-do list!"
  14. Source of PHP programmers by EmperorOfCanada · · Score: 5, Insightful

    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.

  15. Missing the forest for the trees by Angst+Badger · · Score: 5, Insightful

    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.

    --
    Proud member of the Weirdo-American community.
    1. Re:Missing the forest for the trees by gbjbaanb · · Score: 3, Interesting

      so PHP is like English with its mess of irregular verbs and pronouns. I guess the 'best' language is Smalltalk... the Latin of the computing world.

    2. Re:Missing the forest for the trees by Anonymous Coward · · Score: 2, Informative

      Programming tastes evolve over time. At one point, and for at least a few years, I believed Python was the one true language revealed mystically to GVR. Up until that point, I'd done most programming in C++, so you can imagine how much fun Python was, in comparison. After further development and discovery of other programming languages, the shortcomings of Python have become obnoxious, much like torturing someone by dripping water on their forehead incessantly. Part of the problem is that I have to use Python for my professional work now. Using a language for your day job is a sure way to reveal all the issues.

      Here's what rubs me raw day-in and day-out:

      1. Lack of immutable/persistent data structures. 2. Lack of multi-line anonymous functions/lambda. 3. Variable scoping fail, causing hacks like the new `nonlocal` keyword. 4. worst_possible_variable_name_convention. 5. Python evangelism. (community issue, mostly) 6. Hypocritical "explicit is better" and "flat over nested" values with insane amounts of magic built into language and class system. 7. No switch. 8. GIL. (Actually the CPython runtime in general) 9. No macros. 10. the insane way "unicode" is supported. 11. and on and on...

      At this point I write Python code, but not generally by choice. Mostly my coworkers can't even imagine writing code in another language, given that we have been allowed to choose our implementation language(s) as a team.

    3. Re:Missing the forest for the trees by shutdown+-p+now · · Score: 2

      The problem with PHP is that it's not "one awkward feature", it's literally half the language. All other mainstream languages have their awkward sides, but they either have significantly less (like, say, Python), or they have something to compensate for it (like, say, C++).

      In "PHP: A Fractal of Bad Design", the author compares using PHP with using a rock to drive nails in, and that comparison is very accurate. We can argue about the precise shape of the hammer, and how minor changes in the grip may have profound effects on productivity. But no-one can seriously defend a rock as a viable way of handling nails. If it's literally the only thing you've got, then sure, but that's not the case anymore, and hasn't been for years.

    4. Re:Missing the forest for the trees by narcc · · Score: 2

      Why the hell would you expect the strings to be converted to some number though, when both operands are strings?

      Because that's the documented behavior

      If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically. These rules also apply to the switch statement. The type conversion does not take place when the comparison is === or !== as this involves comparing the type as well as the value.

      Sorry, I don't understand what the problem is here? It's like complaining that the ^ operator in C is used for XOR when it's used for exponents in other languages or that = does assignment instead of a comparison in one language when it does both in other languages depending on context.

      If you don't want a straight string comparison instead, you need to use a different operator (===). The complaint is equivalent to "I don't like this operator, I want to use the other one!" with the justification being "I don't understand how it comes up with 1000 from that crazy 1e3"

      That's why I don't think the article is very good. it's not well thought out, virtually none of his complaints are supported/justified and when they are (he tries to justify his complaint), they don't show any real problem with the language other than "I don't like it" and sometimes "I don't understand it". Using the same standard he does, you could write a rant of similar-length about nearly every programming language.

      To someone who isn't convinced, it's just not convincing. I would really recommend you find a better article that criticizes PHP. I can try to find one for you if you'd like.

  16. Re:Fix? I think you mean, "migrate" by ewieling · · Score: 5, Insightful

    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.

    --
    I really shouldn't have used someone else's email address for this account.
  17. Languages don't make bad code, programmers do by melonman · · Score: 5, Insightful

    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.

    --
    Virtually serving coffee
  18. It's always been obvious by Anonymous Coward · · Score: 4, Insightful

    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.

    1. Re:It's always been obvious by Zamphatta · · Score: 5, Insightful

      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.

    2. Re:It's always been obvious by fredrik70 · · Score: 3, Insightful

      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.

      --
      if (!signature) { throw std::runtime_error("No sig!"); }
    3. Re:It's always been obvious by bandy · · Score: 4, Funny

      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

      This is how I can tell that you're not an APL programmer. APL programs are beautiful. Perl looks as if your mom picked up the phone while you were using a BBS.

      --
      "You might as well get your son a ticket to hell as give him a five string banjo." -unknown minister
    4. Re:It's always been obvious by kryptKnight · · Score: 2

      It's modded off topic because it replied to the FP for visibility even though the parent has fuck all to do with Python or anything even related to the off topic post you're championing.

      --
      Facts do not cease to exist because they are ignored. -Aldous Huxley
    5. Re:It's always been obvious by mcrbids · · Score: 2

      For all the stuff that PHP gets wrong, it gets getting started right. It's fostering a virtual fountain of startups, written by tech-oriented people who have an idea and are looking to get the ball rolling as easily as possible. Take a look at the PHP ecosystem, you'll see this happening everywhere. It's why some of the biggest companies around (Facebook? Yahoo?) use it - it gets you going quickly, is well documented, works reliably, has a fairly simple syntax that beginners and fresh graduates can understand immediately, and is available E.V.E.R.Y .W.H.E.R.E....

      Knock it because it's not pedantic enough? It's OO is limited, it's API is randomly_underscored, needle/haystack ordering in functions is random, slow as a fat dog compared to c/java... Well, sure, that's popular, and as one of those tech-oriented people who built a million dollar company with a PHP-based product, I'd agree with you on every single point!

      But it still works, works well, and it was exactly what I needed when I started up, and, especially at first, it's more important to make your idea work than it is to be elegant.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    6. Re:It's always been obvious by kestasjk · · Score: 2

      Python has *always* been obviously better than PHP (or perl, etc.)

      Article author: I know right? I mean PHP is like a toolbox .. with a hammer .. that has no hammer on it .. and the nails are made of wood!


      Meanwhile: PHP coder: *design design* *code code* Hey look, it's Facebook / Wikipedia / phpBB / phpMyAdmin / WordPress / Drupal / etc / etc !

      PHP coder: Nice work Zend, now we've got namespaces, anonymous functions, traits, magic quotes are deprecated, there's a new version of the Zend Framework! Your platform isn't perfect, but I like where it's going and I don't need a perfect platform to write solid code.

      --
      // MD_Update(&m,buf,j);
    7. Re:It's always been obvious by dbIII · · Score: 2

      The only people who have a problem with php

      There are other people - those that are pissed off finding some loser has cut and pasted some PHP script full of holes that should never have been there in the first place, and then to fix other people's work they have to learn enough PHP to change the thing to use the new version that is not full of holes. I suppose we hate the older versions of PHP, but mostly the clowns that used it without understanding how and those that copied them without understanding.

  19. Bad compared to what? by Shag · · Score: 2

    PHP may feel bad compared to currently-popular languages like Ruby and Python, but consider what it was an alternative to when it first came out: ASP and ColdFusion. Can anyone who worked in either of those honestly say that PHP is as bad, let alone worse? I certainly found it less awful than CF for web dev (and that's speaking as someone who'd been getting paid to program since before there was a web).

    --
    Village idiot in some extremely smart villages.
  20. Re:Good things about PHP by hey · · Score: 2

    mod_php the Apache module.

  21. The problem... by jemenake · · Score: 2

    Seems to me that the problem is that people outgrow what PHP can do for them, partly lured by PHP's own efforts to offer more than what it should do for them... but, even though they've outgrown it, they stick with it.

    When it came out, it was really handy for throwing in some server-side functionality into your HTML. Unlike Perl, where you'd have to have print statements all over the place, or load templates and replace keywords, PHP let you just in-line your functions with your HTML. (Sure, there were earlier solutions like this, like ASP but... ew!). So, it's a great first web-development language... like BASIC was for PC programming. Like BASIC, the problem came when you never realized that it was time to "leave the nest" and move on to something more rugged, J2EE, AJAX, .NET, take your pick of oodles of alternatives. Instead, people just kept asking that PHP be extended to do a bunch of kooky crap that it never was meant to do.

    So, to address the original post, there's kinda no hope in trying to fix what's messed up with it, because there's *way* too big of an installed base... and most of what's messed up about it is that people are using it for larger projects than they should be.

  22. Re:Major Flaw in PHP versus Perl by rev0lt · · Score: 2

    It is a stateless scripted language. Everything in the execution path can cause a denial-of-service. A typical example is the piss-poor search implementations in many many PHP sites - they fetch the limit-less dataset (regardless of size) and then they page it. Throw in a couple hundred searches like that, and you'll see the database server and the webserver crawling.
    Other examples include "heavy" functions (such as regular expressions, file operations, etc), or even framework initialization - try accessing a non-existing page with a SEO-friendly url, and they will try to match it with all the router's rules.
    Or, you know, just do some plain ol' HTTP requests to dynamic-generated pages from a fast pipe, and you'll have the same effect.

  23. The next step is Groovy? by i_ate_god · · Score: 2

    As much as I like python, Groovy seems like the logical next step.

    It's dynamically typed, it has a similar syntax, it can be procedural and oop, it has access to 99% of the java ecosystem. The learning curve from PHP to Groovy is much smaller than python I'd imagine.

    Just replace Zend Framework/Symphony with Swing, Apache HTTPD with Apache Tomcat, remove $ from variable names, and while "this" may not be required, it certainly makes code easier to read and is more in line with php, and replace -> with a period.

    Voila... the post-php world has arrived. With a language that has more similarities syntax-wise with Javascript, the flexibility of PHP with the option to be as strict as Java, and access to a wealth of superb libraries.

    --
    I'm god, but it's a bit of a drag really...
    1. Re:The next step is Groovy? by Lennie · · Score: 2

      Most PHP-programmers wouldn't touch Java with a stick. Java has to many properties of what PHP programmers consider bad.

      --
      New things are always on the horizon
  24. Re:Recursive? No, very iterative. by alex67500 · · Score: 5, Insightful

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

  25. Re:Fix? I think you mean, "migrate" by billcopc · · Score: 5, Insightful

    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.

    --
    -Billco, Fnarg.com
  26. Re:Recursive? No, very iterative. by Dan667 · · Score: 2

    people don't complain about things they don't care about.

  27. Re:All Code will eventually be "Awful". Stop Whini by shutdown+-p+now · · Score: 2

    If you don't understand why Classic ASP (or rather VBScript) is awful, you're simply not qualified to judge PHP. Nonetheless, please read the article linked from my sig; it explains in details why PHP - the language itself, and its standard library - is awful on its own merits, regardless of who writes code in it and how they do that.

  28. Re:Recursive? No, very iterative. by leonbloy · · Score: 5, Insightful

    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.

  29. "1" == "true" by slick_rick · · Score: 2

    Or at least it does in PHP 5.2, but in 5.3, not so much. There have been many of these little idiosyncrasies over the years, enough that my company moved our core product to Java long ago. Stupid stuff like that makes it impossible to upgrade the PHP version without major QA and developer time to address all the new "fixes" the PHP folks decided to introduce in the latest minor release. Meanwhile, my C and Java code from 2001 still runs just fine. That said, when I am coding something for fun, not for profit, I usually end up with PHP on the server side. PHP is coded by amateurs for amateurs. Keep it far and away from any critical systems and it can actually be kinda fun.

    --
    apt-get install redhat please god - Me (take it easy, I love Debian)
  30. Re:I am a PHP user by DrVomact · · Score: 3, Interesting

    I am one of those "stupid" PHP users. It's not the first language I learned, nor is it the last. I'm well aware of Python as an alternative for developing web apps, and I've tried it, but I really do prefer PHP.

    One reason is flexibility in flow control. PHP has do ... while loops. Also, I can do "continue 2" or "break 2" if there is a loop within a loop, to continue or break at the outer loop. I'm honestly puzzled that Python still hasn't added these obvious and useful things.

    I've asked Python types about this, and gotten reasons like "you shouldn't be doing that in the first place," which pisses me off and makes me want to stick with PHP even more.

    I'm going to tell you what you don't want to hear, and I'm going to tell you because it's true: you shouldn't be doing that. The reasons why you shouldn't be doing that have nothing to do with any one programming language, they are general to all programming languages. They are the same as the reasons why you shouldn't have GOTO statements, and these things were learned near the very beginnings of the study of programming as a discipline.

    There are far too many people who equate the invention of new programming language with "progress". It ain't so. That being said, it's probably possible for a good programmer to write good code in any language. (I say "probably" because I don't know all the languages, including PHP.) However, not all programmers are equally good, so it might be wise to stick to languages that won't let you commit atrocities.

    --
    Great men are almost always bad men--Lord Acton's Corollary
  31. Re:PHP is not that bad, really! by ChronoFish · · Score: 2

    Yup.

    I've been programming in PHP for 11 years - after coming from a C/C++ for 6. What I've found is that there are three types of people who despise PHP.

    1. Those who love Perl (Python, Ruby)
    PHP is too verbose and doesn't allows the same shortcuts that Perl, Python, and Ruby allow. This is viewed as a weakness of the language. Ruby is essentially a rebirth of Perl, and was a god-send for those Perl developer who found themselves "stuck" with PHP. I personally don't like implicit references or compacting code for the sake of compacting code. I much prefer to write and read code that verbose and easy to understand. And while you CAN write Perl code that is easy to read, the bulk of tends to read more like a RegEx or Awk expression.

    2. Those who love Java (C/C++)
    PHP's typelessness drives Java developers crazy. To a Java Developer OO is all about creating new data types, and locking down how those types can be passed. In PHP OO is all about begin blind to the data and not caring how the data is structured. A PHP developer would suffer under the size and restrictions of Java. Java developers hate the openness and ease of begin burned.

    3. Those who love VB / C#
    MS doesn't support PHP so there is no desire to learn it. VB/C# guys don't get why you wouldn't want to keep your OS up-to-date with the latest .net infrastructure (Sure my code is cross-platform it works on Window XP, Windows 7, and Window 8 server!). PHP guys don't know why you should have to install .Net just to get a basic app running (You mean you have to run this code on a Windows box?).

    -CF

  32. Re:Recursive? No, very iterative. by Reality+Master+101 · · Score: 4, Insightful

    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).

    --
    Sometimes it's best to just let stupid people be stupid.
  33. Re:Cheap web hosting with SSL and non-PHP? by tepples · · Score: 2

    Then allow me to rephrase it in a non-spam way: People use PHP because hosting with PHP is cheaper than hosting with languages other than PHP.

  34. PHP - python by Garble+Snarky · · Score: 2

    I've been using PHP for years, and not two days ago I decided it's probably worth learning python and switching to that for server-side scripts. I got a python cgi script working in about 10 minutes. Then, I just wanted to be able to run python scripts from arbitrary locations on my site. Looking into that, I could not find a single explanation or tutorial website to help me out. Is that just not how python works? Can anyone point me to some resources that will help an amateur familiar with PHP, learn to completely replace PHP with python, on a commercially hosted webserver?

  35. Re:Fix? I think you mean, "migrate" by ewieling · · Score: 3, Insightful

    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 really shouldn't have used someone else's email address for this account.
  36. If PHP is broken, then what is Java? by Anonymous Coward · · Score: 2, Interesting

    PHP is a garden of paradise compared to Java, which has three or four thread models (Android has another couple), at least four layers of I/O (original streams, better streams, and two NIOs), multiple GUIs (AWT, Swing, and all the third pary stuff which fixes Swing's glaring deficiencies that make it useless), and so on. Not to mention the steaming pile of web overengineering which includes JSP, JSTL, EL, and so on as part of J2EE, plus all the third party stuff like Struts and Hibernate. Struts has two incompatible versions (one works with Java Faces, which is like an overengineered JSP) and Hibernate changes all the time. If you like MVC, I have lost count of the MVCs available. If you just want to overengineer for the heck of it, you can use Spring AND Hibernate at the same time. It's like wearing a belt AND suspenders.

    Compared to this, PHP is a sane and rational alternative for web developers.

  37. Re:The problem, of course, is people by Again · · Score: 2

    There's a subset of self- absorbed, arrogant twits that believe that if a programming language is "too simple," it's just wrong and You. Just. Don't. Understand. REAL. Programming! I tend to filter them out as noise and recommend you do the same.

    Yeah, you're right. I hate PHP because exceptions like "Unexpected T_PAAMAYIM_NEKUDOTAYIM" are just too simple. Or how about this line of code: if(new stdClass() instanceof get_class(new stdClass()).... Just try it. Or how about this error message: "Fatal error: Exception thrown without a stack frame in Unknown on line 0". Why not just stick to the classic message: "lol error".

    PHP is full of these weird errors, odd behaviours and inconsistency and you have the nerve to say that programmers are complaining about it being too simple.

  38. Re:Recursive? No, very iterative. by hobarrera · · Score: 4, Funny

    C is so awful that nowbody would dare use it for any serious stuff, like kernels or drivers!!!

  39. Re:I am a PHP user by FsG · · Score: 2

    I'm going to tell you what you don't want to hear, and I'm going to tell you because it's true: you shouldn't be doing that.

    ..and I'm going to ignore you and do what I wanted to do anyway. If my current tool doesn't allow it, I'll switch to one that does.

    But insults aside, I think the way in which you said "you shouldn't be doing that" without even bothering to explain why, is part of the problem. You're basically saying that you know better than me, so much so that you shouldn't even have to persuade me, that I should just accept your superior knowledge. That approach never works, and it's pretty insulting to be on the receiving end of it.

    If you want to advocate a better way or explain why "continue 2" is bad, you can certainly do that, but just trying to force your position upon everyone isn't the answer. If you try, someone else (in this case, php) will come along and give the people what they want.

    --
    I made a PHP/MySQL library that prevents SQL injection & makes coding easier!
  40. You show only your own ignorance by rubypossum · · Score: 2
    It's a question of chance and marketing that you picked python. You show your own ignorance that you lump Ruby in with Perl. Ruby is syntactically and culturally only as related to Perl as Python is, or less. Modern ruby is the cleanest, most elegant, expressive and fastest of the big 4. It offers a bigger standard library (gems(40,000) vs pypi (1,022)), a wider selection of interpreters and platforms, not to mention much better documentation and educational resources.

    Ruby is used by a wider group of people and in a wider area than it ever has been. Also, there's a lot of other really great languages out there you should consider before you idolize one language as perfect. Erlang and Haskell are amazing and certainly worth checking out. Not to mention node and the javascript revolutionaries. A lot of people get stuck on their first language I encourage you to branch out and try Ruby at least. You'll find a much different language than you seem to think. I personally had the following progression in my love affairs with languages:
    1. AMOS Basic
    2. Lattice C
    3. Perl
    4. PHP
    5. Python
    6. Ruby
    7. Erlang
    --
    I have a theory that the truth is never told during the nine-to-five hours. - Hunter S. Thompson
  41. Re:Fix? I think you mean, "migrate" by tibit · · Score: 2

    You've basically decided that you'll be stuck with software engineering as it was in the 70s and to hell with progress, because that's what you're used to. If you truly believe that you can be a good professional without continuously learning, I've got news for you: in no other engineering discipline I know of would that be true. Doctors and even nurses won't be renewed their licenses without proof of continuing education. Civil, mechanical and electrical engineers need to keep up with new technologies both in the design and the end product sides of the process. Even educators often need to do continuing education or their licenses will be taken away. This "academic functionality" you speak of has been, for the most part, engineered as a solution to oft faced problems. Problems you're apparently unaware of. Problems that make you less productive, make your code harder to maintain, and lose money for your employer.

    --
    A successful API design takes a mixture of software design and pedagogy.
  42. Re:But it's PHP! by Miamicanes · · Score: 2

    The big problem with PHP is that you can get yourself into situations where trying to handle error conditions can actually make things worse than just letting it crash, burn, and try to clean up its own mess for you. Let's start with the fact that try/catch DOESN'T actually work with php_mysqli and pile things onto the "things that suck about PHP" list from there.

      I borked an entire database table once thanks to PHP's willingness to recast just about anything, even when recasting contradicts the prepared statement declaration command in php_mysqli itself. The ONLY thing stopping me from porting the whole app to Java is the fact that I can't figure out how to get Tomcat to not accept incoming http connections or respond AT ALL until it's 100% ready to deal with requests, instead of crapping out and returning semi-random 500 errors for that period of 20-90 seconds when it's in an "indeterminate" and "undefined" state while starting up.

  43. Conservatism at its best by sivann · · Score: 2

    What's the new trend? Flames for PHP. Let's everyone join and destroy this shameful thing which is clearly aimed for noobs, not for us!
    But after 15 years and tens of thousands of lines of code in POSIX C, C++, Delphi, Perl, etc I found I like PHP the most! Why?
    Personal preference here:
    -Great syntax. Yes, great syntax.Which for me means:
        C-like blocks, not the delphi's funny stuff, not python's space-based block detection!. Who didn't try to remove semicolons or blocks for fun when they first wrote their first compiler? Well this isn't for fun. I want {.} not tabs and spaces. Why change something that works so good? Even friends who like python have nothing to say about this 'feature'.
    -sane array syntax. Not Perl's @,$,etc maddness.
    -lots of supported interoperability with OS shared libraries. And this code runs fast.
    -reliability. I don't recall seeing a segfault from a PHP process. Where I frequently see our python (2.6) processes segfaulting.
    -mod_php. Reliable. Works.
    -PDO database abstraction layer. I mean Oracle's OCI support was working fine even for external LOBs from 1999 in PHP3, but PDO was a step in the right direction.
    -Modern features added lately (closures, etc).
    -Great, and I mean great, documentation. That alone is a big plus.
    -Several good and easy enough Frameworks (I don't mean Zend)
    So we have a language which is reliable, supported, has modern features, can call most .so libraries I care about, has great DB interoperability, has a syntax I can work with, works good with apache. Why complain so much? Just point out what you don't like and request for changes. All this "I hate php with passion" seems very strange to me.
    -S