PHP Sucks, But It Doesn't Matter

Oh, and no sensible Unicode support. How many modern languages, especially languages targetted towards the Internet, can you say that of?

@Rhys
oh ffs… What kind of developer are you talking about?! You can go on a rampage and blindly dump every .net control into an application and don’t care about the html code it generates… But it is lousy programming and it gets you to great examples of brainfuck code (http://en.wikipedia.org/wiki/Brainfuck#Commands) in any language!

One of the problems is that even some of the more well known PHP frameworks are kinda crappy… like karl mentioned CakePHP. That makes everyone who does not bother digging a bit deeper, or those who haven’t really looked into PHP for a while, think it’s a bad language that can’t be used to make anything nice.

There are seriously good frameworks too. Zend Framework combined with Doctrine ORM are a major win. They have some very talented people behind them.

Btw, if you listed all the classes/methods from the .NET Framework which begin with A, I believe it would be quite confusing =)

PHP hosting is cheaper you know.
That is why young web developers almost always use PHP.
When the app they built gets big, it becomes a problem. Thats it.

Joomla , my favorite CMS is written in php…
most popular boards (phpbb , smf, vbuletin etc) are written in php.
Myself I write some script in php.
I love the simplicity of it.
I love the incredibly big collection of function, that allows to do almost anything. I doubt for instance, that there’s a Levenshtein function in ASP.
Who would care if the “english human language” wasn’t perfectly designed, if you can express anything you want with it ?
That’s the same with the computer language php: I can program anything in php , and everything is well documented.

Yeah, those other guys create crappy PHP but mine is elegant and slick.

Ouch! Broke my eye winking so hard.

To all the people wanting to find more Python, Ruby, etc… on cheap hosts: these hosts will only install what their customers demand. And their customers will only demand your language of choice if there’s software they want to use that’s written in it.

So to fix the problem, write software people want to use in the language you prefer and release it!

no, no and no. PHP 5 has OO and exception handling similar to java and phpunit is very similar to junit (so unit testing is not a problem, only problem is that most of the php developers don’t use it).
Because PHP gives you a freedom to write your code in several ways (with php5 you can write pretty good oo stuff), it’s easier to write crappy code (or fortran).
I agree about php function names, they are very inconsistent and it’s annoying. One other thing i really hate is that there are no consistency about arguments: sometitmes it’s func1(needle, haystack) other times it’s func2(haystack, needle). Often you have to check reference just to be sure that you are using arguments in correct order.

There is one reflection strikingly absent from all the comments so far: why did ever PHP become the de-fact-choice of all web hosters? Well, it’s because of the off-the-shelf php appz, dood! (answer B: it’s because that’s what the devs asked to hosters). If you go back in time 10 years, finding php hosting would not be so easy. In other terms: demand drives offer - it’s just that hosting companies are slow to respond. If everybody asks for python now, they will have it cheap and easy in 5 years time.

I found the post very funny, but mostly agree with Ilia - a bad language is not such because of a humongous function collection or inconsistent parameter ordering. The online, user-commented php manual was php’s gift to comp science, and by itself it solves the function naming problem.

A good language otoh makes the simple things trivial and the hard ones simple. And few things can beat php at that (and few other communities have produce such a boatload of really, really crappy code that is still good enough to run the web).

I still enjoy PHP from time to time. It’s almost universally installed on webservers and if you need to make a quick web app it takes second to throw one together. Last year, I rescued a mailing list for a bar owner/friend. We created a simple 10 line query to pull the entire list into a csv file. Import into Excel and some clean up and now he’s got a useable mail merge for his office.

Over the years I backed away from PHP: 1) .NET developer jobs were paying 10K+ for equivalent positions. 2) I liked the cleanliness of having namespaces and real typed variables. 3) Until PHP5, OO felt like a loosely bolted on 5th wheel. It was there but few were using it correctly or at all.

I do believe there is less noise and better coders in the .NET camp. On the freelance level I was competing for cheapskate businesses who wanted good websites but paying scriptkiddy money.
My experience has been that someone that pays for a dedicated server, IDE, and SDK is heavily invested in their idea. Anyone can get a $10/mo server that does little more than PHP and MySQL and scoff at that idea that a good developer is going to cost $1000s

All programming languages suck. They just suck in different ways. The sensible programmer knows it’s all about ‘horses for courses’ and uses what’s appropriate for the task at hand.

Pascal and Ada are examples of a languages that were created to be philosophically pure. PHP and Perl are examples of languages that were originally created as duct tape to get jobs done. Oddly enough, the latter are more popular than the former, despite the objections of anal retentive purists.

Rather than bashing a language for its historical legacy, Jeff, how about you mention how you would make the best of things in PHP to produce a good PHP application. I’m sure that would benefit your readers immensely.

@mart:
I think you’re missing the point. It isn’t that PHP doesn’t have support for those - it’s that most PHP developers don’t leverage them nearly to their fullest potential. In fact, the PHP library itself doesn’t.

There is one big secret in software, which is known to everyone, who has some experience in the reading of code: the dominating majority of software is messy unmaintainable crap. There is another secret, which is known to ones who is used to read a lot: the code written with newest OOP concepts in mind is much more messy and unmantainable comparing with simple traditional procedural concept. It is so easy to replace one function call by another one. It is much harder to replace class hierarchies.

WOW JEFF!!!

I didn’t take you as a microsoft apologist, but saying PHP Sucks is ignorant… you can’t have it both way naming some of the biggest sites currently on the net and arguing that they all are using terrible langs is outright offensive.

Seeing how facebook was written by a couple of people they would’ve picked the best language available for them to achieve results… I’d hate to break it to you, but ASP is not a good solution, and I’d take PHP over ASP anyday…

To both gaetano and Joseph LeBlanc, it has nothing to do with the apps. The apps exist because the hosting exists.

Apache is the defacto standard for web servers, Apache runs PHP pretty efficiently on commodity hardware. PHP is easy to install, easy to maintain, easy to deploy to, and VERY easy to host.

Java, Rails, Django (I think?), and .NET cannot make those same claims. I know personally that a Java app written to the complexity of something like Wordpress would require its own server, not something a web host is going to be very interested in hosting for $1.99 a month. Rails on shared hosting is flaky at best (anybody ever tried it on Dreamhost? Not pretty.). .NET requires MS, in theory anyway, that means licensing costs.

PHP is everywhere because it’s cheap and easy for everyone.

The major advantage of PHP is that you never run into something you can’t do. At least I haven’t. And I do all kinds of crazy stuff. Websites, Intranet utilities, it talks to everything and with very little research it just works.

Rails? Ha! Waste of time. Only if you want to write nothing but blogs and demos (which most do). Sure it makes the designers happy, but I am not a designer. I want to do MORE.

Python is a fine alternative. I think it’s practically the same language with different syntax.

But yes, it is inelegant. Very inelegant. And how elegant your code is—is totally irrelevant.

functions are not part of the language, if you don’t like the functions name, it doesn’t mean that the language is not good.
It’s like complaining that C is a bad language because of the standard library, use your own functions, name them what you want.
I find PHP a great language.

As Bjarne Stroustrup once said “There are only two kinds of languages: the ones people complain about and the ones nobody uses.”

PHP is simple and fast. In many ways, due to the awesome online reference, it’s easier to figure out how to do complex things with PHP than with other more popular technologies like JSP/ASP. Also, due to the RAD design of technologies like ASP.Net (which I have done professionally since it was in beta), they are slow and clunky. Sure, if you avoid using postbacks and the control tree, you can reach the same performance levels PHP provides, but I rarely see that done. Because PHP writes directly to the response stream still like old ASP did, it encourages the old coding styles which in turn gives better performance. PHP’s lack of packages/namespacing is indeed a problem, but the only way to get rid of that is to fork the project into PHPlus or something like that, and organize all of the functionality into logical groups, standardize naming conventions, and re-release it with a converter program that will convert old PHP to the new PHP. Without a converter, it would be doomed to fail.

Dear Jeff,

PHP started as a language designed to add flexibility for serving HTML content on http calls. One http call = one run. This means for the complex web applications we are using now: you basically need to re-initialise the whole application on each call in one state, bring it to another state, output content and save the state, if necessary. This is inefficient. AJAX is only haf a relief because you need not to send the whole page anymore, just the bits that change.

For me, the problem is beyound: why do developers choose with PHP an application model for the system they want to create that does not support object caching and view-based state caching in an efficient way itself? For me, application development starts before: build an abstract software model and decide then, which kind of application model suits it best. And this is something you do not usually learn when learning to program.

So long - Tobias