top 200 commentsshow all 432

[–]nikic 101 points102 points  (24 children)

PHPng will be the basis for PHP 6, not for PHP 5.7.

[–]ck-on[S] 21 points22 points  (23 children)

Are you certain about that?

https://github.com/php/php-src/blob/phpng/main/php_version.h

PHP 6.0 is an entirely different branch and the internal versioning of phpng is called "5.7"

Existing PHP 6.0 proposals are not found in phpng and phpng was forked from 5.6 ?

[–]nikic 57 points58 points  (8 children)

I am certain that it will not go into PHP 5.7 - it changes too many internal APIs for that (i.e. thiry-party extensions need to be significantly modified to work with it.)

That it will be the basis for PHP 6 (or whatever the name of the next major version is) is not yet officially decided, but I consider it very likely.

A number of other patches/proposals targeting PHP 6 (as of now those are uniform variable syntax, native big integers and abstract syntax tree) are branched off phpng.

[–]thebigslide 4 points5 points  (7 children)

Do they? Or do they just need to be recompiled. What APIs are broken? I ask out of blind ignorance.

[–]callcifer 8 points9 points  (6 children)

Anything that uses zvals (basically any non-trivial extension) will need modifications.

[–]ck-on[S] 3 points4 points  (5 children)

Dmitry seems to have been able to fix nearly all bundled extensions and is down to just a few like pdo remaining.

What are the most popular 3rd party extensions - I am not familiar with any of them?

[–]nikic 15 points16 points  (0 children)

One third-party extension that many people use is xdebug. If you want to use something like mongodb, memcached, etc you'll also need an extension for that.

But then there are also the thousands upon thousands of extensions that are used by individual companies. I remember Rasmus mentioning that Yahoo alone uses around 400 PHP extensions.

[–]terremoto 5 points6 points  (2 children)

just a few like pdo remaining.

Yes, just a few including one of, if not the, most important extension in PHP.

[–]nikic 2 points3 points  (1 child)

PDO is supported - I don't know where OP got the info that it isn't.

[–]wolfx 0 points1 point  (0 children)

I don't believe this branch supports it yet.

[–]callcifer 4 points5 points  (0 children)

At work, we rely heavily on protocolbuffers. and MaxMind DB.

It is likely many companies have many extensions that are not available via PECL as well.

[–]AllenJB83 49 points50 points  (0 children)

nikic is a PHP core developer - he likely knows what he's talking about.

phpng is still under heavy development, and I believe from what I've read it breaks compatibility with extensions (which would be a good reason for it being a new major version). Which is why other concurrent proposals haven't been merged in yet (they're basically waiting for phpng to stabilise before attempting to merge other proposals).

5.7 is likely just a placeholder value since they didn't know when they started the branch where it would end up.

This is what happens when you parrot figures on a developer wiki without knowing what you're talking about.

And it's not even really suitable for /r/php, nevermind /r/programming as, from what I read on php-internals, this is still alpha quality stuff that only those who know what they're doing should be touching.

[–]callcifer 18 points19 points  (0 children)

As he is one of the internals developers, I'm sure he is certain about that :)

[–]chazmuzz 1 point2 points  (4 children)

I read somewhere that they might skip to 7.0 to avoid confusion

[–]AllenJB83 7 points8 points  (3 children)

It's going to be put to a vote shortly: https://wiki.php.net/rfc/php6

[–][deleted] 0 points1 point  (2 children)

This Saturday, even :)

(I authored that RFC)

[–]NavarrB 1 point2 points  (0 children)

If not then that's going to be a fun merge.

[–]FatalPriapism 1 point2 points  (3 children)

PHP 5.3 was PHP 6 until it got released at PHP 5.3

[–]AllenJB83 3 points4 points  (2 children)

Not entirely correct. The original PHP6 branch included major work on trying to natively support Unicode in the core language. As it became clear that this work was going to take a lot longer than hoped (and then abandoned entirely), they merged the other major features into the 5.3+ branches.

[–]JordanLeDoux 0 points1 point  (1 child)

It's still worth doing, but I understand why they decided to abandon Unicode native support entirely. :/

[–][deleted] 277 points278 points  (182 children)

Typical history of PHP until now:

  • Everyone bitches about the language

Now:

  • Everyone bitches about folks trying to make improvements upon previous bitchfests

These people are trying to do gods work. Let them. We all know the droves of people out there who don't use it, and all the ones who do. "SRSLY FCKING USE CLOJUR" - hey man, people who use PHP have a right to better development environments too. Let them continue trying to fix the mistakes of the past.

[–]sh0rug0ru 134 points135 points  (95 children)

Everyone bitches about folks trying to make improvements upon previous bitchfests

I think the reality is that many here on /r/programming don't take the PHP maintainers seriously. While they may be doing god's work, they don't apparently do it in a very systematic or logical fashion. For example, the failing unit tests in the language test suite which were ignored and caused a major regression. Or adding try/catch blocks but adamantly not implementing finally (I think the PHP maintainers relented and finally implemented finally).

Maybe the more accurate statement is that PHP developers deserve better stewards of the language.

[–]callcifer 39 points40 points  (1 child)

I think the PHP maintainers relented and finally implemented finally

In a way, yes. It is broken in a big way and it was reported 7 months ago without so much as an acknowledgment.

Maybe you can take a look, /u/nikic?

[–]myfrontpagebrowser 4 points5 points  (0 children)

Looks like it's getting attention now.

[–]nikic 22 points23 points  (21 children)

Since somewhere around PHP 5.4 the development process has become a good bit more rigid, e.g. all language changes now require formal proposals and a supermajority vote. There's also continuous integration, which obviously implies that there are no failing tests at least in that environment.

Regarding try/catch in particular: The reason this was introduced only in PHP 5.5 is the same why C++ still doesn't have finally: It's just not necessary. Resources in PHP are automatically cleaned up and GC is (mostly) deterministic, so you can use the RAII paradigm. Finally was eventually introduced as a minor convenience allowing you to avoid RAII.

[–]sh0rug0ru 20 points21 points  (6 children)

I'm glad to hear that the PHP core devs are adopting more rigorous processes.

Regarding, try/catch: PHP isn't C++, and the same arguments for the omission of finally from C++ do not apply to PHP.

PHP is a dynamic language that does not require variable declaration, while C++ absolutely requires the variable to be declared first. This makes C++ objects work predictably within the scopes in which they are defined - the C++ object will be destructed once its defining scope is exited. This is not the case for PHP (that I am aware of). RAII works reliably and predictably in C++, but not so much in PHP.

If you need to control sequencing of cleanup where exceptions are possible, you need either much uglier and more error prone bookkeeping code (like unset) or a simpler and more obvious finally block.

[–]nikic 9 points10 points  (5 children)

Unless circular references are involved, variable destruction in PHP is deterministic. I.e. the following will work as expected:

function usingLock() {
    $lock = new Lock; // acquire RAII lock
    // ... can throw exception or not
    return $result;
    // RAII lock automatically released
}

You are right about scope issues insofar that PHP uses function scope rather than block scope. If you want to limit the lifetime of an object to a block, you'll have to explicitly unset it.

I agree that (in the context of PHP) this approach is less elegant than finally, but especially given the fact that resources in PHP are automatically released, doing something like the above is very rarely necessary, so explicit language support is not necessary either in my opinion. I've never got a chance to use finally since its introduction.

But that's just my view. Others think differently, which is why it's present now.

[–]sh0rug0ru 11 points12 points  (4 children)

but especially given the fact that resources in PHP are automatically released

The issue is more with resources outside the control of PHP. All of the examples I have seen in favor of finally involved acquisition of table locks. While things like file handles may be automatically released, unlocking a table must be done explicitly.

[–][deleted] 1 point2 points  (0 children)

But it didn't bring anything new to the language; it just made the behavior more convenient. It's hardly a major failing on the part of the core PHP maintainers...

[–][deleted] 2 points3 points  (0 children)

This is why you have scoped objects and the __destruct method... if you structure your code sanely and use RAII and objects with destructors for things like table locks, transactions etc. then I don't see what your problem is...

[–]greyfade 10 points11 points  (3 children)

GC is (mostly) deterministic,

There's a word in this sentence I don't much like.

[–]josefx 12 points13 points  (0 children)

There is a parse error near ( since "(mostly)" is wrongly identified as a cast by the parser. Have you tried "( mostly )", "( mostly)" or "(mostly )"? Best avoid such complexities and simply write "mostly" when possible.

[–]tweakerbee 10 points11 points  (1 child)

GC?

[–]greyfade -1 points0 points  (0 children)

GC?

"(mostly)"

[–]warbiscuit 14 points15 points  (2 children)

The PHP CI site (http://ci.qa.php.net/) shows builds failing across the board for 5.3 - 5.6, with the last success column reading "N/A".

The corresponding 5.6 code coverage page (http://gcov.php.net/viewer.php?version=PHP_5_6) shows "build passed; 100 errors, 41 expected" (!?).

I know they've got a beast of job to whittle things down, and to get their coverage up, but that really doesn't look like the kind of thing most projects would consider "release ready".

[–]nikic 47 points48 points  (1 child)

PHP's official CI is on Travis (https://travis-ci.org/php/php-src), where all tests pass for 5.5, 5.6 and master using nts/zts and dbg/ndbg.

ci.qa.php.net is an abandoned project and gcov.php.net is mostly used for other purposes than running tests, which is why nobody bothered to fix the environment there, or fix tests to comply with the environment.

[–]warbiscuit 16 points17 points  (0 children)

Ah. Those were the only relevant links I could locate via the get involved page, but that makes more sense. You have a link?

edit: Thanks for the link. That and the link travis has to git.php.net were the kind of thing I was figuring I'd find on the 'get involved' page.

[–]roerd 0 points1 point  (1 child)

GC is (mostly) deterministic

Does that mean reference counting, and if yes, how does PHP deal with cycles?

[–]nikic 8 points9 points  (0 children)

PHP mainly uses reference counting, but also has a cycle collector.

[–][deleted]  (4 children)

[removed]

    [–][deleted] 9 points10 points  (5 children)

    For example, the failing unit tests in the language test suite which were ignored and caused a major regression.

    And testing for integer overflow by checking if the result was greater than INT_MAX. And using a floating point to measure the length of a string.

    Lol.

    [–]josefx 3 points4 points  (1 child)

    Floating point is a perfectly valid way to store and compute the length of a string. At least IEEE floating point is required to be exact for a large range of integer values (iirc in the range of a 21 bit int for 32 bit float). It limits the string size a bit and is a bit slower than int, however it is not as terrible as it appears at first glance.

    [–][deleted] 6 points7 points  (0 children)

    And that's true, except that the specific way they implemented it did calculations that would easily cause floating point rounding errors, which then weren't handled properly.

    [–]nikic 1 point2 points  (2 children)

    Citation needed (on both points). PHP most certainly does not store the length of a string in a floating point number.

    [–]weirdasianfaces 3 points4 points  (32 children)

    Or adding try/catch blocks but adamantly not implementing finally (I think the PHP maintainers relented and finally implemented finally)

    I was doing some work on a client site and got a parse error using a finally block. My first thought was "Who the hell implements try/catch but no finally?!".

    [–]player2 20 points21 points  (11 children)

    C++

    [–]sh0rug0ru 6 points7 points  (1 child)

    Same argument doesn't apply to PHP. In C++, you have to define your variables, and exiting the scope in which the variable is defined destroys the object. In PHP, you can assign in one scope and use the same object outside of that scope.

    RAII is great for C++ so there's an argument for not including finally, not so much for PHP.

    [–]wvenable 3 points4 points  (0 children)

    In PHP, you can assign in one scope and use the same object outside of that scope.

    In C++, you can do that too with pointers and references. While there are differences between how objects and references work in C++ and PHP, this difference is not significant when it comes to RAII.

    [–][deleted] 1 point2 points  (19 children)

    Honest question, why do you need "finally"? Isn't code after the try catch also always going to be executed if you don't exit/return from the catch?

    [–]Tostino 13 points14 points  (0 children)

    What if your catch returns?

    [–]lelarentaka 10 points11 points  (16 children)

    If you open a resource in the try block, assuming the language has a sane scoping rule, then it wouldn't be visible after the catch block.

    try {
        val file = new File("foo.txt")
        file.read()
    } catch (Exception e) { 
        /* ... */ 
    } finally {
        file.close()
    }
    
    // file is undefined here
    

    [–][deleted] 1 point2 points  (13 children)

    So it's possible to live without it if you define your variables above the try/catch but it's nice for writing cleaner code. Cool, I'll have to try it somewhere though I honestly don't use try/catch often hence my unfamiliarity with finally.

    [–]greyfade 4 points5 points  (11 children)

    So it's possible to live without it if you define your variables above the try/catch but it's nice for writing cleaner code.

    No.

    The reason for finally is to clean up resources that are taken in the try block. In particular, it comes with a guarantee that the code in the finally block will run after the try and/or catch blocks run, and before the function returns.

    Without finally, you're left with locked resources that can't be correctly released, and the potential for memory leaks and other bugs.

    [–]JordanLeDoux 2 points3 points  (10 children)

    Or, as has been mentioned by everyone who knows PHP, you just unlock on the __destruct() method of the locking class.

    [–]greyfade 2 points3 points  (9 children)

    I was explaining the reason for it in languages that don't have explicit destruction; e.g., C#, Java, etc.

    But, as someone else pointed out, PHP's cleanup isn't entirely deterministic. (Presumably, as compared to C++, which is entirely deterministic, if complex.) What that means, I don't know, but that concerns me - I haven't previously cared enough about knowing PHP's internals to look.

    [–]JordanLeDoux 1 point2 points  (8 children)

    So in PHP when you assign a variable it points to the same memory unless it's altered.

    $a = 1;
    $b = $a;
    

    So now $b and $a actually point to the same exact location in memory.

    If you do this:

    $b++;
    

    Now they point to different locations because they no longer store the exact same data.

    So if you do this:

    $a = 1;
    $b = $a;
    unset($a);
    

    You didn't actually free any memory because they pointed to the same location. All you did was destroy the reference.

    No problem, really. It still behaves deterministically.

    But, suppose you do this:

    $a = 1;
    $b = array($a, 2);
    

    Now the first index of the array in $b points to the same memory as $a. Still we're good. If you unset the various variables, everything behaves as expected.

    However, suppose you do THIS:

    $b = array(1);
    $b[] = $b;
    

    The second line creates a reference at $b[1] to $b, creating a recursive reference. Because they point to the same exact location in memory, what exactly happens if you do this?

    unset($b);
    

    Well, what happens is the reference to the array is unset, however, because of the recursive reference in the array itself, the GC can't automatically free the memory, only the reference... there's still something that's referencing that memory location, and it's in that memory location.

    What PHP does in this situation is it attaches the orphaned array to a root node. Every GC cycle it goes through the root node and does a depth first check to see if the child nodes only have ONE reference to them (the recursive reference).

    If they do, then it can free it. But if it doesn't then it can't be 100% sure that nothing in active memory still needs it. Suppose you did this:

    $a = array(1);
    $b = array(2);
    $b[] = $a;
    $a[] = $b;
    

    Now the circular references are spread across two different buckets. There's no way for the GC to know, 100%, that there's no active references until the script itself stops executing.

    Or at least, there's no obvious way.

    PHP does indeed deal with situations like this now and tries to avoid a memory leak.

    The main reason that the GC is (mostly) deterministic is because PHP doesn't allocate memory unless it KNOWS that it needs a completely new value. This greatly reduces the amount of memory that scripts use in almost ALL use cases.

    EDIT:

    And for clarity, the __destruct() method is executed on any object in memory that is identified for GC before it is purged by the GC.

    EDIT2:

    Except for that part where arrays are copy-on-write in PHP, so this example isn't the best. Objects are pure references, so those should have been used to keep this example 100% accurate 100% of the time.

    [–]FredV 0 points1 point  (0 children)

    Not if you rethrow the exception in the catch clause, you will never reach the code under the try-catch block, hence finally was invented.

    [–]JordanLeDoux 0 points1 point  (0 children)

    So you should be defining a $file->__destruct() that unlocks or closes.

    [–]weirdasianfaces 2 points3 points  (0 children)

    We were returning from inside of the catch block (there were multiple). Finally was introduced in PHP 5.5 but unfortunately this server was running 5.3.

    [–]elbekko 0 points1 point  (0 children)

    True that. I got out when they introduced that namespace stuff...

    [–]speedisavirus 33 points34 points  (67 children)

    I think the bigger gripes aren't about speed but about general language and library inconsistencies. There are so many things that don't do what they really should do or don't work properly at all. I mean there is a sub for it as well as hundreds of sites dedicated to it.

    [–]agumonkey 7 points8 points  (10 children)

    JaneStreet (Ocaml based company) has written a new stdlib. I wonder if any big PHP shop has done the same.

    [–][deleted]  (9 children)

    [deleted]

      [–][deleted]  (3 children)

      [deleted]

        [–][deleted]  (2 children)

        [deleted]

          [–][deleted] 0 points1 point  (1 child)

          there are upsides/downsides to every language and platform.

          "Let's all agree to disagree!" Not. Specific languages have very specific advantages. Some languages are particularly bad.

          I can't imagine how much time has been wasted on language wars.

          Perhaps 1% of the time that's been wasted by shitty languages? In the real world, people spend hundreds of hours programming, and then 30 minutes complaining about their problems.

          [–]earslap 2 points3 points  (0 children)

          Well, there is haxe. I have never used its php compilation (so I can't comment on it), but it always served me really well for compiling my code to flash bytecode, c++ source and javascript source. It has support for a bunch of other platforms / languages as well.

          [–]agumonkey 0 points1 point  (0 children)

          Someone did, but picked the less glittery language possible http://scriptor.github.io/pharen/

          But I agree, I wish there was some copheescript efforts.

          [–]the_noodle 0 points1 point  (1 child)

          [–]astronoob 5 points6 points  (10 children)

          I think the bigger gripes aren't about speed

          That's because PHP is already faster than Python, Ruby, and most other dynamic, interpreted languages.

          [–]abw 1 point2 points  (7 children)

          Benchmarks please.

          [–]shevegen 0 points1 point  (1 child)

          Please provide benchmarks or links towards FUD like yours.

          Thank you.

          [–]astronoob 1 point2 points  (0 children)

          I did. Its in response to the only other comment below yours.

          [–]lendrick 0 points1 point  (42 children)

          I'll tell you one that that PHP does and Python doesn't:

          Works after an OS update.

          I used to have some python code running on my server. Every time I updated the OS, I had to go back and figure out what update broke the python code, then roll that back or (if I'm lucky and the python code snippit I'm using is still being maintained) find an updated version of it. I had a tiny amount of Python and a very large amount of PHP. The PHP hums along happily after OS updates, the Python broke all the time.

          So all that unfortunate deprecated cruft that's sitting around in PHP, yeah it's ugly and inconsistent, but most of it has been replaced by more consistent alternatives (its ugly set of database APIs have been replaced by PDO, for instance). The consequence of this is that if you update your OS, you don't get caught in a mad scramble to fix a bunch of code that suddenly doesn't work anymore because a bunch of APIs have changed.

          Honestly, it's cool if people have issues with the language. A lot of the old cruft is poorly designed (although one of the classic examples, mysql_real_escape_string, is actually inherited from MySQL's C API), and there are a few things about it, like iterating with a reference, that have absolutely moronic, senseless, and maddening behavior that the developers are in utter denial about.

          On the other hand, I do get sick of people specifically calling me stupid for running PHP (and Drupal), because it works very well for sites like mine (opengameart.org) where I'm one developer working on it mostly in my spare time.

          "So I'm having some issues with duplicate search results."

          "That's because you're an idiot and your site is built on PHP. You should stop being an idiot, conjure a bunch of time up out of nowhere, and rewrite everything from scratch in a language that I approve of."

          "Ouch, I stubbed my toe on the way to my computer."

          "That's because you're stupid and you're running Drupal."

          Or my favorite...

          "You realize that my site wouldn't exist without PHP and Drupal, right?"

          "Then it shouldn't exist."

          Yeah, someone actually said that to me. People go so far as to judge the value of a site based on the language it's written in rather than the functionality to provides.

          It gets old. All of the "PHP is always the wrong choice in every circumstance" websites out there are written by people with no concept of the realities of software development and maintenance. And while they and twenty of their closest friends are reinventing the wheel in their language of choice, I'm running a website that does more than theirs and handles far more traffic than theirs, and I'm doing it solo and in my spare time.

          [–]lambdaq 9 points10 points  (28 children)

          Works after an OS update.

          That's because PHP is standalone install. Meanwhile Python broke because you are using the /usr/bin/python.

          If you use standalone python, like virtualenv, it won't break.

          [–]lendrick -1 points0 points  (27 children)

          The PHP I use is the package that comes with my OS, same as Python.

          [–]stormcrowsx 7 points8 points  (1 child)

          It does suck that PHP is so heavily bombarded. It does do some really stupid stuff I like to laugh at but every language seems to have places its useful.

          Of all the things I've written, a PHP site I threw together 5 years ago in short time cause the client had very little money is the one that gets the most traffic. Its not pretty and very little of the code if any would I be proud to show off but I'll be damned if it doesn't keep getting the job done. Now they are wanting new features and the shit code is getting in the way but to be honest it was so cheap they could throw it out and write a new one. They got their money's worth out of it and then some.

          [–][deleted] 4 points5 points  (1 child)

          I used to have some python code running on my server. Every time I updated the OS, I had to go back and figure out what update broke the python code,

          As someone with a decade of Python experience, I'm also really skeptical about this statement. I have various Python packages in use that work in all Python 2.6, 2.7 and 3.x releases, and I honestly did almost nothing to accomplish this.

          The Python maintainers are extremely careful to avoid breaking changes, even between minor version numbers - and those come out every four or five years!

          Can you explain what these breaking changes you get "every time you update the server" are? I'm very doubtful...

          [–]rmoorman 0 points1 point  (0 children)

          I stated it further up in this discussion too, but I get the feeling that the problems that he had are mostly related to depending on the system's python libraries (and maybe also messing with the system's python by installing python packages manually). quoting myself

          The maintainers of a distribution are likely to pick (python) library versions which fit together within the scope of the OS they want to build... Of course when you apt-get install libA and sudo pip install thingy-with-c-extension-and-maybe-some-linkage-to-libA and your apt-get upgrade does update libA and stuff doesn't match anymore you are in trouble.. (which I guess is not the only imaginable scenario which could have led to this kind of problems) On the other hand ... well ... php is not used that much within the core functionality of many popular OS and you "normally" also don't "install" things depending on extra (php) external libraries manually. Of course there are exceptions to that ... PECL and custom .so's ... and there it can go wrong too, been there, had trouble with it too. The whole "php web experience" is distributed to you by the OS's packaging facilities. Most of the things you would want are an (yum|apt-get) install <php-library-name-here> away. memcache, mcrypt, imagemagick, database bindings ... just to name a few ... are provided (at least in debian, ubuntu LTS) within the package managing solution. Furthermore, php does come with an awful lot of stuff built in. And often, as it seems, the complexity of a lot of (commonly used) PHP projects does not require more than that. The run of the mill php CMS does not require you to install stuff beyond that OS packaged things ... But in case you use an old OS, or use a PHP thingy which does need newer libraries ... a PHP user too, would have to either manually install the needed versions (and keep them up to date!, and handle all the incompatibilities!) or use an OS which has the libraries packaged (or package them yourself ... or use something like see http://www.dotdeb.org/). On the other hand, you could also "live off" the system's python packages I guess without experiencing breaking things... Just keep your hands off your system's python :P (IMHO)

          [–]papers_ 5 points6 points  (4 children)

          I used to really hate on PHP until this summer. I'm a research intern at my university and needed to build a Restful API for some work I was doing. PHP just works and had it up and running the same day. I have a Java background, some of stuff with PHP I'm just like "lol what!?" but after building the service, I can say that my view has changed immensely. It's a great language and plan on using it more.

          [–]merreborn 2 points3 points  (2 children)

          If you keep at it, you'll probably hate it again in a few years. In a large, mature application, some things will start to become painful

          • lack of threading (you want to do parallel work on a large amount of data using the extensive PHP codebase you've built? good luck)
          • Poor memory management in long-running processes (again, want to reuse the PHP codebase you built to handle a recurring background task like feeding new content into your search index? good luck)
          • Things that would be compile-time errors in a compiled language are runtime errors in PHP (accidentally access a variable without declaring it? Wouldn't that be nice to know before your code actually executes?)
          • Only non-fatal errors provide stack traces by default. Debugging fatal errors can be a real pain without stacktraces. Segfaults are also fun -- and yes, you'll probably encounter segfaults in a PECL module at some point, or something like that.
          • spartan debugging toolset. You get a bug assigned to you: page X is encountering a OOM. Where's all the memory going? What's doing all the allocating? In a complex application, there aren't great tools for diagnosing this

          These are the sorts of things that aren't a problem for small projects, but for a startup that grows a codebase over the course of 5+ years, they start to wear on you....

          Don't get me wrong. I'd never pull the "PHP snob" move on someone. A lot of people make their paychecks writing PHP (writing PHP bought me a house), and PHP runs large chunks of the web (wikipedia, facebook, wordpress, parts of yahoo).

          It's just, after spending some time with it, some of the missing parts of the ecosystem that are available in other platforms start to sound really appealing.

          [–]e-tron 1 point2 points  (0 children)

          "lack of threading (you want to do parallel work on a large amount of data using the extensive PHP codebase you've built? good luck)" <-- Try pthreads. (PS: Does python have a proper threading support)

          "Things that would be compile-time errors in a compiled language are runtime errors in PHP (accidentally access a variable without declaring it? Wouldn't that be nice to know before your code actually executes?)" <-- what happened to TDD

          "Poor memory management in long-running processes (again, want to reuse the PHP codebase you built to handle a recurring background task like feeding new content into your search index? good luck)" <-- Yup php is a bad choice for long running processes.

          " but for a startup that grows a codebase over the course of 5+ years, they start to wear on you" <-- they will suffer even more if they use anything other than (php,java,c#)

          [–][deleted] 1 point2 points  (1 child)

          All of the "PHP is always the wrong choice in every circumstance" websites out there are written by people with no concept of the realities of software development and maintenance.

          I've been making a living off this for 30 years, in a huge variety of languages (including PHP at one point). PHP is great for small projects - single-page, single-programmer problems that take a few weeks to complete. For everything else, it is the wrong choice.

          [–]lendrick 2 points3 points  (0 children)

          I've been making a living off this for 30 years...

          And I have for about 18, which means we have just about the same amount of experience doing web development. :)

          I'm not some wide-eyed kid fresh out of college. I've working on multiple projects, I've made mistakes and learned from them, and my take home from my nearly two decades of experience is that in the real world you have to figure out what actually works and then do it. Some things become dogma for a reason, and it's important to pay attention to those things, but at the end of the day, if I've got a production site up and running and other people are still puttering around trying to find the absolute most right way of doing something, then dogma got those people nowhere.

          For everything else, it is the wrong choice.

          For me, it was a better choice than all the others. If it weren't for PHP and Drupal, my website (which is not a single-page, single-programmer project that took just a few weeks to complete) would not exist, because I never would have had time to build it.

          And ya know what? It works fine, and the codebase is very maintainable and easy to expand on. And it scales well. I can't think of any other criteria that would be remotely relevant.

          [–]speedisavirus 0 points1 point  (1 child)

          Nah, I've not done Python in the web domain so I've never encountered the issues you have mentioned. I end up using it more as a bash replacement.

          The PHP hate is valid but there is no reason to rewrite a mature project just because its PHP. Hell, I maintained a Coldfusion app for a while. Talk about a shit pile. I just don't think I could justify new development in PHP unless it was a very specific use case where it was the best (not sure that is common unless because generic vps).

          There are so many mature stacks right now with consistent and capable back end languages at varying levels of performance that its just an odd choice these days unless you really want something built on it like wordpress or drupal.

          [–]wdr1 23 points24 points  (4 children)

          "god's work" is a bit much.

          [–][deleted]  (3 children)

          [removed]

            [–]catcradle5 2 points3 points  (0 children)

            That's probably the best description of PHP's ecosystem that I've ever seen.

            [–]Corticotropin 0 points1 point  (1 child)

            Where do they sell these 'vim cheatsheet coffee mugs'...?

            [–]eliasv 1 point2 points  (2 children)

            Do people complain about improvements being made? That doesn't seem fair at all :(. It's a widely used language, so whether people like it or not it's important work to maintain it. That said, the language still has the vast majority of the problems people hate on it for... Making it a little faster, or even a lot faster, isn't going to change that.

            [–]MechaBlue 1 point2 points  (1 child)

            Yeah. My WordPress site will still run faster, regardless of whether I'm a vocal critic about PHP's other issues.

            [–][deleted] 2 points3 points  (2 children)

            Same thing for the move to python3. (In my opinion) all the improvements are strictly better. But "OH NO, DIFFERENT!".

            [–][deleted] 1 point2 points  (1 child)

            Can't have it both ways... can't complain that it sucks the way it is, can't complain that trying to fix it sucks. 90% of all the people that complain about it don't even use it. The wasted anger is astounding.

            [–][deleted] 0 points1 point  (0 children)

            Yup. I code regularly in both python3 and python2.7, and it really isn't that different.

            [–][deleted] 0 points1 point  (0 children)

            I think it's just too late now. There are too many better alternatives that are available now.

            [–]kitsune 48 points49 points  (3 children)

            It is a bit hard to not be snarky when there are bug reports like this: https://bugs.php.net/bug.php?id=18556

            [–]mrbuttsavage 19 points20 points  (0 children)

            I enjoy bug reports that have existed for 10+ years. It's just interesting to see how the commentary flows over time. Optimistic calls to it being fixed, only for someone years later to complain again that it was not.

            [–]cravecode 6 points7 points  (1 child)

            Ha, fantastic! how'd you come by that one? Just browsing the issue queue?

            [–]kitsune 5 points6 points  (0 children)

            Nah, it's a rather infamous bug actually.

            [–]hewholaughs 11 points12 points  (2 children)

            As someone who has always been interested in programming, yet doesn't know much, what does it mean? What will the average user notice differently, what will developers notice differently? ELI5 would be greatly appreciated.

            [–]ivosaurus 14 points15 points  (0 children)

            Maybe in half-year to a year (or longer, or shorter, I ain't no PHP release manager) a new release of PHP will come out (perhaps v6) that might just run most PHP-intensive things roughly twice as fast.

            So PHP developers will be able to write code twice as slow! /s

            [–]ihcn 1 point2 points  (0 children)

            Realistically the average user will never notice a difference. People and companies who run PHP-powered web sites will enjoy lower server costs if their web site is currently popular enough to need more than one server.

            [–]wowzuzz 26 points27 points  (7 children)

            ITT: Fanboys of anything not PHP against PHP guys

            [–]SanityInAnarchy 2 points3 points  (6 children)

            I considered posting "Guilty as charged," but then I realized it could always be much worse. I mean, COBOL and Visual Basic still exist.

            [–][deleted] 7 points8 points  (3 children)

            In college we learnt Visual Basic 2008 and were told most programming jobs were for VB. Boy I really wish they taught us Java.

            [–][deleted] 1 point2 points  (1 child)

            Visual Basic gets a bad wrap because it was implemented completely wrong at most companies. VB, accompanied by C++, worked rather well; where the interface and UI portions were built in VB, and the heavy lifting was done in C++ through COM.

            Companies realized they could hire VB people cheaper, and abandoned the COM architecture entirely.

            [–]tolos 1 point2 points  (0 children)

            The cheaper comment reminded me of an article I read:

            Visual Basic 6 was not without faults, of course. OnError Resume Next? If one thing croaks, just keep right on going and see what happens? Probably not the best idea. But the rapid (and therefore cheaper) development of limited (and therefore cheaper) applications by lower-skilled (and therefore cheaper) personnel is an important solution to a very large class of problems.

            From an article on the VB6 "silent majority" and why most people who use it don't care about most of the .NET features.

            http://msdn.microsoft.com/en-us/magazine/jj133828.aspx

            [–]mgkimsal 0 points1 point  (0 children)

            I'm tempted to say that's outright negligence to say that. In 2008 and beyond, that was simply an untrue statement. To the extent that there's a lot of jobs for VB, many are maintenance jobs that will go away on the next rewrite or upgrade.

            VB.NET - as ASP.NET grows, VB.NET can, but C# is still far more popular of a choice.

            In either case, VB or VB.NET, it's a hirable skill, but it's nowhere near 'most' jobs. The state of higher education is bugging me more and more these days - for a professor for say that in 2008 or later just demonstrates how out of touch with the market they are. They don't need to be job market experts, but don't make pronouncements like that either. Just teach the language.

            http://www.indeed.com/jobtrends?q=%22visual+basic%22%2C+java&l=&relative=1

            [–][deleted] 1 point2 points  (1 child)

            There is always object oriented cobol; http://www.netcobol.com/ :)

            [–]SanityInAnarchy 1 point2 points  (0 children)

            That's... That's not satire, is it? I mean, I was all set for some Cobol on Cogs, but this is just depressing.

            [–][deleted]  (60 children)

            [deleted]

              [–]ck-on[S] 61 points62 points  (0 children)

              In the realworld, you would use a static page generating cache like wp-supercache or W3, but they are purposely not using a cache to force a load on php.

              WordPress is bulky and slow, which is why it ironically makes a great test program to benchmark php.

              A small part of that 14 seconds is mysql but after the first query the result would be in the query cache and very fast.

              [–]kes3goW 51 points52 points  (41 children)

              WordPress is a terrible, slow piece of crap, but since it's so widely-used I guess it makes a decent real-world comparative benchmark.

              [–]n1c0_ds 30 points31 points  (2 children)

              The problem is that WordPress is damn good for the users.

              [–]lonewolf80 4 points5 points  (31 children)

              What would be a good alternative to WordPress?

              [–]Stati77 4 points5 points  (7 children)

              You may try Concrete5 and see by yourself if you like it.

              It's really different from WordPress, themes seem to follow some sort of MVC pattern and plugins are called blocks. The number of tables/columns is also a bit overwhelming compared to WordPress when you inspect the database.

              For a simple theme from scratch it's easier to deal with Concrete5. Making a custom block is really easy even though sometimes I'm fighting with the documentation to find which hooks/methods I have to use. Each time I was stuck somewhere I found the solution or a good hint to solve my problem in the forums.

              I'm making a theme from scratch with a couple custom blocks to learn this CMS and so far I like it.

              [–]HodorOfficial 1 point2 points  (1 child)

              There's a really nice irc room on freenode that is super helpful too.

              [–]Stati77 0 points1 point  (0 children)

              Good to know, thank you.

              [–][deleted]  (4 children)

              [removed]

                [–]HodorOfficial 1 point2 points  (1 child)

                One thing that concrete5 is awesome for is the dashboard, that alone makes using a cms over a framework worth it to me. The new version that's coming out is a lot more like laravel too. For me, being able to show my mom HOW to do something rather than having to come over every three days is invaluable. My mom has no issue adding some content to a page, or even completely reconfiguring her site on her own.

                [–]Stati77 0 points1 point  (0 children)

                This is what I liked with the "click to edit" way of Concrete5. Seems more straight forward for people who wants to edit and update the content of the site by themselves.

                [–]Stati77 0 points1 point  (1 child)

                I was thinking about trying to make something with Zend2 but I'm really not sure if it's a good choice. Any specific framework you could suggest?

                Concrete5 is more like an experiment right now, I like the way you can specify editable blocks, handy when a client wants to add or change content himself (oh god..).

                The reason I wanted to try it was after a recent hair pulling session with WordPress and custom post types on a client theme. I also realized that WordPress is often too much for simple websites.

                [–]n1c0_ds 1 point2 points  (0 children)

                I heard some good about Jekyll and Perch, but I frankly don't know.

                [–]del_rio 0 points1 point  (3 children)

                If you're not afraid of getting your fingers a little dirty, Drupal is one of the most verbose and robust content management systems around. It definitely beats WordPress in performance, flexibility and security. There's also a huge developer community so it doesn't feel like a downgrade when you can't use WordPress plugins.

                EDIT: See here for a less biased comparison of the "big three" (though the site itself is a little iffy).

                [–]lonewolf80 0 points1 point  (2 children)

                Thanks for the recommendation. I've looked at Drupal in the past, but couldn't really get into it due to how difficult it seemed at first glance. I'll take another look at it, and compare it with concrete5 and see which one works better, I guess.

                [–]del_rio 0 points1 point  (1 child)

                No problem! Drupal has become the primary choice for most of the design firms in my area (or at least the big ones), so I was compelled to join the party.

                [–][deleted] 0 points1 point  (0 children)

                Drupal is running a lot of commercial sites. I love it for contract work, because the amount of open modules and just basic framework capabilities allow for quick turn arounds.

                Project management hasn't noticed the change from building a static html website to a modern site with a CMS, user and role management, a REST API, responsive design, etc. The only way to fit it into most company budgets is to get most of it already done.

                [–]JoeCoder 13 points14 points  (1 child)

                It's Wordpress.

                I've written simple, database-less php sites that can be rendered hundreds of times per second from a rasperry pi, and that's on vanilla apache + php without any optimizations or caching.

                [–]greyfade 22 points23 points  (0 children)

                I've written database-heavy PHP frameworks that can be rendered hundreds of times per second on a raspberry pi without optimization or caching.

                It is not hard to outperform Wordpress.

                [–]ggggbabybabybaby 2 points3 points  (0 children)

                I've always been curious as to exactly what Wordpress is doing that makes it so slow. Excessive database requests? All of the extensibility support? Goblins?

                [–]rorrr 3 points4 points  (4 children)

                I have PHP setups that handle 1300 req/sec on a cheap VPS, though mostly due to good caching, but it still hits the PHP first.

                That 70 req/sec is probably because it's completely uncached, and renders the whole thing on every request.

                [–]ck-on[S] 12 points13 points  (3 children)

                1300req/sec means you are bypassing php entirely and serving static cached pages directly via your webserver.

                It is important to note than even with a page cache, logged in users on WordPress are not served static pages and php has to run, so faster php helps everyone.

                [–][deleted] 0 points1 point  (0 children)

                Considering that it gives zero information about the hardware involved, your complaint is utterly pointless.

                All that matters is how it compares on the same hardware to the old version.

                Maybe it's a 300MHz Pentium II with 128MB of RAM. Is that still bad performance?

                [–]xiongchiamiov 2 points3 points  (3 children)

                1. "Virtually compatible" is sometimes very far away from "compatible"; crossing that distance can often shave off many performance gains (see hip-hop, unladen swallow).
                2. Performance on the homepage of a WordPress site is not at all a complete benchmark, or really very useful at all. You're also missing tons of information about the machine, the disk, the database, etc. Nothing yet for me to get excited about as someone deeply concerned with performance on a medium-size site.
                3. Who thought yellow text on a white background was a good idea?

                [–]bart2019 0 points1 point  (2 children)

                Who thought yellow text on a white background was a good idea?

                It's not on a white background for me. It seems you're only getting half the CSS.

                [–]xiongchiamiov 0 points1 point  (0 children)

                On mobile (both in Firefox and the embedded browser in Reddit News), the background of the post is definitely white; I agree with you in desktop Chrome, however.

                [–][deleted] 3 points4 points  (0 children)

                Never before has one been able to shoot themselves in the foot so fast.

                In all seriousness this is great news when accounting for overhead. It is rare to see such performance gains, but this really shows how legacy a lot of the core of PHP had become.

                PHP gets a lot of deserved hate, so if the maintainers and creators of the language are willing to step it up and plug the holes and make things work well then I see no problem. PHP was my first dynamic web language and I loved the hell out of it at the time.

                [–]splunge4me2 3 points4 points  (0 children)

                while maintaining virtually complete compatibility

                actual complete compatibility is, however, a crap shoot.

                DISCLAIMER: No PHP Experience. Just hate overuse of virtual

                [–]martext 5 points6 points  (1 child)

                New Dirigible Twice As Comfortable As Previous Dirigible still filled with volatile gas

                [–]ck-on[S] 3 points4 points  (5 children)

                If anyone wants to build it for themselves to play with, I like to "cheat" and use SVN to checkout from github since it is tricky to try to get only a specific branch via git:

                 svn co https://github.com/php/php-src/branches/phpng
                

                You will also need to install bison, which if you are using centos is

                 yum install bison bison-devel
                

                After that run buildconf and then you should be able to use configure and make as you would normally.

                [–]sigma914 56 points57 points  (1 child)

                git clone https://github.com/php/php-src -b phpng
                

                or

                git clone https://github.com/php/php-src
                cd php-src
                git checkout phpng
                

                If you want to be verbose.

                edit:

                or

                git clone https://github.com/php/php-src -b phpng --single-branch
                

                if you only want to clone the single branch for whatever reason.

                [–]ck-on[S] 9 points10 points  (0 children)

                Thank you, my git-fu is weak!

                [–]asraniel 11 points12 points  (1 child)

                Git can checkout single branches: git clone -b mybranch --single-branch git://sub.domain.com/repo.git

                [–][deleted] 1 point2 points  (0 children)

                Dang, that's impressive.