May 20, 2008
Here's a list of every function beginning with the letter "A" in the PHP function index:
I remember my first experience with PHP way back in 2001. Despite my questionable pedigree in ASP and Visual Basic, browsing an alphabetical PHP function list was enough to scare me away for years. Somehow, perusing the above list, I don't think things have improved a whole lot since then.
I'm no language elitist, but language design is hard. There's a reason that some of the most famous computer scientists in the world are also language designers. And it's a crying shame none of them ever had the opportunity to work on PHP. From what I've seen of it, PHP isn't so much a language as a random collection of arbitrary stuff, a virtual explosion at the keyword and function factory. Bear in mind this is coming from a guy who was weaned on BASIC, a language that gets about as much respect as Rodney Dangerfield. So I am not unfamiliar with the genre.
Of course, this is old news. How old? Ancient. Internet Explorer 4 old. The internet is overrun with PHP sucks articles – I practically ran out of browser tabs opening them all. Tim Bray bravely bucked this trend and went with the title On PHP for his entry in the long-running series:
So here's my problem, based on my limited experience with PHP (deploying a couple of free apps to do this and that, and debugging a site for a non-technical friend here and there): all the PHP code I've seen in that experience has been messy, unmaintainable crap. Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML, replicated in slightly-varying form in dozens of places.
Tim's article is as good a place to start as any; he captured a flock of related links in the ensuing discussion. As you read, you'll find there's an obvious parallel between the amateurish state of PHP development and Visual Basic 6, a comparison that many developers have independently arrived at.
Every solution I've ever seen or developed in PHP feels clunky and bulky, there is no elegance or grace. Working with PHP is a bit like throwing a 10 pound concrete cube from a ten story building: You'll get where you're going fast, but it's not very elegant. ... I love PHP, and it's the right tool for some jobs. It's just an ugly, cumbersome tool that makes me cry and have nightmares. It's the new VB6 in a C dress.
From my own experience, and the countless of online tutorials and blogs, many PHP developers are guilty of the same crap code VB developers were once renowned for. OO, N-Tier, exception handling, domain modeling, refactoring and unit testing are all foreign concepts in the PHP world.
Understand that as a long time VB developer, I am completely sympathetic to the derision you'll suffer when programming in a wildly popular programming language that isn't considered "professional".
I've written both VB and PHP code, and in my opinion the comparison is grossly unfair to Visual Basic. Does PHP suck? Of course it sucks. Did you read any of the links in Tim's blog entry? It's a galactic supernova of incomprehensibly colossal, mind-bendingly awful suck. If you sit down to program in PHP and have even an ounce of programming talent in your entire body, there's no possible way to draw any other conclusion. It's inescapable.
But I'm also here to tell you that doesn't matter.
The TIOBE community index I linked above? It's written in PHP. Wikipedia, which is likely to be on the first page of anything you search for these days? Written in PHP. Digg, the social bookmarking service so wildly popular that a front page link can crush the beefiest of webservers? Written in PHP. WordPress, arguably the most popular blogging solution available at the moment? Written in PHP. YouTube, the most widely known video sharing site on the internet? Written in PHP. Facebook, the current billion-dollar zombie-poking social networking darling of venture capitalists everywhere? Written in PHP. (Update: While YouTube was originally written in PHP, it migrated to Python fairly early on, per Matt Cutts and Guido van Rossum.)
Notice a pattern here?
Some of the largest sites on the internet – sites you probably interact with on a daily basis – are written in PHP. If PHP sucks so profoundly, why is it powering so much of the internet?
The only conclusion I can draw is that building a compelling application is far more important than choice of language. While PHP wouldn't be my choice, and if pressed, I might argue that it should never be the choice for any rational human being sitting in front of a computer, I can't argue with the results.
You've probably heard that sufficiently incompetent coders can write FORTRAN in any language. It's true. But the converse is also true: sufficiently talented coders can write great applications in terrible languages, too. It's a painful lesson, but an important one.
Why fight it? I say learn to embrace it. Join with me, won't you, in celebrating the next fifty years of glorious PHP code driving the internet. Just don't forget to call the
maintain_my_will_to_live() PHP function every so often!
Posted by Jeff Atwood
I used to write ASP and have been writting in Coldfusion for 6 years now. For the first time I took on a php side project and I have to say it is a headache! I'm glad I work with Coldfusion.
Unsuscribe. This post sucks more than PHP. Unscoped, unreal.
Did you, Mr. subscribed_guy, perhaps considering elaborating why this post sucks rather than getting offended and stomping out like a child?
It is amusing to read all of the comments deriding PHP for not being a "golden hammer". PHP is by no means a perfect language, but it does what it is designed to do rather well. It's biggest failing is that it tries to please everyone (and is becoming more bloated as a result).
You want Apache specific functions? There you go. You want MySQL specifics? Got those too. You want to integrate with .NET assemblies? Yep, there are functions for that.
I've only been using PHP for a short time now (working on a hobby project targeting a non-standard browser that does not support scripting), and the only real problem that I've had is that I've been spoiled by Visual Studio's IntelliSense. Since I'm not developing in it commercially, I'm not going to shell out for the official Zend Studio IDE. I've found two free IDEs that seem to work alright for me: Dev-PHP and HateML. It would be nice if the built-in functions were arranged in tiers rather than everything being global, but as long as it works, I'm not going to piss and moan about it.
I do object oriented PHP (PHP5 has classes) and redefine functions as appropriate. I'm mostly a C# developer and i don't have many complaints with PHP 5.
The OO choice is up to the developers not the language.
The problem with PHP isn't PHP itself but the fact that most PHP is the first programming/scripting language that many PHP developers use.
The effect is similar to the old days when some application developers received a VB6 lobotomy as their introduction to programming: they had no understanding of what they were *really* doing because the language was so free and forgiving. The end result was a beast that was so removed from solid programming fundamentals that it tore the soul to maintain and upgrade the code.
This also ties into the "Should you learn C++" discussion that Joel and Jeff have had. The answer, BTW, is ABSOF*CKINGLUTELY. Developers that understand C++ write fundamentally solid code, *regardless* of the languages (which is why C++ experience is a must have at my shop).
PHP doesn't suck, it's just amazingly inelegant. You can do everything nearly any web site needs to do using PHP and you can probably build it faster in PHP than any other language. That's not "suck", that's prioritizing goals differently than most other languages.
I like Python and Ruby much more than PHP because they are more elegant languages, but I can't do anything in Python or Ruby better or faster than I can do it in PHP.
It's tough to get into the minds of these folks. My current best guess is that learning a second language would be way too much effort.
Pfft, I've programmed in pretty much every major language out there, from FORTRAN and ALGOL-60 to C/C++, Java, ML, Python, PERL, and yeah, PHP. I pick the right language for the job (though ML is never the language, to be honest). I certainly wouldn't use PHP in most of the situations I use the other languages.
PHP is great for doing CGI. It was idesigned/i for CGI, and so it's no surprise that it's better at it than other languages.
Generally speaking, with traditional CGI, you have a program (in C, PERL, Python, whatever) emit a HTML page. In PHP, you have a HTML page with code naturally embedded inside of it (though you can invert it and think of the close tag as an emit statement). It more naturally fits the mindset of the programmer.
bThe most important thing in software engineering is preserving the good mindset of the programmer./b I think people get too caught up in trivial nonsense and forget this.
I wholeheartedly agree with you on this post, and here is why...
Merb - All you need... nil you don't.
This is going to be my framework of choice, of course it does use the ruby language (which is way easier to write/read than php, imo). It has taken all the things Rails have taught us, and improved upon them, not to mention slimmed it down.
No code is faster than, no code.
Its more lightweight, which means its faster than rails is, thread safe, and can handle multiple requests better.
Also it can use datamapper, check out this video, http://mtnwestrubyconf2008.confreaks.com/04katz.html
This article certainly exposes some of the worst aspects of php, along with some references that support the idea that php is indeed a sucker's language. But I must disagree.
Php has lots severe errors.
* Inconsistent function naming
* Inconsistent function parameters order
Php has some not so severe errors
* Not all libraries are object oriented
* Incomplete type hinting for functions and methods
* No hinting for class attributes
Php has some other false errors
* Not a fully object oriented language
* Not a type strict language
* Not a compiled language
This set of errors and apparent errors make the language look like it sucks for people not familiar enough with the language, strong paradigms about how a language should be, and a large set of unexperienced programmers.
But all this gives php several powers over other languages.
* It is very easy to face the language for new adopters
* It allows to get simple things done quickly and easy
And also some weaknesses
* It allows you to make a mess easily
* It requires discipline, not rules, to code well
So how to code well in a sea of poorly written php code when you are learning?
* Use some rules (any of them but use them)
* If you are going to scale code well
* Avoid coping the errors of the language
* Code using best practices, and use object oriented programming
* Comment, test, reuse, and all those good programmers voodoo magic
How to accomplish this if the language sucks?
R: The language does not suck, it just has its manners.
Php fully supports Object Oriented programming, Unit testing, Patterns, Some kind of overloading, caching, security and all that stuff people think about a good programming language.
* Wrap all the language inconsistencies in classes, and make them consistent, some day that will change, so be prepared.
* Use patterns like MVC (Model View Controller).
* Use Frameworks (either adopt one or make it).
* Type Hint your method and function parameters
* No namespaces?? come on, make an object and put your stuff in there. you dont depend on the instruction namespace for that.
Namespaces in php (correcting the global variables nightmare)
public static $names;
public static function set( /* String */ $name, /* Mixed */ $value )
if( !is_string($name) )
die( 'Fatal Error: $name must of type String on DemistifingNameSpace::set()' );
self::$names[$name] = $value;
public static function get ( /* String */ $name)
if( !is_string($name) )
die( 'Fatal Error: $name must of type String on DemistifingNameSpace::set()' );
There it wasn't that hard right?
well improve that class with comments, support for subnamespacing, better validation and some other cool stuff and you avoid collisions.
So to conclude, the languages does not suck at all, you got all those cool and well written frameworks, applications, and classes that can aid you to take away the pain to normalize the language errors.
So good look. and be a bigger programmer, not a bigger sucker, so they say.
11 years experience programming in C, C++, UNIX, Java, Perl, .NET (both VB.NET and C#), shell programming, VB script. When I first saw php I made an immediate resolution to avoid it at all costs. Why hurt yourself? It's like Perl, only worse.
Coders are funny. They argue that their language of choice is superior while no one gives a shit. I'll be retiring soon from my work coding PHP websites. I'm glad I didn't waste my time time learning what namespaces are. True, we didn't get the job when they asked our company to build Youtube (oh wait, no they didn't) but lucky for us most websites aren't that demanding.
Instead of learning OOPS or OOD or whatever the heck it's called you guys should take some business classes and find out what's important in the real world.
First off Jeff I have to say i often sympathize and cringe when you speak. I am a listener to the "stackoverflow" podcast injoy listening too. I know joel gives you a very hard time, and sometimes it is not warnented, but I’m afraid you just run right into it, stop defending the fact that you don’t know C and don’t need to, that’s like going to Europe and getting by only knowing English. You’ll be able to get done what you need and not die in the processes, but you’ll get beyond being just a Yankee hack. Don’t expect to get the best food (best libraries) or get advice on where to really go (the best spots). Unix and sourceforge are built on c libraries, and if you want to get out of the kiddie sandbox you need to know C.
This article is most or less correct. PHP is not an elegant language and it doesn't matter. All scripting languages are the same for me, getting stuff don’t is just a matter of using some guys library. the only difference is how much the language will get in the way. i know perl, php and python. Here are my views on each.
perl -- lots of modules, lots of ways people use them. i can write perl "ok", but i can't read it for shit, everyone who "knows perl" thinks they have to write everything in "perl sanskrit" and regexe's. great for other perl ninja’s useless for anyone who isn’t a born again perl developer.
php – PHP people feel that modules is just more shit to download, we'll just have _everything_ in the language but just not document it or support it through the versions. Want to start your coffee machine with your roomba, no fucking problem. Want to parse "xml", good luck figuring out what php5 actually supports, turns out 1/3 of the shit on the php.net page is out of date and useless.
python -- haven't used it enough to be as critical. but from what i can tell so far it has the module support perl does but a language that is simple enough that even perl fuck monkeys don't go making a bunch of unreadable python.
Sometimes Jeff you are right on the mark, and sometimes you are very badly off! At least the articles and the subsequent comments are thought-provoking. We could argue about language choices 'til the cows come home, but the startling point you miss is that PHP is open source and has been used and abused by millions of people. Download a LAMP/WAMP installer and it's MySQL and PHP all the way. This popularity and the number of frameworks available make it a great choice for web development for both consumers and businesses. The API is easy to navigate anyway and, if you're familiar with C (as any programmer really should be), half the basic functions are included, as most open-source languages are based on it.
It just then boils down to the fact that good, educated developers write good, elegant code, as opposed to hacking away. Python was developed to maximise structure and elegance: you're a .Net man, look at IronPython; it's implementation via the DLR is changing .Net from the ground up. And no, YouTube was already written in Python before Google bought it out. I can't believe Guido van Rossum commented on this article though, what a legend, keep up the good work!
This article is offensive in its naivety. Your gripe here isn't that PHP sucks, but rather that you suck at PHP. They are vastly different concepts.
There is nobody forcing the great web-apps of the world to be written in PHP. The reason it dominates is that it is a very useful language - and yes, the code is OO and maintainable when done by people who know the language.
I could spend an inordinate amount of time picking your points apart one-by-one, but for the sake of brevity I will instead say this: please show the programming community some respect and don't EVER publish a review of a language that you don't know how to program in. It's absurd and insulting.
Sorry for the tone... *takes a breather*.
Sometimes looking back doesn't tell you what's in front of you.
Suckiness is a relative thing. Compared to perl, PHP is brilliant. Back 7 or 8 years ago when all of the existing "big sites" were built it was an obvious choice, a no brainer.
Today, when all of the future "big sites" are being built using PHP to build them is simply retarded. When compared to real programming languages and frameworks available, PHP (an embedded scripting language, always was, always will be) doesn't compare.
It's worth noting that none of the "big sites" run on a Windows platform either which could be argued to be just as retarded.
Jeff, please don't repeat the misconception that YouTube is written in PHP. There's plenty of evidence that Python is much more used than PHP: http://www.gooli.org/blog/youtube-runs-on-python/ . Your point stands just fine with just digg, WordPress, and Facebook as examples.
If you don't change your post, people will start citing you as a source. And we wouldn't something wrong on the internet, would we? :)
Jeff I gotta disagree with you on this one. I'm an PROFESSIONAL PHP DEVELOPER, as the the spaghetti code thats about the coder not the language. I have well structured, highly optimized code, that other coders continuously work on without any complaint. Thus far I have had 3 C(#, ++) devs tell me they like my code.
Bottom line, it's too easy to do it wrong, there were even books teaching it the wrong way.
But I've seen action script 2 code that's a nightmare. Imagine the worst PHP, but now complicated by the fact that some code runs on frame 7 or 24 of a timeline. It'll make your brains hurt. :)
Blame the carpenter, not the hammer. Any tool can be misused.
I disagree but you are entitled to your opinion.
After having spent the last 10 years doing embedded C development, I recently tried some PHP and found it very liberating. Knowing that the language was viewed as very poor, I didn't try to do things perfectly right, I didn't worry about errors, I was able to guess at how to do things (since, many thing seem to have a C like interface) and I was able to get a quick and useful (to me) dynamic site in a matter of a week of starting my personal project. I think that really is the allure. The best part, it's easy to learn how to do almost anything in php due to the vast amount of information out there on the Internet -- think of something and it's already been done and explained too!
Just another case of kicking ass with the worst character in the game. ;)
Delphi for PHP does a very nice job of componentizing and adding some structure to PHP development.
PHP has some legacy it cannot jettison so easily, but I'm sure they will eventually. For instance, functions with bad parameter order, functions not loaded in namespaces, etc. I'm actually glad they don't to this to soon because otherwise all us PHP Freelancers are borked.
Frameworks (and things like a framework) are the only way to survive with PHP as a PHP Freelancer. Trouble is -- every year there's another favorite, and you end up getting clients who ask you, "Do you know the new X Framework? We only do our work with that." And that blows.
Most PHP projects I inherit are exactly as you state -- SQL and HTML sprayed into PHP instead of keeping it in its place, global variables popping variables into functions like variables out of nowhere, and not even a semi-useful naming convention that lets me know whether someone intended for a variable to be an array of strings or a string or a number or an object.
And, just like you say, it doesn't matter, because it's the PHP guys laughing to the bank. Just type in "PHP" versus any other language at elance.com (under Find Projects) and you'll see that, hands down, PHP is the number one language in demand right now in 2008.
coming from c++/java/c# is must say: you are so f*** right about PHP. it's a pain in the arse ... it's a mess. the first times i had to build something in php i got tears in my eyes.
but then - php hosting is widely aviable. ASP-hosting (i'd love to do webstuff with c#) is not. php runs on every hosting plan. and that's why i'm using it - i build a site and dish out many copies of it. i just can't afford the money/time to setup a ASP-server for every site i make :/
hell - MS do something about lowend ASP-hosting ;)
oh, and you can write clean code with PHP. PHP5 offers something that's like very primitive OOP. you can build object oriented code with php ... it's just like the language doesn't encourage you to do so. i implemented MVC in php and i'm using my framework now for every project i start. ok, it's far away from the comfort of c# or even c++ but i can avoid spaghetti-sql-in-spaghetti-php-code. (it's nor spaghetti-sql in OOP)
I think a big point of contention is in the ideologies in use. (disclaimer: generalizations in use)
There are essentially two camps of ALL software and web development: There are developers that work in the software industry (where products are made to be sold) and developers that work everywhere else (where projects are to be used in-house).
In the software industry, applications are written using the tools that produce the most elegant and efficient code with the most control possible (C++ and Java). This camp writes the code that works great but takes the longest time to make.
Everywhere else in the real-world, however, applications are written using the tools that will get the job done in the fastest possible way, albeit by sacrificing potential performance. This is the realm of the VB and PHP programmers, where "get it done" takes precedence over "make it fast (performance-wise)"
I would also recommend looking into the KohanaPHP framework (kohanaphp.com). It is a very elegant PHP5 MVC framework.
I was an ASP programmer for many years and then I did a few things in PHP and thought it was great because it seemed so similar to Classic ASP. But after moving to .NET, ASP and PHP really do seem like huge unavoidable spaghetti code mess generators. Every piece of existing PHP code I've seen looked like a total mess. I completely agree with your article.
Oh dear, another fucking designer writing about programming languages...
I love PHP. PHP5 in particular was a great improvement.
I think you're sort of right in saying it's a collection of abritrary stuff, and that it is often deployed poorly as 'spaghetti' code.
If anything it's this apparent lack of structure that forces me as a programmer to design my program properly. To use OOP properly, seperate files for each class and keeping a clear distinction between data, structure, and layout.
I've coded ASP.NET (VBScript), and was a proficient user of VB6 way back when. But more often than not I find PHP to be the right tool for the job, something so many people seem to stubbornly refuse to admit.
Unfortunately, VS.php is a tad pricey for hobby programming, and is only for VS 2005 and 2008 professional editions. I'm using VS 2003 Professional and 2005 and 2008 express editions.
Until I make a profit on software I write, I'm stuck with what I can easily afford.
The thing that depresses me most is that many amazing web open-source projects use php. I use Drupal and Gallery (because of cheap hosting) and I have to fix some things in them. To do that, I write php - language that I really don't like.
I'd better write C# or python, but then much existing code will not be avalable and I will have to rewrite them myself and that's even worse than fixing php.
You are right. And that's exactly my point of view !
PHP is kind of perfect for everything. It makes life so ridiculously simple, that all programmers think they'll go out of the job since a script kiddie can now make the most compelling web apps from their parent's basement.
Fixed: "You've probably heard that sufficiently incompetent coders can write FORTRAN in any language. It's true. But the converse is also true: sufficiently motivated, persistent and masochistic coders can write great applications in terrible languages, too. It's a painful lesson, but an important one."
"I also came to the conclusion that it is possible to write LISP in almost any language"
What is that supposed to mean? How exactly did you come to this conclusion? Please show us how you can create Lisp-style macros in PHP.
Hint: Greenspun's Tenth Rule.
= Some of the largest sites on the internet -- sites you probably interact with on a daily basis -- are written in PHP. If PHP sucks so profoundly, why is it powering so much of the internet?
May be because it facilitates doing things quickly. May be because not everybody earth is a fan of OOP. May be because of its extensive pear libraries. May be because user community around the language. May be because you can use zend/apc engines. May be because you don't need to reimplement everything from scratch. May be because it plays nice with other tools (memcached, mysql, ...). May be because you don't need expensive IDE's to write scripts. May be because its clone of C language with a $ sign before every variable.
I just can't get past having to put dollar signs at the beginning of all of my variables. What a PITA.
I couldn't agree more.
I'm a Java developer born and bred but I write PHP apps for a living.
So I use all my Java experience and knowledge and try to write Java style code in PHP. It helps to keep me sane.
While some languages are definately better than others I really do think that how bad an application is comes down to the coder.
I've written some horrendous stuff in C, and I've also seen some incredible code that makes me want to just chuck it all in and say "I'm not worthy!".
I think that given the best tools, the best craftsmen will create art. Given crappy tools the best craftsment will create someting pretty damn good.
Given the best tools a handyman will only ever create something that is well..... 'home made'.
So yes, PHP sucks. Writing in PHP sucks. Trying to get someone elses app written in PHP to work sucks so bad you could call it a black hole. But it's not a perfect world, and we just have to make the best of the hand we've been dealt. At least it is getting better, slowly.
" building a compelling application is far more important than choice of language. "
An excellent point. I'd take it further.
The language you program in is completely irrelevant to the user. Always.
The user will never care, they will only care if your application works, and does what they want it to do for them.
Far too many IT professionals forget this and get lost in the endless complexity (pretty and elegant it may be,) of programming and technology in general.
PHP contains to many functions - that's one problem you've described in your article. And another - PHP havn't strict convention for functions names (In pressent or in past? I don't know it exactly).
Solution: IDE customization
1. IDE contains (names, documentation, auto completion, ...) only functions, that you know and using.
2. Aliases for functions with one convention that you prefer.
Width this customization your a-functions listing contains less functions and you won't make whattheconventions_thisFunctionHave() typping errors.
Problems width ugly HTML+PHP+SQL spaggetis and so on are problems with:
1. bad programers and bad programming techniques - to many people programming in PHP, most of them aren't (and never in future will be) programmers.
2. Applications are more complex now. And PHP contains to little bricks (functions) to build a house (applications). Building from bigger bricks (using framework or higher type of programming language) is faster. The ASSEMBLER time is gone (no for 100%, i don't mean it exactly), so PHP time will sometimes.
P.S. My english is terrible, i think, but i do my best.
Anyway, Tim Bray has a problem with just about everything, so saying he's got a problem with x doesn't make x the least problematic...
Agree with the rest of the argument, though.
It's all about deployment. I've been migrating some of my own sites from ASP.NET to PHP, because I can host PHP for peanuts compared to hosting ASP.NET.
I use PHP with the CodeIgniter framework. The documentation (for both PHP and CodeIgniter) is complete, exact, easy to find, and accurate.
The strange part? Other than the syntax, my code looks like C# on ASP.NET, except cleaner.
I have libraries I re-use with every project (user library, custom database-based session handler allowing me to use PHP's natural session handling, a Page class that with minor tweaks will represent any generic page for any project).
My code follows MVC conventions (ASP.NET doesn't necessarily--looked at the SqlDataSource control recently? Embedding database logic in your HTML markup is an atrocity, whatever language it's written in).
Plus, I can build a website from a USB hard drive. Try that on IIS ASP.NET/RoR--it's an exercise in pain management, if it's even feasible. Not only do my development tools (syntax highlighting text editor, Firefox with all my favorite plugins, GIMP) all run directly from a portable drive without requiring installation on the machine, the server itself (a XAMPP installation including Apache, MySQL, PHP, and PHPMyAdmin) runs completely from the USB drive without any installation required.
In essence, I can plug in a USB drive and turn any Windows XP or Linux machine (yes, this software is duplicated on the drive for Linux) into a full web server, complete with development tools.
I'm not going to say much about PHP's shortcomings as a language. It has several, including the previously-mentioned monstrosities in naming conventions. But every language has these--for instance, Microsoft's FormsAuthentication.HashPasswordForStoringInConfigFile(string password, string hashType) method. There's so many things wrong with that function (which is duplicated in PHP's md5( $strToHash ) and sha1( $strToHash ) functions) that I don't know where to begin.
All I can say is that PHP works, simply because it is agile, runs on anything (including an embedded system with a whopping 200MHz of processing power and a tiny amount of flash-based RAM, as I found from one of my recent jobs), and it has reached critical mass.
One final note:
PHP developers are cheap and easy to come by.
Good PHP developers are moderately easy to come by.
Expert PHP developers are rare as hen's teeth and expensive, but the results will amaze you.
I just wanted to congratulate anyone whom actually reads this far down.
you hit it! the discipline! :)
"good for getting job done" is a strong and valuable argument but do not overestimate it. In this industry, the job isn't quite done when it's done ;) On the contrary, it just the begining. There starts all that maintenance that could turn into nightmare. And in many cases, it will be nightmare of someone else than the original author..
Youtube is written in Python. I've spoken to a youtube developer myself at Pycon. Many web apps use Regular Expressions to process the incoming urls which means they can resolve .php, .asp, .html or whatever else they want to. It may be to preserve legacy links.
PHP is nice because it just works. It can be tricky to scale up to larger tasks, but given that PHP is a language made initially for web development, HTML generation shouldn't take a lot of work. The only thing I use PHP for is developing smaller websites, a task which it is well-suited to.
"Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML" - this still holds true. One of the best examples of what's wrong with PHP is the echo and print functions. Both do the exact same thing, but neither has been eliminated. PHP needs a major restructuring.
Again, I agree that PHP sucks as a Swiss-army-knife language, but for building small-to-medium database-driven websites, it excels, and is practically purpose built. The functions for querying databases, escaping SQL, working with strings - they're all *there*. No dozen packages to import to gain the functionality. It's also nice for web development because there is very little casting of objects.
Essentially, it makes it easy to develop a web application. As far as writing good code, education, and frameworks like CakePHP and Smarty (templates) help.
PHP was the first language I learned, and I was able to quickly grasp programming concepts without being confused and encumbered by more advanced hindrances. I moved on to Java as my primary language, but I've recently been using PHP again to make websites. JSP is great for the large web application I work on, but PHP saves a lot of work when you really just want to start coding.
Dear Jeff Atwood,
Java had a lot of namespacing, n-tiering, and ooping etc.
while at the same time PHP had a lot of String manipulation Array digging functions etc.
This was the major differences once a time between both languages -and cultures- but now as Java has Collections Framework and PHP has developed a full functional OOP universe.
Being developing on the two platforms for the last days I can assure that when
in Java manipulating Strings I'm still sucked thinking how easy it will be in PHP...
and when in PHP dealing with fake threads I'm sucked thinking how easy it will be in Java...
Both platforms (I'm talking of what *really* I know) have they weakness and they strongness and critiquizing a Language for what others said or for what functions started named with * is not what the regular readers of CodingHorror are expecting.
And one real major difference is: the last thing I'm loving PHP is that is a real open language where all the concepts I learn while dealing with Java's frameworks, etc. I can easily transport to the next PHP app that I will develop but Java as is really strong typped and strong namespaced I can say the same.
Also one of the majors facts that let PHP success on a lot of 2.0 webs is the fact that the engine itself does not overload your apache neither your database, as the resources are sized and optimized at extreme reates.
Finally is true that the vast major developers niche for PHP are amateurism but this is again not a real reason to not to love PHP. All we had seen a lot of unmaintainable Java apps and we don't fall to develop again on this or that language for this reason.
I suggest to try for yoursef with http://www.symfony-project.org/ framework for instance or the ORM http://www.phpdoctrine.org/
I'm just trying to be honest about my deep misgivings with the PHP language. It has some rather severe architectural problems, more so than any other language I can think of.
Hmmm... can you list anything of note that you've ever built from PHP, or are you simply parrotting the work of others because you had a slow day and couldn't come up with an original idea?
foreach (simplexml_load_file('groovy.xml')-account as $account) foreach ($account-transaction as $transaction) $totals[(string) $account['id']] += $transaction['amount'];
You know what else sucks: just about everything!
It's just the way it is. Things suck so that when something comes along that actually doesn't suck, it makes it that much better.
P.S. Things that don't suck:
A cold Coca-Cola on a hot day
Swimsuit models (looking at them, not necessarily talking to them!)
Here is the thing, man. PHP doesn't suck. It just started as non-OO and later became OO. That's like critisizing C++ because people code C++ and use a C function library when they could be using an OO library.
The shitload of functions is inconsistent and not separated into OO, because PHP was supposed to be backward compatible. Sure, it started as a hobbyist language (actually it started as a scripting language by Rasmus Lerdorf) but it did exceedingly well to become a major programming language. It is on par with C++ and C# in its expressiveness, and often exceeds it.
As for people writing unmaintainable nightmare code in PHP... I guess C# sucks for the same reason, as does C++ and C. Perhaps no one should use these languages. Just because a language doesn't force you to use OO concepts does not mean it sucks.
There are so many frameworks out there. Some are better than Rails for Ruby. Why don't you use one of them before writing a post about PHP? :)
p.s. By the way guys, here's a PHP framework if you want to do AGILE php development. I wrote and am currently maintaining it. SHAMELESS PLUG!! :)
I'm just trying to be honest about my deep misgivings with the PHP language. It has some rather severe architectural problems, more so than any other language I can think of. Even my beloved, much-maligned BASIC.
Come on. BASIC is much worse than PHP :)
But I'm also here to tell you that doesn't matter.
Only if the amount of time you get to spend at home with your family also doesn't matter.
Go PHP! :)
Its terrible and suffers from the "a function for everything because I don't really have any libraries" problem... but its great fun, and the only server scripting language that I feel comfortable using for general purpose web stuff... the learning curve is tiny and the reference is good. So unlike ASP or Java I have to learn almost nothing to pick it up and use.
i.e. I use PHP cos I'm lazy. :)
I love how everyone gets pissy when you insult the language they happen to use. Hey, guess what, learn a few more languages and then you come to realize they all have weaknesses.
Your assessment of PHP reminds me an awful lot of Python - a slapped-together standard library that is wildly inconsistent but nobody seems to say anything because its OSS and that makes up for it. Or something. Its a shame, Python as a language is pretty elegant for the most part.
I rather enjoy these shaming posts. Hopefully there are some subset of developers that will realize that a big ball of mud is not acceptable as an architecture - regardless of perceived time constraints. Engineers make software that is robust, hack-jobs write things that "should work" and simply hope for the best.
I completely agree. I love php because it was my first web programming language, but as the years have passed and ive grown wiser, ive learned that its not the best constructed language. Its not even close. Actually its on the opposite end of approaching the worst...
Anyway, i agree with what you said, some of my best work has been in that crappy language so its not the language that makes the app great, its the person behind it.
Obvious troll is obvious..
PHP is just fine, if you can get past the inconsistent function naming conventions. Familiar C/C++ syntax combined with a loosely typed scripting language that's supported by 99.9% of web hosts out there.. what's not to like?
PHP is Awful and programmers who went to college and obtained their masters in Computer Science should not spend any time touching this highly profitable brainless format of web scripting language. You should instead contact your employers and tell them what you really think of their ineptitude in regards to choosing PHP as a solution and reaffirm your superiority over essentially everyone.
However, I for one - welcome our new PHP overlords.
And the money to be made doing it.
I was wondering, how good is Ruby on Rails?
"It is on par with C++ and C# in its expressiveness, and often exceeds it."
Talk about damning with faint praise....
You Sucks, But It Doesn't Matter
The ugliness of a solution isn't given by the language used, but by WHO developed that solution.
"Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML, replicated in slightly-varying form in dozens of places."
This describes my current project PERFECTLY!
Jeff, you spelled it out nicely. I'm on a project right now that is php. No biggy right? well I should mention that we are a Java shop by nature and could not build the solution we needed fast enough in java to warrant using it on this current project. I hate php but I'm using it and I feel dirty every time I have to write a function that uses globals or passes by value or directly calls sql. I know this project won't be maintainable but thats not what we are concerned with - its getting it out there and seeing if it sticks to the wall. Thats probably a philosophy shared with facebook, youtube, digg etc... get it out there first and then make it better. Its also funny that you mentioned VB as I could argue that Microsoft was one of the first software companies that used the "get it out even if its crap" mantra.
Let me paraphrase your argument to see if I understand your criticism of PHP.
PHP is the most horrendously bad programming language in the world because it has waaaaaay too many functions that start with the letter 'a'. And not only that, it's also horrendously bad because it is so easy to use that anyone can program in it, like HTML. And all these idiots don't know how to program. Therefore, PHP sucks. Oh, and it's a big joke that the words in function names are separated by underscores. Everyone knows the right way is to use camelCase.
Is that the gist of it? Did I miss something?
I hate php but I'm using it and I feel dirty every time I have to write a function that uses globals or passes by value or directly calls sql.
Then don't do those things.
I would except that we have inherited code from a 3rd party and are stuck right now doing things the way their "framework" lays it out. The method by which the database connection is setup and the way you manipulate the models (which are really just direct calls to the db tables) has already been defined by this framework so its either re-write it (losing the time gained in using it) or conform to their way of doing things in the interest of moving fast and keeping the code base consistent. The default behaviour of PHP is to pass by value not by reference and yes you can override that using the operator on your parameter passing but again when using a pre existing code base that does not do that it means you will inevitably introduce side effects that are hard to diagnose or fix.
@Kristan "Krispy" Uccello
Seems like you are working in PHP4 while PHP5 is already available for about 5 years.... And the problems you state are problems with the framework. Not PHP. In PHP 5 passing by reference for objects is default .
You are correct - the framework was written in php4 even though it was released not too long ago. I guess the issue is really that a language (any language) carries with it the legacy of its creation. I know php has come a long way in its existence and will most likely continue to get better. But even as it gets better there will be those who do not use or pick up on the improvements. I see every language as a dirty snowball rolling down a hill. Rails for PHP is new and looks promising as is the PHP unit frameworks (still a little cumbersome compared to things like RSpec though) and I'm sure there will be many more improvements in PHP like this - If you read my earlier post: I did decide that PHP was the way to go for the current project but I still feel the burn of not having the ease of use of the other tool sets/libraries etc that I can leverage in other languages/frameworks.
Back to your comment: yes many of the problems are in the framework I am using but it was PHP that allowed those problems to exist.
Wow. After reading all of these sterling posts from the defenders of PHP, I've decided to become an elitist code everything in Haskell. (that is, at least until I get my AI up and running - implemented in Lisp, of course - and then I'll just have it write Haskell code for me)
Jeff, thanks for updating about YouTube; I appreciate it, and really enjoy your site. I'll step out and let the PHP discussion rage on now.
I find it extremely funny how many people completely misunderstood the article. Jeff, maybe you could do these morons a favor and avoid the humor and sarcasm - they obviously don't get it.
If you're about to make a "PHP doesn't suck" post - go back and RTFA again...
Who told you that insulting people was the best way to get your point across ?
Stuff that proves PHP is continuing to mature as a serious programming language:
* Build System: Phing (http://phing.info/trac/)
* Continuous Integration server: Xinc (http://code.google.com/p/xinc/)
* Eclipse PDT Project: http://www.eclipse.org/pdt/
* Endless Frameworks to choose from: http://en.wikipedia.org/wiki/PHP_frameworks#PHP
* Plenty of Object-Oriented support (and still growing)
* According to the internals mailinglist for PHP, PHP6 will most likely have Namespaces
PHP sucks for experienced programmers because they need to work harder to insure good coding practices. PHP sucks for beginner programmers because it lets them get away with ugly code.
It doesn't matter that PHP sucks for experienced programmers because they can still write clean, reusable, and readable code on an enterprise scale. For beginner programmers, it doesn't matter that PHP sucks because it allows them to do something useful with a powerful language -- one that they can grow into over time.
@Jasmine and manu
She's right though - I doubt most of these rants read past the first few lines of the post. People are so sensitive, especially about these stupid things like "do people think my programming language sucks?" - WHO CARES!
who the hell asked to use PHP? go fuck around with java / c or any other fuc-kin language. dickheads like you are just to spread flame and elitism, mother fuc-ker dumbass.
wow, Necromancer. You sound like one of those people that got screwed in 1999 because they couldn't get paid $100k to do HTML anymore. Then one day, you saw a copy of OMGFTW pHp in 42 minutes at the local book store and therein saw your salvation. A ray of hope illuminated your soul upon reading that book, as you found a way to once again charge for cobbled together spaghetti?
You can't say a language SUCKS based on this criteria, when other languages SUCK far worse. C++ sucks because it's a pain in the ass to use. PHP is not a pain in the ass to use. Sure the library is an inconsistent mess. The library is not the language. I can get things done FAST and maintain existing things FAST, in PHP. THAT is what matters.
Many folks have used the argument that elegant code can be written in almost any language. That is true, for the most part. But that is not the point of Jeff's post, I don't think. The point is that PHP is a tool that is widely used, but is also inferior to the languages that were developed with large scale, extensible development in mind. To say that PHP is as powerful/useful as C++/Java/C# is like saying a carving knife is as useful as a power saw when building a house. The tools do matter.
Using rubyonrails makes my penis bigger
Whatever else you might say about it, PHP's documentation is the best I've seen for any web development tool. That's a major reason I believe it has gained popularity. It's easy to make fun of "script kiddies" until you remember we all started as one. PHP, for whatever reason, is very intuitive.
I have developed a few quick apps using Rails and Django, and those are certainly not without faults. (Django can't alter tables if you change your model specs, defeating the purpose of designing them before your DB's). CakePHP is essentially Rails with code that's less "beautiful" (read: obtuse), and PHP nearly always runs faster than Ruby.
I got a link to a blog post on this site. Read it, read a few more, and loved it. So I type up the address, preparing myself to stamp it on my favorites list.
First thing I see: "PHP SUCKS". Since I use PHP a lot, and I love it's features and simplicity, it didn't exactly ring a bell. Ok... I know people have different opinions, so maybe there's some interesting arguments in there. Right?
Well, where are they? All it says is PHP sucks, PHP sucks more than BASIC, PHP sucks real hard, PHP has all those functions that begin with the letter 'a' so it MUST suck!...
Never returning to this site again. This site sucks, but it doesn't matter.
Endless discussions about style, people tend to forget PHP/.NET or whatever are Tools for you to create something, does not matter what your tool looks like, what matters is how helpfull it is, and the answer for this question is pretty clear: PHP is the most usefull tool for web creativity.
In my opinion, php has 2 major drawbacks:
- not thread safe with all extensions, this one is really bad
- native unicode support (should be here in V6)
"Le reste n'est que littrature..."
I've written in tons of languages over the years including VB (I used to like but have moved from it because it's way too rigid and not portable). For most my work, which involves creating custom applications running on various UNIX platforms, I've settled with Tcl/Tk and C/C++. Tcl is great for rapid prototyping and even for powerful portable applications. Recently, I decided to port a web server written in Tcl/Tk to something more standard. So I moved to PHP. I must say it was the smoothest port coding exercise I had every done. Yeah for PHP!
I'm of the opinion that the language doesn't matter - it is the resources and community around it that matters. PHP allows you to do tons of stuff with little effort. Its flexibility and stability is hard to match.
Great blog by the way.
i sincerely hope you wrote this post to provoke argument, and not because you really believe it, otherwise, you're on the point of losing a reader.
i have been working for a major telecoms company for the past year. we're building serious, mission critical stuff. when i started, they had just released version 1 - written in php. it was intended to be a stop-gap until the 'real' application, written in c++, was deployed. the c++ has yet to be seen - it was eventually abandoned after months of delay. the one module that does exist was delivered late, wasn't properly tested, and has so far been the cause of two serious bugs in production. by contrast there have been no significant bugs found in the php code.
the php team has continued to consistently produce bug-free, high performance code, on time. it is now at version 2.3 and holding the fort just fine. take it as evidence that php is more than capable of handling serious applications. as for the c++, the effort has resumed to replicate the php functionality (for performance reasons). so far, despite having twice as many developers working for twice as long, the scheduled june date has already been pushed back. nevertheless i don't think c++ is a crap language, or the guys are poor developers. they've got a difficult job and they're doing the best they can.
jeff, i am totally fed up with hearing from people like you, how crap php is. you clearly don't know what you're talking about. you REALLY make yourself look stupid with comments like "OO, N-Tier, exception handling, domain modeling, refactoring and unit testing are all foreign concepts in the PHP world.". i have lost an enormous amount of respect for you because of this post. isn't it time you did your groundwork, grew up a bit and evolved out of the childish 'my language is better than yours' bickering?
If you haven't tried ColdFusion 8 - I highly recommend you take a look because after years of developing in everything from VB to PHP, aside from Ruby, I have found ColdFusion a shear joy to develop in while being extremely productive.
Yahoo! Bookmarks is also created using PHP - PHP5 that is, utilizing the Symfony. The latest gossip was that Yahoo! was re-writing Del.icio.us in the fashion too.
And Flickr -- initially it was done on PHP4 ;) I'm not sure what's the current state of the project, and if they "evolved" it to the more mature PHP5, but hey - even PHP4 was OK for building a heavy-duty tons-of-load website.
PHP appears to be the defacto "do-it-yourself" server-side web dev platform.
Just look at the multitude of cookie-cutter PHP apps/scripts out there. Every low scale niche message board I go to, every bittorrent tracker website, all written in PHP.
Don't get me wrong, there are some very good open source ASP.NET apps out there for handling all the great generic problems. It's just that ASP.NET seems too industrial a platform for start up web developers lookin' to implement their grassroots ideas and host them for cheap.
My only beef with PHP is I can't do things like spawn threads or have variables that outlive the web call. I would kind of like to use nonserializable objects in sessions. Is that too much to ask?
In case it's not obvious, I only want the first two because if I have them I can make the last one for myself. Trust me, it really comes in handy.
I programmed in Perl, Classic ASP, PHP and ASP.NET/C#.
IMHO PHP code sucks if you want it that way. While classic ASP offered no alternatives in style (unless you coded your COM class to encapsulate needed features, which moved the problem into "DLL Hell" area), you *could* always write a (limited) class library in PHP.
Nowadays, there are lots of alternatives in PHP if you want clean, structured, MVC-compliant code. My favourite is CodeIgniter: structured enough to keep your code clean, relaxed enough to allow you to delve into low-level mode if you *really, really, really* want to.
Did you even bother to read the links he's referencing? Those links are the shortcomings Jeff is talking about.
When you get right down to it, either spoken or computer all languages suck. They are all an 80% solution to convey what is going on in the mind of the person using the language. They key is overcoming their short comings and being successful in spite of them. PHP does this very well, so does VB.NET, C# etc in the hands of someone who knows the language well. It's a pedantic argument to say one is better...
Everyone who is all in a flutter because a blogger (with a penchant for hyperbole) who isn't a hardcore PHP says your favorite language sucks should go look up the word hyperbole.
As a few posts have mentioned, Drupal is an example of a successful and practical implementation of a web content management system in PHP. I have found it easy to modify the Drupal PHP code on my own site to tweak details. I have done OOP for years mostly in C++, OOP is overrated.
Anyhow, to answer why PHP (and messy stuff) is so prevalent, you'd want to read this to get the gist:
(is your captcha stuck?)
What I found most annoying about php, apart from the inconsistency in the library, is that PHP5 is so much nicer but my application is a installed app, not something I host, so I'm stuck with the lowest common denominator. It's actually tempting me into switching to a compiled language and making binary distributions instead - something I can't do with php, although I could with perl+par - or to a language that hasn't sucked in living memory, so I don't suffer the same way with old versions. It would need to have a decent built-in library too.. Perl, Ruby and Python seem to be the candidates, although perl is sometimes a lot of grief to install modules, too.
Die PHP4 Die!
There's way too many people here blaming the users of a language for its shortcomings. That's just plain dumb. The language is poorly designed...period. The fact that it is *possible* to write reasonably good code in it is no mitigation whatsoever.
David Platt's (http://www.whysoftwaresucks.com/) first law is that logistics triumphs over all. That is to say that things that are easy to do will get done and done often, regardless of whether they are "good" or "bad", simply because they are easy to do. The converse is also true. Things that are hard to do will not get done or get done seldom, regardless of whether they are "good" or "bad", simply because they are hard to do.
Therefore, the primary goal of *any* design has to be to make good things easy and bad things hard.
It sounds like the kind of common sense a child could come up with but do you see any of that in PHP ? It's one of the worst cases of "design by committee" (http://en.wikipedia.org/wiki/Design_by_committee) I have ever seen.