Ugh. I am so tired of defending PHP - even from people I know and respect and who use it every day. So here I'm going to make my last stand. In all future arguments I get into, I will point back to this article as my sole defense.
Before you read further, you have to understand that "the curve is a circle", and those who appear to be beneath you may in fact be your superiors in a given field of expertise. Never forget this.
Need proof? Here it is, broken down by category:
Now, here are some common complaints about PHP, and why the don't matter:
News flash: static typing sucks - deal.
Oh noes! Seriously, this is a theoretical objection, not a practical problem. Use a class dude - makes for a nice way to wrap your functions.
Globals can save your life. Globals pierce through all the layers of code and get right to the heart of the matter. You say you don't like globals, so try to remember that the next time you grab a singleton from your static factory.
I call shenanigans on that one. PHP appeals to a broad audience, especially new coders, because it is ubiquitous. It's just as easy to write poor code in any other language (an Interface with exactly one Implementation anyone?)
In summary - I'm really tired of having to defend PHP. I feel like I'm the only one here. Even the developers I know that use it on a daily basis speak ill of it. Whatever.
There are plenty of reasons we all keep finding ourselves drinking from the PHP watering hole. If you don't like the taste, you're welcome to leave at any time.
Got something to say?
Sorry, comments are disabled.I totally agrees with you. I find right at home using pl/sql, PHP, even if I use c#, java or asp.net from time to time. Php is and stay my main coding language, and you can code well and fast with it.
The peoples talking about big projects and deficiencies in those case just don't want to adapt the code to the language.
I've worked on rather big web site, ported from jsp to php. It was a 4 years project, and in the end, the php rewritten version is lighter, faster but more complete than the previous jsp.
PHP is versatile, have a short learning curve and is extensible easily. And I love it for exactly those qualities.
--Thierry 03:58, 24 January 2008 (MST)
If there was one perfect language then we would all be using it. Case in point: http://99-bottles-of-beer.net/
I like ColdFusion, you like PHP, some guys like Java, others like C#, .... All of them are good fits for some projects and not so for other projects, you have to find the right hammer for the job.
--Kris Brixon 07:24, 24 January 2008 (MST)
You are not alone ...
--Moisés 07:45, 24 January 2008 (MST)
Why do you think they do that ?
Too freakin many people consider themselves PHP programmers(in fact to many people consider themselves * programmers).
:P
--iongion 07:57, 24 January 2008 (MST)
And what do you have to say about Unicode support?
--uQQ 08:29, 24 January 2008 (MST)
you are not the only one :) php is great for getting things *done* ; let those theoretical guys crap in the margin with their highly advanced languages.
--frank 08:32, 24 January 2008 (MST)
I've pretty much given up defending PHP. Once upon a time I used to get drawn into stupid arguments about PHP vs Java/Perl/ColdFusion/ASP/whatever.
Now when somebody says "PHP sucks because of X. I only use Ruby/Java/whatever". I can't even be bothered saying "Yeah, that is why every web 2.0 app other than Twitter uses it."
PHP is a very effective tool for solving a set of real world problems. Whining about details is just not that important.
--Luke Welling 08:33, 24 January 2008 (MST)
@Greg: he, I like Haskell too, but I make my $xx.xxx/month money using PHP as no-one wants Haskell; they want to use stuff they can deploy fast and anywhere. And the scale thing; I am working with two apps in PHP over 500.000 lines each; they are written well and thus maintainable. Ofcourse it is easy to write crap, but you don't have too. And no you won't port a Cobol banking mainframe to PHP, but it surely is not a 'rule' that all big php apps are bad.
--frank 08:36, 24 January 2008 (MST)
I agree. The better gauge of a language is how long you've worked with it, and what sort of libraries and toolkits are available for it, not how 'new' it is, now much hype surrounds it, or how idiot-proof it is.
--ws 08:53, 24 January 2008 (MST)
It integrates into Apache with a mod, rather than requiring a special web server for it, or CGI, like some languages I know.
--Volo Mike 09:03, 24 January 2008 (MST)
Dont worry about defending PHP.
Its a good starting language, lateron real men turn to proper languages - python or ruby. ;)
--she 09:03, 24 January 2008 (MST)
I love PHP, but:
It sounds like you've never worked on any major PHP (or any other) project if you call these things irrelevant.
PHP has it's downsides. Deal with it.
--Rick 09:38, 24 January 2008 (MST)
PHP is a good language. I agree with you. I think anyone that would disagree has crossed over to the religious zealot side of programming. A language is a language, use the one that works best for the task at hand. PHP is really good for making websites with plenty of open source code available.
--Rich 09:40, 24 January 2008 (MST)
If you use something other than PHP for Web development, you should do the world a favor and drown yourself in the Arctic Ocean.
--Joel 09:55, 24 January 2008 (MST)
I use PHP daily and love it.
The only thing that has always bugged me about it is having to use special arbitrary precision match libraries to do simple floating point operations without getting weird rounding errors.
It's good to see someone defending PHP!
--Marius 10:00, 24 January 2008 (MST)
You forgot one more thing: deployment. Compared to other platforms, deploying PHP apps is a breeze.
People should stop bashing PHP just because they don't know how to use it right. PHP is like a dirty whore, it does it's job well, quick and you just want to get in, get it done and get out.
There's no need to juggle with OOP mess, ORMs (they tend to be half-assed OO approach to RDBMS which SQL can do just fine and I dream SQL, so screw you), templating systems (PHP is a templating system in itself, you just got to know how to properly separate concerns).
Remember, just because you can't do it properly, doesn't mean the tool suck, most probably it's because you suck.
--wageslave 10:09, 24 January 2008 (MST)
I've done quite a bit of PHP myself, and I will be the first to agree with many of the positive points that PHP offers. Considering the current landscape for doing web applications, I can appreciate how PHP simply because it is:
Having said that, I don't work with PHP these days, and it's not because I jumped on the Ruby/Rails bandwagon.
I personally think PHP is a very quirky dynamic language with some serious fundamental flaws.
One flaw that you dismissed as a "theoretical" objection and not "practical" is one of the key reasons why components are so broken and don't work with each other in PHP.
Want to use LibraryA with LibraryB? Well, you'd better hope they both declared wrapped their functions in classes with unique names, and let's hope they both don't use generic class names like "Record", "Field", etc.
I can see how namespaces aren't a big deal if you're writing everything from scratch, but if you have to integrate other people's source then you're going to have problems.
I'm not saying they're not unsurmountable problems. After all, you can always modify LibraryA's source code and rename everything so it doesn't conflict with LibraryB. If you like doing that sort of thing, then you'll probably get a lot of practice when you decide to upgrade from LibraryA v. 1.2 to LibraryA v. 1.2
PHP is good for doing small/medium websites. It performs relatively well (as long as you're not loading up your pages with too many features, or using some horrendously bloated MVC library like CakePHP)
Personally, I think you should explore other languages and try new things. If you haven't found lot of fault with PHP yet, then I'm inclined to believe either:
In any case, learning new languages can only make you a better PHP programmer. Right?
--Steve Goguen 10:15, 24 January 2008 (MST)
A lot of what you say is irrelevant. Basically you say PHP is awesome because you like it, no one objective argument. There is obviously no reason why is better to have only associative arrays, for example. And yes, no having namespaces or package equivalent is a bad thing. You should grow.
--OMG 10:19, 24 January 2008 (MST)
Zend_Search_Lucene_Search_Query_Boolean Yes no need for namespaces. They can just be included in the class name. If they aren't needed then why are the coming real soon now?
--Samus 11:11, 24 January 2008 (MST)
I couldn't fit my thoughts here, so I put them on my blog instead. Check it out at http://codermanwrites.blogspot.com/2008/01/php-sucks-balls.html
--The Coder Man 11:25, 24 January 2008 (MST)
HA!
--That's what she 11:30, 24 January 2008 (MST)
It's a language... a tool used to manipulate a logical computer to solve illogical real world problems.
You can't argue with someone for liking one language more than others... Jimbo's only defending a language; not bashing others. Personal attacks are unacceptable.
"The Coder Man": You obviously knew that personal attacks are unacceptable when you created your brand new anonymous blog. Your grandmother would be proud.
--pillowfactory 12:07, 24 January 2008 (MST)
I enjoy these types of discussions - it's only a matter of time before Godwin's Law reveals it's truth. Let me speed things up: you are all Nazi's.
With that out of the way, I am interested in what "huge" projects you all have worked on in PHP that lead you to assume that Jimbo hasn't done anything non-trivial. Let me enlighten you as to Jim's experience:
First professional job as a J2EE developer/architect/super-star for a top hospital software company (where we first met). This is a zero-tolerance environment - meaning - if you write code that makes mistakes, people can die.
Second job as a Ruby/Rails developer for a search engine marketing company for high-throughput search arbitrage. Think massive number crunching on millions of fields. This while working as a contributor for MediaWiki - the open source Wikipedia project (also PHP project)
Third professional job: http://www.mahalo.com/. A wiki-like search engine written entirely in PHP. Visit it. Does it feel fast? Responsive? Yeah - that's Good network+Jim+PHP.
The curve is a circle - just be sure you know what loop you're on before presuming someone is behind you.
--Eric 12:31, 24 January 2008 (MST)
The problem you have is that you try to come off as a intelligent person presenting a reasonable arguement.
And then you do this: "News flash: static typing sucks - deal." So some guys says that static typing sucks, damn well you sure showed all those supporters of static typing a thing or two.... or maybe not..
Anyway I am of the opinion that people need to become less emotionally attached to languages and use what works for them. People dont think the same way and langauges dont work the same way. Use what fits you and your project the best.
I essentially learned to program using PHP and I recognize its strengths but it is not the end all and be all of languages. I feel that it is combersome to maintain in large projects but that is probably due to the way I think.
--Ed Coyne 12:35, 24 January 2008 (MST)
No language is free of flaws. If PHP is enough to solve most web development problems, that's enough for me. For the rest who are really worried about problems arising in less than 1% of the cases, they should use another language.
--Mohamed 12:41, 24 January 2008 (MST)
PHP blows donkey dick. I like a langauge that's quick and dirty and gets the job done.
--south of the border 07:04, 25 January 2008 (MST)
Hey Jim and everyone. I agree that PHP is a good enough language for many things, and this discussion intrigued me. So decided to put my 0.02$ in my blog [1]. I did it there simply because I needed several sittings to write it, and the blog portion of my site has been rather sparse up until this point as well. Regards,
--Charlie 22:25, 25 January 2008 (MST)
@Greg & other namespacers--
Check out PHP6 (http://snaps.php.net). It will probably take years to get PHP libraries to employ the namespacing features & to become more properly module-ed, but that doesn't mean you can't write modular, extensible, maintainable code now.
I think the real problem is that people working in other languages by definition haven't kept up with what PHP has been up to. PHP5 is far more robust than PHP3&4, and 6 seems to be PHP5 done right. What needs to end is the criticism based on programmers' impressions of PHP4.
If you have used (note: not "toyed with") PHP5.3 or 6, I'd be interested in hearing what your remaining complaints are.
--Joe 02:47, 13 February 2008 (MST)
I agree! With all the 'Irrelevant complaints'.
--Apokalypse 16:59, 11 March 2008 (MST)
> It's dynamically typed
Software experts are split over whether static or dynamic typing is better. So, for now, this feature is neither good nor bad.
> All arrays are associative (hashes)
This a bad thing.
> It's object oriented with a reflection API.
Most criticism about lacking OO support applies to only PHP 4 and earlier. PHP 5 has certainly gotten better. In fact, it has become rather Java-like. (Of course, if improvements to PHP make it more and more like Java, one might wonder why we don't just use Java in the first place.)
> It uses different operators for numeric addition (+) and string concatenation (.)
OK... Though certainly not a very impressive "feature."
> It supports eval() and lambdas (somewhat)
The use of eval, whatever language it appears in, is very bad practice. "eval" belongs in the garbage, right next to "goto".
> Can execute system commands and read from local and remote files (all one-liners)
Another feature that, though true, is neither unique nor impressive.
> Supports coercing scalars into boolean decisions (means you can just do if($x) instead of if($x!=null
This a bad thing.
> Usable in both web and command-line contexts
Yet another feature that is ordinary and unimpressive.
> It comes with a vast array of built-in functions to do all sorts of common tasks.
That PHP can do all sorts of tasks right out of the box is certainly a good thing. That all those thousands of functions are defined in the global namespace (with inconsistent naming conventions to top it off) is very, _very_ bad.
> Oh noes! Seriously, this [PHP doesn't have namespaces] is
> a theoretical objection, not a practical problem.
> Globals can save your life.
And here's the kicker. These two comments are very good indicators of your skill at developing software. How many lines of code do your projects reach? One-thousand? Two-thousand? How about 200,000+? And what size is your team? One? Five? How about fifty? I'd guess that your software hasn't come anywhere near that complexity. You're still in little league.
--Jeff 23:13, 18 March 2008 (MST)
Your argument is poorly supported. You should list things that PHP is good for that other languages are not. You haven't done that, you've listed a series of things that appear in lots of different languages. I'd also worry about your linking to static typing discussion - some of the points in there simply aren't correct.
Some of the complaints listed aren't irrelevant. Class names can conflict too, so they still need namespaces. Namespaces are just really useful and I have no idea why they didn't put them into php5. PHP does allow poor programming practises, it's more difficult to go from a weakly typed language to a strong one and it's more difficult to go from a OO lite language to a strong one.
In future, if you want to support PHP, you should present an argument that is well structured and argues reasonably on both sides. From reading this, you appear to be a "fanboy", who's opinions aren't based in logic but in feeling.
--Rob 06:07, 19 March 2008 (MST)
PHP's biggest flaw is the lack of unicode support. That doesn't mean it sucks but it is a big issue and will be difficult to fix.
I have to agree that classes are no replacement for namespaces but I'd argue that if you need namespaces in a dynamically loaded web application then you are doing something wrong. If you are using a project that requires preloaded server code then it might be worth using something else for the backend but PHP would do fine for the dynamically loaded code.
As for the quality of code issue I've often said that programming should be a licensed profession. Anybody would still be able to write code however to call yourself a programmer you would have to have met the proper educational qualifications and been tested properly to ensure you at least have the basics of coding properly.
--serp 17:09, 23 March 2008 (MST)
> serp:
> ...but I'd argue that if you need namespaces
> in a dynamically loaded web application then
> you are doing something wrong.
That doesn't make any sense. I don't think you understand what namespaces are for.
Imagine there is a library that implements blogging functionality. Your program would interface with that library through a single class, perhaps "class Blogger". But that library would be composed of several other classes that it would use internally. A "class Post" would undoubtedly be one of them.
Now also imagine another library that implements bulletin board functionality, perhaps "class BulletinBoard". That library would also be composed of several other classes that it would use internally, such as "class Post".
The problem now, of course, is that both libraries define a "class Post". These would conflict with each other and couldn't coexist. The only way to avoid this problem, for now, is to give our classes excessively long names, such as "class BloggerPost" and "class BulletinBoardPost".
Namespaces would let classes with the same name be distinct without resorting to crude naming schemes.
--Jeff 14:25, 24 March 2008 (MST)
The way I see it: Don't let them get to you when they are bashing PHP. I recently looked at the job market, and PHP programmers are able to find jobs that start at 70k per year. Not bad for a "lousy" language. The less people know, the more they will bash, and the more my knowledge will be in demand by those who don't care what language you use, so long as it works.
Let them complain. More money for me.
--Jon Harris 09:49, 2 April 2008 (MST)
No one ever said PHP doesn't have a market. But, that PHP succeeded in the market says very little about how good it is. Plenty of good products lost, or never had, a strong market presence. (Apple and Betamax are the two commonly known examples.)
And your claim, Jon Harris, that the less people know, the more they bash, is nowhere near true. Plenty of extremely intelligent programmers -- programmers who have used several languages and understand what leads to good or bad software -- have also "bashed" PHP.
I could even go so far as to argue that the less people know, the more they defend. Like Jimbojw, the author of the original post, who clearly didn't understand what namespaces are for while he defended their absence in PHP.
--Jeff 12:10, 5 April 2008 (MST)
I beleive i'm on the bottom of the circle.
Make of that what you will.
P.S. Anything that harbors bad programming traits especially in the field of maintanibility is obviously the tits.
I guess that comes down to the person using the language in a practical way. It makes more sense to me to use a more practical language, but whatever floats your bloat.. err boat.
--AmbiguousCoder 12:45, 14 April 2008 (MST)
I have to agree. I started developing using c and then C++, php was the natural extension into web development from those skill-sets.
I have also worked with ColdFusion 8, and had the opportunity to work on some large projects with it. And I have to say...
I can't put one ahead of the other, but all in all, PHP does a better job of most things. Mostly because you have full control of it. PHP was initially meant to be a web scripting language for ACTUAL programmers. Honestly, I think that if you are the kind of programmer that needs a programming language that forces you to write structured code, than you shouldn't be developing.
This topic hits close to home because I am sick and tired of looking at code-bases that are written in PHP,CF,ASP and they are just crap. One big problem in this industry is that it is just like all the other industries. Once there is hype about a framework (ala CakePHP and Model-Glue) everyone jumps on the "best-practices" band wagon, no matter how dumb that decision may be.
I spend every day watching CF developers taking hours to do something in Model-Glue + Reactor + ColdSpring, when they could have done it in 30 minutes had they developed an actual useful framework themselves.
There is no better language, I have come across many instances where one does something better (easier) and vise-versa. The real difference is coding style and structure. All languages are good in their own right, and do things better, they each have their ups and downs.
--Anthony 11:02, 22 May 2008 (MST)
First of all, let me say that most of the serious problems with PHP aren't apparent at the small scale. If that's where you've been operating, it's no surprise and no shame that you haven't noticed them. But they are real problems to the people who've reported them to you, OK?
Disambiguated operators and system commands are nice if superficial, but the rest of your Language Features are all serious flaws.
Your reference only covers the problems with Java's type system, it doesn't apply to static type systems in general. (that static types "aren't real" is fairly general, but by that definition, programs aren't real either!)
Classes and namespaces are not the same. This is a practical problem once you need finer-grained layers of modularity.
I don't want the heart of my code pierced by globals or anything else. They only save you from your former self at the expense of your future self. Singletons are scarcely better - they are rightly deprecated.
Have you tried writing bad code in Haskell? Yes it can be done, but trust me, it's a whole lot harder.
In the end, the only defense you need is that people pay you money to write it. But remember that the other people doing the complaining aren't necessarily the ones who made the choice to use it.
--Greg Mildenhall 02:03, 24 January 2008 (MST)