Live data from Hacker News

I Like PHP

beust.com

91–100 of 269 posts

Re: I Like PHP

#91
I'm just glad we're at this point where there are so many quality languages and frameworks available that we can fuss over which one is best. That is all I'm going to say on the subject.

Re: I Like PHP

#92

> I write PHP code very sporadically Explains it. PHP is fine if you jump in, write a few lines, and then don't ever have to maintain it yourself. Woe to the guy who does have to maintain it.

Absolutely, and I'm sorry if my article didn't carry this point across.

I would never use PHP for anything big/complex, my post was mostly in response to the universal sneering and mocking that PHP always gets. I think it's unjustified.

Since I only modify my web sites a few times a year, I am pretty sure that I would be much more reluctant making these modifications on a RoR app than a PHP one.

Re: I Like PHP

#93
Where I work, we've standardized on PHP and I have no choice but to use it. It isn't as bad as people say that is! Our organization's product is a large application written in object-oriented PHP with unit tests for every method of every class. As a team, we use continuous integration and have regular code reviews to promote quality. We've done some things that we're not proud of, but on the whole our codebase is pretty clean and elegant, and at the end of the day I'm almost always proud of the work I've done.

What worries me about PHP is that innovative ideas don't appear to be coming from the PHP community. They come from Python, or Ruby, or Erlang, or Java projects and are copied by PHP developers afterwards. I worry there's a risk that PHP is being left behind as the developers who solve new and challenging problems turn to other languages.

Furthermore -- and this is just my sense of how things are where I live -- while it's possible (and not even difficult) to write quality PHP code, it seems to be difficult to find developers who care about quality. My manager complains about this constantly and I'm inclined to believe him since, when I was a freelance developer, I saw tons of PHP code that was simply and unambiguously terrible. Conversely, a developer who wants to write quality code in PHP has to look pretty hard to find a PHP shop that recognizes quality and values it. I suppose that these issues aren't tied to a particular language, but they seem more pronounced with PHP.

Re: I Like PHP

#94

Earlier quoted context omitted.

Here is some PHP code: $x = "0"; if(!$x){ echo "0 is false"; } If you understand why it's crazy that PHP prints "0 is false" when you execute that, you're probably better off jumping ship now. If you don't, you'll probably appreciate the low barrier to entry for PHP more than any benefit you'd gain.

Actually, here's a more insane version: $x = 0; if(!empty($x)){ echo '"0" is empty'; }

empty() is an alias for 'isset($x) && $x', so this example is semantically identical to the previous one (since $x is always set). PHP doesn't have any special concept of "emptyness" to check for.

Re: I Like PHP

#95
post #78

Earlier quoted context omitted.

> Did you ever read Python's documentation? Yes. it's rather fucking good. > Show me one popular web programming language which has a full page, up to date, with examples and user comments and version incompatibility info, per function. Have you ever read Python's documentation? In the last ten years? Python's docs have a complete and readable description of the language[0] including its data model and the various co…

Don't forget being able to do this from within the interpreter: >>> print abs.__doc__ abs(number) -> number Return the absolute value of the argument. >>> print xrange.__doc__ xrange([start,] stop[, step]) -> xrange object Like range(), but instead of returning a list, returns an object that generates the numbers in the range on demand. For looping, this is slightly faster than range() and more memory efficient.

Or from ipython, even better:

    In [1]: abs?
    Type:		builtin_function_or_method
    Base Class:	
    String Form:	
    Namespace:	Python builtin
    Docstring:
       abs(number) -> number
    
    Return the absolute value of the argument.

Re: I Like PHP

#96

PHP's greatest strength is that it doesn't require OO. Seriously, for most simple web application tasks (and even some complicated ones) OO adds more confusion than it removes, and I say this as someone who certainly sees the value in OO for complex apps. Most web apps are ultimately more like shell scripts or console applications than desktop/mobile applications. It's no coincidence that most of the former are writt…

A tricycles greatest strength is that it doesn't require balancing on two wheels.

For those who can't ride a bicycle, tricycles are great.

Once you understand how to use a framework/language like RoR, I don't see how PHP is more useful (unless you have size constraints). ActiveRecord::Base.connection.execute("SELECT foo from bar where x = y") is just as simple as mysql_query("SELECT foo FROM bar WHERE x = y"), and you get the benefit of abstracting away the database in database.yml so you can run it in different environments.

Re: I Like PHP

#97
post #42

me too, i like php. it's a decent templating language with some very advanced features. it even supports namespaces!

It's an XSS-prone templating language, as the default correct syntax for outputting variables is:

      
which is far from encouraging safe best practices.

PHP namespaces aren't any better: http://pornel.net/phpns

Re: I Like PHP

#98

There's a regular stream of "defending PHP" posts but they all seem to miss the point. No one bashes PHP because it can't do these things, or that it isn't easy. People bash PHP because there are objectively better languages and platforms out there and objectively bad decisions made by those guiding the PHP language. If you want to defend PHP in any meaningful way then you can't just list things that can be done easi…

The problem is that people go too far with the bashing- People tend to just sneer at anything PHP-related, and don't acknowledge that great work is being done every day in PHP. An app written in PHP by a 8/10 programmer is going to be better than an app written in (sexy other language) by a 7/10 programmer.

> An app written in PHP by a 8/10 programmer is going to be better than an app written in (sexy other language) by a 7/10 programmer.

Depends entirely on your metric. It's far too easy to introduce subtle bugs, especially security oriented ones, in PHP. If I had a dollar for every XSS, remote file inclusion, CSRF, arbitrary file read, etc vulnerability I found in a "good" PHP app, I'd be a very wealthy man. Some things are mitigated by using a good framework, but in most cases people get them horribly, horribly wrong.

Re: I Like PHP

#99
post #60

Earlier quoted context omitted.

...which leads me to think that the poster is confusing "mainstream" with "GoDaddy".

I'm not. I'm using a fairly "non-noob" ISP (ssh access, crontab, etc...) and they still don't give me access to much more than PHP. I can install Java but I can't even run it as a CGI because of the HTTP request memory constraints they impose. This is pretty standard, I don't blame them for doing this, and I would go with a VPS if actually needed all this. Same for Ruby on Rails, obviously.

I fail to see why "my ISP doesn't give me Ruby" --> "Ruby isn't mainstream".

To my downvoter, here's a list of "mainstream" providers, at the Godaddy-level, and language support:

Dreamhost: RoR, PHP, Perl, Python [1]

Godaddy @ $8/month: PHP, Perl, Python, RoR [2]

a2Hosting @ $3/month: PHP, Perl, Ruby, Python

That seems pretty mainstream to me.

[1] http://beta.dreamhost.com/web-hosting/ [2] http://www.godaddy.com/hosting/web-hosting.aspx [3] http://www.a2hosting.com/services/web-hosting/

Re: I Like PHP

#100
I submit that PHP's popularity has much more to do with mod_php and its ubiquity across cheap web hosts than any intrinsic merits as a language.

As someone who made a good living for many years by building stuff with PHP... I couldn't get away from it fast enough. Rails+Heroku is the new PHP, if you want a batteries-included web framework and easy hosting.

Not rhetorical: does anyone here use PHP for starting new projects?

Post reply on HN