from Hacker News

The Lesser Known Contributors Who Are Trying To Make PHP Good Again

by DanielN on 10/3/12, 3:44 AM with 50 comments

  • by adaml_623 on 10/3/12, 8:13 AM

    Article title seems to imply there will be some info about the people who programmed these new features... instead there's a rehash of the new features and mention of a library or 2 that we could read about elsewhere.

    Author says, "the developers of these new tools deserve some serious recognition for the work they are doing" and then totally fails to mention them!

    So now we've again been suckered into the 'PHP good' vs 'PHP bad' non-debate.

  • by error54 on 10/3/12, 5:04 AM

    While I've bashed PHP as much next guy, these are the facts:

    -Take away PHP and the internet would break. The vast majority of websites are either written in PHP or have a PHP back end.

    -The LAMP/LNMP stack is by far one of the most deployed web server configuration.

    -PHP is extremely well documented and it's been around so long that it's easy to find solutions on the web.

    PHP is the Model T of web languages: people love to laugh at it because it's old and ugly but it nearly single-handedly revolutionized the landscape. I for one applaud any efforts to revive and improve this language.

  • by ericclemmons on 10/3/12, 4:29 AM

    Time to beat this dead horse again!

    PHP as a language isn't great, since it has been around the block in a volatile environment (the web) and shows lack of foresight in language design.

    However, PHP is experiencing a renascence with modular components, frameworks and tools utilizing established design patterns, and an overall boost in contribution and collaboration in the open-source community, in large part thanks to Github.

    PHP is not dead, and vibrant communities around Symfony and Doctrine are pushing it forward considerably.

    In my opinion, large applications can and have been built primarily on PHP while leveraging other languages and tools for their strengths.

  • by mseebach on 10/3/12, 5:55 AM

    PHP was never good, but it abstracted away some basic web specifics -- as opposed to CGI/Perl that required you to care about protocol details such as starting output with two newlines -- and hit a sweet spot infrastructurewise -- dead easy to get started with, dead easy to get hosted for next to nothing -- that gave it enough traction to grow very quickly.
  • by acabal on 10/3/12, 11:20 AM

    Those are all nice, but as a long-time PHP dev, the only way to make PHP truly better is to do a Python-style hard version bump. Rip off the band-aid, so to speak. Create an entirely new, consistent, object- or namespace-oriented standard library to replace the mess that exists now. The majority could just be wrappers for existing code, which is fine but just inconsistently named and parameterized. Then fix the terrible namespacing implementation, consolidate the jumble of operators (::, ->, ., +, etc.), add some syntactic sugar to objects (getters and setters?), add native Unicode support, and call it all PHP X or something.

    There's much to be said for backwards compatibility, and PHP does that really well; but there's also much to be said for a new generation built with the mistakes of the past in mind.

    I actually really like PHP despite its flaws. It gives the programmer easy, deep control over HTTP output, it's easy to install on new servers, it's easy to deploy (no compilation, just rsync everything!), it has decent built-in templating (if you can learn the quirks), it's OSS, it has rich libraries, rich documentation, and a rich community. But it's also deeply flawed and it deserves a break from the past.

    My ideal sort of web language would be something with C# syntax and libraries but with PHP-style OSS-ness, simplicity in output and compilation, and expressiveness in HTML. That would be nice!

  • by zdw on 10/3/12, 4:43 AM

    Everyone probably knows this, but PHP's Smarty template engine (http://www.smarty.net) is really awesome.

    I've yet to see a better one in any language - it has things like Unix-like pipe chaining of filters, user defined functions, and intelligent caching built in.

    I reduced the number of lines in one codebase I worked on by 70% through use of Smarty.

  • by jrockway on 10/3/12, 9:56 AM

    So does PHP not let you mock things by actually writing classes in the test file, like:

       class FakeFooBar(FooBar):
           def my_method(self, *args):
               self.last_my_method_args = args
               return self.result
    
       class TestFooBar(TestCase):
           def test_my_method(self):
               foobar = FakeFooBar()
               foobar.result = 42
               self.assertEquals(
                   foobar.use_my_method('hello world'), 'forty two')
               self.assertEquals(
                   foobar.last_my_method_args, ['hello world'])
    
    This is more verbose than mocking things out, but the control flow is more obvious and you don't have to rewrite the entire test case every time you change one tiny implementation detail (which is what I've had to do with every mox test I've ever written).

    Actually, it's not even that verbose compared to mox :)

  • by jey on 10/3/12, 4:16 AM

    When was PHP good in the past? (Honest question; I don't use PHP.)
  • by languagehacker on 10/3/12, 6:37 AM

    Those examples aren't good differentiators between PHPUnit and Phake. And unfortunately, despite how goot Composer it, it just adds another package management system into the mix. GitHub has ended up being the best package manager PHP could really ask for.

    I kind of view the native PHP development server as getting featural parity with Rails and Django. But it seems like that's a major gripe for developers who are averse to working with Apache or Nginx for being too complex.

    I'm very excited for traits as a feature. This is when we get into real language features other, more prestigious or "hot" web development languages actually have that PHP lacks. These result in true architectural deficiencies requiring annoying hacks to accommodate.

    In the end, PHP itself benefits most from expanding its capacities as a logical formalism. Tools are great, but they're also a lot less easier to get right.

  • by lunetics on 10/3/12, 4:37 AM

    You shouldn't forget about PSR-0 / http://www.php-fig.org/
  • by TamDenholm on 10/3/12, 12:15 PM

    To all the language bashers, can we all agree that a good developer beats a bad developer in any language?

    I wrote a post on this: http://news.ycombinator.com/item?id=4606961

  • by jentulman on 10/3/12, 8:41 AM

    composer is great, I'd just like to add that the docs make the distinction that it's a dependency manager rather than a package manager.
  • by eik3_de on 10/3/12, 8:56 AM

    Serious question: Do you know of successful/large web startups in the last two years that used PHP as their main language?
  • by gubatron on 10/3/12, 5:44 AM

    Again?