Slashdot Mirror


The New PHP

An anonymous reader writes "This article at O'Reilly Programming suggests that PHP, a language known as much for its weaknesses as its strengths, has made steady progress over the past few years in fixing its problems. From the article: 'A few years ago, PHP had several large frameworks (e.g. CakePHP, CodeIgniter, and so on). Each framework was an island and provided its own implementation of features commonly found in other frameworks. Unfortunately, these insular implementations were likely not compatible with each other and forced developers to lock themselves in with a specific framework for a given project. Today the story is different. The new PHP community uses package management and component libraries to mix and match the best available tools. ... There are also exciting things happening with PHP under the hood, too. The PHP Zend Engine recently introduced memory usage optimizations. The memory usage in PHP 5.5 is far less than earlier versions.'"

6 of 254 comments (clear)

  1. Re:Too Little, Too Late & MtGox by hondo77 · · Score: 5, Insightful

    Why in 2014, do I have to decorate variables with '$'?

    That is your first complaint about PHP? That? I can't stand PHP but, seriously, that is first on your list of PHP badness?

    --
    I live ze unknown. I love ze unknown. I am ze unknown.
  2. A fractal of bad design. by Anonymous Coward · · Score: 5, Insightful

    I don't normally like linking to blog posts, but this one pretty much sums up PHP for me:

    http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/

    His analogy is very apt.

  3. Re:You don't know what you're talking about. by Anonymous Coward · · Score: 5, Insightful

    PHP has always used explicit memory management.

    allocate_StringMemory()
    sys_FreeMemory_UTF8()

    Watch out because there is no way to tell if allocation fails. That's convenient though because it makes sys_Free* idempotent; there is no difference between failure to allocate and multiple free-s.

    With 5.5 you get a great new function;

    sys_FreeEverything() // in traditional mixed camel case + underbar style!

    Now you don't need to keep track of allocations and release them. Just blow away all allocations across all requests and start fresh. It's really great for fixing those darn memory leaks.

  4. Re:PHP by Tablizer · · Score: 5, Insightful

    Every common language out there has ugly stuff of one kind or another.

  5. Re:Too Little, Too Late & MtGox by Dan+East · · Score: 5, Insightful

    I do a lot of coding in PHP, and there's a lot of things I don't like about it, but your particular dislikes don't make a lot of sense.

    Why in 2014, do I have to decorate variables with '$'?

    It's not like PHP was written in 1965 and thus there was some hardware (memory footprint, compilation speed, etc) reason variables are prefixed with a dollar sign. It was a design choice. That's so you can do this:
    $count=5;
    echo "The total is $count.";

    And you can use the same variable syntax in your code as in strings that are automatically parsed.

    Why is the assiciative array syntax take two characters that look a comparison operator?

    It doesn't "look" like a comparison operator if you actually know what the operators are. <= and >= are comparison operators, and => is not a comparison operator in any language I've ever used. A single equal sign looks like a comparison operator too, and woe to the developer that doesn't have the universal C-like basic operators (used in dozens of modern languages) memorized backwards and forwards.

    Why do I need == and ===?

    For the same reason that Javascript and other scripting languages need it. Those languages do automatic type conversion, and sometimes you don't want that to occur. The alternative is manually casting things, which isn't very script-like at all, and having to explicitly deal with types is more like C than an "easy to use" scripting language. Thus there are two equality operators for the times you don't really want 0 to equal null to equal false.
    This one is even more ironic considering Javascript based node.js is your favorite server side platform, and thus you would also have to use both == and === operators in your preferred language anyway.

    ANd vaiable confusion between $_GET, $_POST and $_COOKIE

    I don't even know where to begin on this one. They are 3 entirely different things, with the most self-explanatory names I can think of. That's exactly as it should be. Look at $_REQUEST if it's too difficult to figure out which you should be using (and woe to your client if that's the case).

    --
    Better known as 318230.
  6. Re:PHP by Mitchell314 · · Score: 5, Interesting

    I was about to make a joke, but seriously, the only language I can think of that doesn't have some nasty gotcha is . . . . ugh . . . BASIC. Python has the whole whitespace deal, Perl code tends to be unkempt, Java is fuggin java, Ada is a secret government spy, I don't even want to talk about C++, Bash is fine as long as you never have the misfortune of using quotes or variables, C guarantees regular segfaults, Matlab/Octave will delightfully inform you of your bugs deep in system library code, SAS's userfriendliness pars that of installing Linux from scratch, you can't write more than four lines of Fortran without painting some Star Trek action figure, and just fuck Cobol.

    Honestly, BASIC's wins this round just by virtue of being so limited that it's hard to shoot yourself in the foot. I don't count GOTO, as jumps aren't really language specific. Having tutored programming for years, I can say that students are perfectly able to write speghetti code with or without goto. :p

    --
    I read TFA and all I got was this lousy cookie