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:
  • Re:Really? (Score:5, Informative)

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

    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.

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

    by JDG1980 ( 2438906 ) on Friday June 29, 2012 @12:33PM (#40495373)

    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.

  • That's what major version bumps are for.

    People will stick with the old major version if shared web hosting companies don't allow hosting customers to run an app for one version and an app for another version on the same hosting plan. Even outside PHP, that's one reason Python 3 isn't taking off as fast as was hoped: the operating system doesn't know which major version to execute when the user double-clicks a .py file.

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

    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 [veekun.com]:-

    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)

  • Re:Recursive? (Score:5, Informative)

    by arth1 ( 260657 ) on Friday June 29, 2012 @12:59PM (#40495777) Homepage Journal

    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

  • Re:Really? (Score:2, Informative)

    by Java Pimp ( 98454 ) on Friday June 29, 2012 @01:25PM (#40496225) Homepage

    If the submitter is doing anything with uninitialized variables he doesn't have any room to complain about other people's code.

  • Re:Recursive? (Score:5, Informative)

    by bruce_the_loon ( 856617 ) on Friday June 29, 2012 @01:35PM (#40496373) Homepage

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

  • by Anonymous Coward on Friday June 29, 2012 @02:08PM (#40496869)

    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.

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

    by Golthur ( 754920 ) on Friday June 29, 2012 @02:55PM (#40497533)

    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.

"If it ain't broke, don't fix it." - Bert Lantz

Working...