Live data from Hacker News

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

danielnill.com

41–50 of 53 posts

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

#41
post #10

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…

PHP is extremely well documented and it's been around so long that it's easy to find solutions on the web. I can agree that PHP is documented. That it is well documented however is something I'm very much willing to argue against. PHP has string-operations documented to be "binary-safe" without ever saying what that is supposed to mean, if it's good (it's not), if it's bad (yes, yes, yes it is) and why you should hav…

It doesn't hurt that Microsoft is able to hire the best engineering grads, pay them 100k, and convince them that writing documentation for .NET is a better deal than building some pseduo cool product somewhere else at half the pay.

The very small percentage of php developers who have ever had to deal with binary data probably had their hands burnt enough to figure out what binary safe was. While I'm not arguing that documentation should have vague references, its not that hard of a tradeoff between just mentioning something that should be explained over pages, as opposed to not having it there at all.

Plus, the comments section makes it very useful to have examples and clarifications. Its not as bad as you make it out to be.

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

#42
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 :)

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

#43

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'])…

It does; it's just not very common.

Defining mocks manually is my preferred method. I find things like Phake and Mockery to be a little too opaque and hard to debug when you get subtle problems. I think they also add to the learning curve when getting new devs up to speed.

IMO one reason a lot of PHP devs avoid the manual method of defining mocks is just laziness.

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

#44
post #39

Serious question: Do you know of successful/large web startups in the last two years that used PHP as their main language?

I would be interested in the answer to this also, but I am coming from the side of expecting lots probably are.

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

#45

Earlier quoted context omitted.

I hate PHP and don't even want to talk about it but I did skim through the docs for Smarty. The rationale is that PHP sucks as a template engine, so why not create a new one and use PHP for the model-controller/whatever. Maybe that seems perverse, but you have stuff like Node.js in existence that oddly enough solves some problems quite nicely, so maybe it works for PHP guys. I'll never see the appeal compared to othe…

Completely unrelated: I'm not easily offended. Right now I'm not offended at all, in case anyone would interpet this post to mean so. I'm all OK. Really. But that said: I'm severely puzzled about your choice of HN username.

Breivik is a fairly common last name. There are actually 8 men in Norway who have Anders as their first name, and Breivik as their last name.[1]

[1] http://www.ssb.no/navn/sok.cgi?lang=n&fornavn=anders&#38...

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

#46
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!

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

#48

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.

I'm not sure that was so much the attraction when PHP first started gaining traction given the existence of CGI.pm

From my experience in the 90s, most of the early adopters of PHP were more smitten with included PHP code in otherwise static HTML files. It was SSI++

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

#50
post #19
post #9

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.

PHP is itself a template engine. Bolting a template engine on top of that makes no sense whatsoever.

PHP is not a HTML template engine. You have to run all your content through library functions to encode and prevent it from being interpreted as markup. That's essentially making your own half-baked template engine from scratch in PHP, and it would be just as easy in any sane language.
Post reply on HN