News for hackers. Stuff that matters.
Re:PHP Must Die by jacquesm on Saturday January 09, 2010 @08:56PM (#1042446)
Hehe, don't get me started :) How about:

- naming conventions

- globals (or, better yet, scope in general)

- 'objects' (I use the term lightly)

And a host of other things.

They could do a lot better still, but as long as nobody comes along and starts to make serious inroads into their user base I doubt this will change much.

What is surprising is not how much is broken, but how far they made it with so much stuff as broken as it is.

I've always thought that if python would have used braces, dropped the whitespace bullshit and came with a ready to go plug-in for apache with a similar ease of deployment that it would have kicked PHPs ass long ago.

Re:PHP Must Die by jrockway on Saturday January 09, 2010 @09:22PM (#1042488)
PHP appeals to the people that don't really understand programming, so I doubt making the language better in a programming-language-designer way is going to convert users. The next language that's as popular as PHP will be "easier" in some way that's appealing to average users.

Perl was there first; you could "require 'cgi-lib.pl'" and start writing a web application.

Then PHP made that even easier, by making HTML pages valid programs. (You could add code "later"; your scripts didn't have to live in cgi-bin isolated from plain HTML files.)

The average users jumped ship from Perl to PHP pretty quickly, despite Perl having more features, more modules, a better runtime, etc. They wanted to know as little about programming as possible, and PHP got them there. Inexperienced programmers want to micro-optimize for things like deployment or runtime speed, and PHP gives them that.

The next Popular Language will make one of those things even easier.

(Ruby on Rails almost did this, but it went overboard with the advanced programming language concepts, and is now a small niche again. It alienated the experienced programmers, who went with Merb, and the inexperienced programmers, who couldn't wrap their head around concepts like exceptions and just stuck with PHP, which lets you ignore errors if you prefix the line with an @ sign.)

Anyway, what I'm getting at is, "just leave the PHP users alone". Those that want something better will find it. Those that don't, won't.

Re:PHP Must Die by jacquesm on Saturday January 09, 2010 @09:38PM (#1042508)
PHP is used by plenty of people that (at least think they do, looking at myself ;) ) do understand programming, they just use it because they literally got used to it.

The perl community was pretty abrasive when I first looked in to it, the PHP community was the opposite so I ended up programming a large amount of stuff in PHP.

But before that I already coded my way around for about 15 years or so in lots of other languages, projects including cad systems, low level communcations drivers for weird bits of hardware, an OS and a whole slew of other stuff.

Basically my take on it was 'it's good enough for what it's for', web programming and making money.

To this day a good part of http://ww.com/ (possibly nsfw so don't go there if you are on your boss' line) is written in PHP, I've recently gone over the whole thing in order to clean it up readying it for a port to something a little bit more clean.

It was quite amusing to see how many hoops we had to jump through 11 years ago when it was first built compared to how easy you could do some of that today.

For plenty of people it is just a means to earn a living, language aesthetics and purity or expressiveness don't enter in to the equation, it is whatever their boss tells them to use, C#, PHP or Java.

And perl definitely suffered because of the attitude perl aficionados take, both with respect to other languages as well as to those that do not fully grok perl just yet.

Community is a huge part of any programming environment, possibly even more important than the language itself.

Re:PHP Must Die by jrockway on Saturday January 09, 2010 @09:51PM (#1042527)
Community is important, and that is the main reason why I tolerate Perl's various annoyances. There are simply a lot of Perl programmers that give me excellent code for free (see http://github.com/languages) and that makes it all worthwhile.

The same does not appear to be true of PHP. PHP's community is more talkative ("How to cut-n-paste code to hash passwords"), where Perl's is more programming-oriented ("Authen::Passphrase"). As a programmer, I prefer to stick with the programming-oriented community.

Re:PHP Must Die by plinkplonk on Sunday January 10, 2010 @07:18AM (#1042975)
"The perl community was pretty abrasive when I first looked in to it, the PHP community was the opposite so I ended up programming a large amount of stuff in PHP."

Interesting how the "feel" of a community dictates the choice of language. I thought I'd be immune to this effect after programming for 15 years but I recently chose not to use Clojure on an (eventually to be opensourced) project because of the "dumb fanboi" tone of a part of its community.(eg: http://www.bestinclass.dk/index.php/2009/10/python-vs-clojur... HN reaction: http://news.ycombinator.com/item?id=881642).

I chose to use Haskell instead (I like the "vibe" of its mailing lists and irc and blog posts and so on) and have been feeling a smidgen guilty about dismissing Clojure (which I think is really nice - I admire Rich Hickey's tech skills and design sensibility) for its community's stridency.

Seems I am not alone in my weirdness!

Re:PHP Must Die by gabrielroth on Saturday January 09, 2010 @10:38PM (#1042575)
This is exactly right. There's a lot of use cases where what's needed are variables, loops, conditional logic, and easy HTML output. In those cases, the winning language is the one that's easiest to learn and to deploy. Problems with handling invalid characters in octal are just not relevant in those cases.

Of course, those cases aren't interesting to HN, but they're common, and PHP legitimately wins in them.

What should die is not PHP but the use of PHP in circumstances where another language would be a better choice.

Re:PHP Must Die by jacquesm on Saturday January 09, 2010 @10:43PM (#1042586)
That is a very good way of sketching it, but even the last part is sometimes not the easiest to do.

I've written a 'media-player-annex-file-sharing-service' ( http://mxchg.com/ ), the thing has a web based front-end written in PHP and a C based back end for audio fingerprinting (so you don't end up storing 10 copies of each possible audio file).

When the time rolled around to write the scripts that glue everything together in the back-end I chose to do it in PHP instead of python for several reasons:

  - it reduced the number of dependencies

  - it removed the need to rewrite part of the code in yet another language 
    (mostly library stuff)
 
  - it removed the need for yet another skill in people wishing to modify it
Re:PHP Must Die by andrewvc on Saturday January 09, 2010 @11:08PM (#1042617)
Perl may have had a better runtime, but PHP was effectively faster since it had an easy to use apache module and most perl code was being run as cgi scripts, which is hardly performant. I remember trying to configure mod perl and mason circa 2002, and it was an excercise in poor documentation and pain. PHP was dead simple to setup. That said I still stuck with Perl (eventually moving to Ruby), and I loathe PHP.
Re:PHP Must Die by jrockway on Saturday January 09, 2010 @11:40PM (#1042661)
Installing mod_php:

  apt-get install libapache2-mod-php5
  a2enmod php
Installing mod_perl:

  apt-get install libapache2-mod-perl2
  a2enmod perl
But, in general, running app code in the webserver is a bad idea. This is why everyone uses fastcgi in production, and why every web framework (except PHP) ships a standalone dev server for development work.

PHP is the one that's hard to use now, unless you are developing on an already-configured system.