Live data from Hacker News

I Like PHP

beust.com

121–130 of 269 posts

Re: I Like PHP

#121

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.

Do yourself a favor. Never ever use wordpress as an example of a quality PHP application. Please look at the source code, the open source wordpress is a monstrous hack that has no clear architecture, has a terrible system of hooks that plugin authors regularly abuse and doesn't scale unless you write your own hack of plugin to override the db handler so you can do things like r/w splitting or sharding.

Re: I Like PHP

#122
post #7

Earlier quoted context omitted.

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.

This is still the main reason why I use PHP: the development cycle is just so fast, and if you are experienced enough to write good code without anyone holding your hand, you can do great work in PHP in a much shorter period of time when compared to most other platforms (at least the ones I've tried).

When people criticise the PHP language I think they really miss the point: it is the PHP platform that is really powerful because of:

1. The shared nothing architecture (it really helps you scale).

2. The rapid development cycle.

3. The portability (Apache, IIS, nginx, persistent in-memory interpreters via PHP-FPM...).

4. The huge amount of native C extensions providing amazing functionality.

Sure the language has warts, but who cares when the platform is this powerful?

Re: I Like PHP

#123
post #114
post #89

Earlier quoted context omitted.

This is unfortunately true. I'm a PHP programmer (currently writing a book, A Highly Negative Book About PHP , that I've been billing as "like Essential Java but tells you what not to do") and, I like to think, a fairly good one; reading this article made me cringe because this guy is emblematic of most of the problems in the PHP community. He: -accepts uncritically gobs of code dredged up via Google -considers somet…

From your description, it sounds like Crockford's "JavaScript: The Good Parts" to me.

For the record, "PHP: The Good Parts" is downright fucking awful. Apologies to the author if he reads this, but I'll buy him a beer and restate my opinion.

Re: I Like PHP

#124
PHP's one great strength is that it can be effectively used in a very wide range of applications. But doing that well requires using the language in ways suited to that purpose.

The problem with people "defending" PHP is that they often only use PHP for a very specific purpose, and describe PHP from that perspective.

Hacking quick and dirty procedural scripts, writing something like WordPress plugins or developing "enterprise" applications with frameworks like Symfony or Zend are entirely different ways of using PHP, usually done by entirely different kind of developers.

The unmaintainable crap PHP is infamous for occurs when less than mediocre developers only familiar with one approach apply those limited skills to a project that requires a completely different approach.

What the author describes is not "how PHP is supposed to work". It's just one of many ways PHP can work. (And certainly not my way of using it.)

Re: I Like PHP

#125
post #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 writ…

Can you please provide me a resource to learn how to fully separate the code from the markup? I learned web development on ColdFusion then switched to PHP. I certainly understand separation of content from design (HTML to CSS) but I honestly have no idea how to do web development without mixing markup (HTML) with the actual programming. I've done a little C and Java web stuff where my code printed HTML output - ugly.…

Some of the other responses link to good resources, but I want to point out that "separating the code from the markup" is the wrong question -- instead what you want to do is separate business/application logic from display logic. It's okay to have an "if" statement or a "for" loop in your markup (in fact, it's necessary for dynamically outputting content), just make sure those things are specific to the display of the data, and not the creation or retrieval or "processing" of the data. For example, gat all of your data from the database first, put it all into a simple array or simple variables, then just loop through arrays and echo variables in the markup. MVC frameworks will have you put the data retrieval and prep steps in another file altogether, but even if you don't do this, at least shove all of that stuff up at the top of the php file and then at the bottom do all of the markup/display stuff.

UPDATE: Here's a stackoverflow link with a zillion more examples and resources about this: http://stackoverflow.com/questions/62617

Re: I Like PHP

#126

>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 Except that PHP is terrible for systems programming?

And PHP has super-aggressive garbage collection and C has none. And C compiles to machine code and PHP compiles to optcode. And...wait a second, why are we comparing this two unrelated technologies again?

Re: I Like PHP

#127
post #113
post #89

Earlier quoted context omitted.

This is unfortunately true. I'm a PHP programmer (currently writing a book, A Highly Negative Book About PHP , that I've been billing as "like Essential Java but tells you what not to do") and, I like to think, a fairly good one; reading this article made me cringe because this guy is emblematic of most of the problems in the PHP community. He: -accepts uncritically gobs of code dredged up via Google -considers somet…

I'm convinced that this post is satire and the author has trolled us all. In fact, i reject any other explaination. Sticks fingers in ears . Lalalalala, it's satire, nobody is this incompetent. Lalalalala, can't hear you.

I really did consider that since the other posts by the author sound considerably more sane, but he's incredibly good at deadpan if so.

Re: I Like PHP

#128

Earlier quoted context omitted.

You haven't done much asp.net development I take it?

Not for many years, no. I'd forgotten about it. Still surprised I got voted down for that, since C and Java are still correct. In fact, it's what I hated about Java web development the most... You had to compile, package, and deploy every time you made a tiny change. It was a nightmare.

There are frameworks for Java that doesn't require you to compile / package / deploy for each change. One example of this is http://www.playframework.org/

Re: I Like PHP

#130

Earlier quoted context omitted.

You haven't done much asp.net development I take it?

Not for many years, no. I'd forgotten about it. Still surprised I got voted down for that, since C and Java are still correct. In fact, it's what I hated about Java web development the most... You had to compile, package, and deploy every time you made a tiny change. It was a nightmare.

Even in some parts of the Java world, that problem doesn't exist anymore.

The Play framework uses its own copy of the Eclipse compiler to compile everything on the fly while it is running in development mode...so as you as you save your changes, you can reload your browser and see them immediately.

Post reply on HN