Live data from Hacker News

I Like PHP

beust.com

21–30 of 269 posts

Re: I Like PHP

#21
post #17

One of the reasons I like PHP is that it still lets you get to a lower level of coding. Many of the newer languages and frameworks that have become popular in the past couple of years abstract things such as database connectivity away (Django is a good example of this) and it makes it difficult to optimize queries effectively without hacking onto the framework.

Most ORMs (including Django) let you easily drop-down into writing your own custom SQL queries when the need arises.

Re: I Like PHP

#22
post #15

> PHP is exactly like C. Either you like both or you don’t like either, there is no claim you can make about PHP that can’t be made about C as well, and vice versa * C is fast and has tight resource control * C is portable * C has a transitive (==) operator ...

I sort-of felt like this comment was added in his post to get the blood boiling a little.

I love his other points about PHP (as I too like PHP), but I felt this was one of those bold statements that was a little sensational and attention grabbing at best. I too find it pretty far fetched.

Re: I Like PHP

#23
"I don’t even bother writing tests for most of the PHP I write (obviously, I would be a bit more thorough if this code were destined to be used in a more mission critical web site). Not writing tests is not the only software taboo that I break when I write PHP: I happily mix up presentation and logic all the time. That’s just how PHP is supposed to work"

And this is why everybody else hates PHP. It tempts you to write bad code, and so most people working in the language end up doing so. I have to periodically stop myself when I'm writing PHP and make sure I'm not falling into bad habits. It's possible to write good code in PHP, and I know some people who do, but the pull to write sphpghetti is too strong for most. And there is no real corresponding benefit (aside from "noobs who don't care about code quality can still write programs") arising from the design choices that cause this.

Re: I Like PHP

#24
post #7

"There is nothing more exciting than modifying a file, hitting Refresh on your browser and seeing the result right away" I think this feature is definitely useful, but you can virtually do the same thing in other languages with templating engines.

With additional setup, yes, but PHP has a fast development cycle out-of-the-box which I think is significant.

This mind-bendingly important. In 1999, you could download one single installer on Windows, run it and with literally no further configuration you'd be writing PHP on an Apache/MySQL stack. No other environment even came close at the time and for a long time following.

Re: I Like PHP

#25

From the comments: "PHP is great for its purpose. Quick scripts that generate web content. It’s even OK for small applications. But just like C, PHP is lousy for the medium to large. Any software project with a duration in months or greater that is entirely in PHP is going to be painful." Like Facebook? Or Wordpress? Or Digg? PHP aint perfect, but it's demonstrably suitable for medium to large projects.

Is developing for Facebook not painful?

[deleted]

Re: I Like PHP

#26

From the comments: "PHP is great for its purpose. Quick scripts that generate web content. It’s even OK for small applications. But just like C, PHP is lousy for the medium to large. Any software project with a duration in months or greater that is entirely in PHP is going to be painful." Like Facebook? Or Wordpress? Or Digg? PHP aint perfect, but it's demonstrably suitable for medium to large projects.

Is developing for Facebook not painful?

Depends if you consider writing a PHP-to-C source transformer "painful".

Re: I Like PHP

#28
post #17

One of the reasons I like PHP is that it still lets you get to a lower level of coding. Many of the newer languages and frameworks that have become popular in the past couple of years abstract things such as database connectivity away (Django is a good example of this) and it makes it difficult to optimize queries effectively without hacking onto the framework.

Rails has two ways to do this. You can do any select query returning active record objects with

    Model.find_by_sql("raw select query")
And any query with a driver dependent result using

    ActiveRecord::Base.connection.execute("raw sql")
You can shorten the second one to simply "execute" by creating a method to wrap the functionality.

Re: I Like PHP

#29
post #17

One of the reasons I like PHP is that it still lets you get to a lower level of coding. Many of the newer languages and frameworks that have become popular in the past couple of years abstract things such as database connectivity away (Django is a good example of this) and it makes it difficult to optimize queries effectively without hacking onto the framework.

Don't confuse abstraction and formalization with convention with restricting low-level access. Most ORM frameworks allow you to drop down to direct SQL if you need to.

Re: I Like PHP

#30
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 easily in almost every semi-modern web ecosystem, but actually compare it to the other alternatives and identify when it's the right choice. It's harder but it leads to a blog post that might actually benefit readers.

Post reply on HN