Today's Question:  What does your personal desk look like?        GIVE A SHOUT

Why PHP Was a Ghetto

  KENNY KATZGRAU        2011-05-06 00:35:37       3,466        0    

Note: I wrote this over a month ago, but decided not to publish it until now.

I was talking with the Co-founder of a pretty cool start-up in DUMBO the other day about why the non-PHP development world generally has such disdain for PHP and the community surrounding it. He brought up an interesting point that stuck with me, largely because I hadn’t heard it before.

If you’re unaware of the usual beef most developers have with PHP, it tends to revolve around:

  1. Ugly syntax
  2. Lack of some necessary features that other languages have (prior to 5.3, namespacing, closures)
  3. Inconsistent function naming, usage, and other quirks
  4. Mix of procedural and OO-ness
  5. The fact that 80-90% of PHP projects are probably gigantic piles of shit

But his problem with PHP was a little different. He didn’t say the actual language was poor — he said it was the general culture surrounding the language, which is usually iconified by a language’s founder, that seems to encourage bad practices. That is, PHP code bases tend to be hacky and unmaintainable.

The concept that the community surrounding a language or framework embodies an author’s philosophy seems to be true. He brought up Ruby andMatz. Matz wanted a language that was easy to read and write, and enhanced programmer productivity. Don’t Ruby developers seem to harp on rapid application development and the elegance of their language?

Then DHH and the Rails came up. Then Guido and Python. So I thought: What about Rasmus?

Rasmus Lerdorf is an interesting figure. He created the original version of PHP, continues to contribute, is widely considered a demigod in the community and the authority on almost anything PHP. He steals masses of attendees at conferencesgets hired by big internet places, and garners the respect of everyone despite one glaring property: Rasmus represents what most non-PHP developers hate about PHP.

Rasmus generally promotes abstention from using frameworks, and the use of PHP as more of a templating language. To him, this translates to raw speed and scalability (load-wise). To everyone else, this translates to piles of procedural spaghetti code, and unmaintainable projects. For roughly 10 years following the birth of PHP in 1995, this was how PHP projects were written.

But another issue cropped up:  In it’s pizza-faced adolescent years (pre-5.0), PHP gained a serious following among novices. The language has a fantastically low barrier to entry, so anyone could get started in 2 minutes by downloading some self-extracting *AMP stack for Windows. Additionally, the acceptance of the MVC paradigm hadn’t really occurred yet in web development. What do you get when you mix n00bs and a lack of best practices? Unmaintainable garbage. And that’s what proliferated.

Don’t get me wrong — there were some great PHP developers around, even back then. But like I said, unrefined n00b-sauce was all around. When cowboy PHP developers with no standards got together to build a project, it came out looking like PHPbb, PHPNuke, or some other gnarled mash of .php3 files. But can you singularly blame PHP developers? No! The other web language giants, ASP and Perl, were also gross as hell and promoting the same spaghetti-code practices.

So why does PHP get a bad rap? Because of its legacy. And most old-time PHP devs who have fled to Python, Ruby, and Java haven’t really looked back to see what kind of development has happened in the language since the introduction of MVC on the web. Additionally, there were super-outspoken critics like “Ruby guy” Zed Shaw complaining of developers with “PHP-Infected Brains”, and the distribution of stuff like this on RubyInside.

PHP was a ghetto.

But the development of frameworks like Zend and CodeIgniter have greatly pushed the language development into the right direction. In fact, it’s been pushed in the opposite direction of where Rasmus would probably like to see it. Check out the Zend or CodeIgniter frameworks and tell me it’s not some of the best documented, most well-written code you’ve seen.

When most developers learned Ruby, they were learning Rails and MVC  at the same time. PHP was in use for a full 10 years before that. So there really wasn’t a period of time when heinous Ruby was being written by novices. There was an established standard in place for Rails, and the barrier to entry was a much higher, typically keeping less experienced developers out.

The fact is, a PHP applications can be as well-written as an application in any other language, and probably have the additional advantage of speed. The widespread use of MVC-style development in the PHP world is a relatively recent phenomena though, and admittedly, we can probably thank Rails for it.

So what does PHP have going for it now?

  1. Standards (not universal, but generally a flavor of MVC for most projects, and little procedural crap)
  2. A very low barrier to entry
  3. Speed & Scalability (maybe the best among script-based languages)
  4. A great unit testing framework
  5. Arguably the best documentation for any language

Additionally, it’s behind some of the internet’s most influential websites and tools, like Facebook, Digg, Wikipedia, WordPress, Drupal, etc. I’d bet that having a solid understanding of it opens more doors for a developer than any other.

If you don’t agree with the above, comment on this post, or email me — I’d like to hear why you don’t think so.

I’m no PHP fanboy — in fact, I’m very language-agnostic. I write PHP more often because, you guessed it, people pay me to. So it all comes down to this:

If you are capable of making wise software design decisions, PHP is a great choice to build your web application with.

By the way, if I just convinced you to build your next webapp in PHP, check out CodeIgniter. It’s the lightweight, no magic, ultra fast framework for PHP. When it comes to CodeIgniter, I am a fanboy.

4/4 Edit: I’ll be presenting a tool I wrote in Perl called ‘divvy‘ tonight at Hack and Tell in NYC. Here’s a video of a previous event (about 10 minutes in) where a developer plugs in his laptop to reveal Windows XP on his desktop (strike 1.5) and then admits to being a “PHP Coder” (strike 4). Is it me, or can you feel the judgment in the air? Maybe it’s me.

Source : http://codefury.net/2011/04/why-php-was-a-ghetto/

PHP  FRAMEWORK  MVC 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.