PHP Sucks, But It Doesn't Matter - partial rebuttal
patrick — Fri, 2008-05-23 14:27
It's funny that after Ravi pointed out PHP Sucks, But It Doesn't Matter at some point I came across Blogging Horror... While I've found a lot of posts on coding horror funny & horrifying over the years I find the issues being pointed at in the bulleted list under the Blogging Horror
sub section absolutely horrifying as well. Credibility starts going out the window especially with Atwood's example of MVC :(
I initially started this as an email, but considering the number of people I'd end up forwarding this to I think I'll just slap it up here... Long story short I initially left ASP (and felt it sucked) because the community wrote crap code and I could never find any articles about advanced programming concepts. Although the PHP community contains a lot of crap code (hell, I think hotscripts started with just PHP crap code and has since added crap code from other languages) I found several people with lots of articles on advanced programming concepts and covering security issues.
What really gets me, and it's not afaict mentioned in his PHP Sucks
posting, is that Atwood seems to think that .net is a better language than PHP. No matter whether you're referring to VB.net, C#.net, or Whatever.net if you're attaching the .net you're referring to the .net framework. Even if he wants to state that .net is a better framework that's fine... PHP is not a framework. Comparing a framework to a language is like comparing apples to oranges, but then again he's not even bothering to compare it to anything.
As far as server side programming languages are concerned, my first was classic ASP. One of my reasons for leaving is the same reason that 1 of the commenters states is the reason PHP sucks - the community writes crap code. The initial reason I've stayed with PHP rather than flocking back to ASP or immediately rejecting it is that I was able to find people who were promoting advanced programming techniques as well as pointing out security issues and how to deal with them (see Tony Marston's Web Site and Harry Fuecks [phpPatterns and sitepoint]).
As I was joking in IRC recently, I could switch to being a .NET developer and have a job tomorrow... but the pay wouldn't cover the cost for the aspirin and therapy needed to deal with it
. I've knowingly seen crap code in VB, ASP, PHP, Java, Javascript, ColdFusion, and C++. I think there even used to be (still is?) a prize for the most obfuscated Perl code! No matter the language it's very telling when a person has written a huge chunk of linear code within a single method - several 100 lines of code within multiple nested if statements... Or how about the page that makes a SQL call, embedded within the page, to retrieve a list and for each item within that list makes a separate SQL call back to either the same table or another using a foreign key. I've seen this done in ASP, PHP, Java, and ColdFusion code; encouraged in ASP, PHP, and ColdFusion example code; and only discouraged in PHP and Java.
One of the biggest problems in getting over the learning curve hump is documentation. Most developers don't understand how crucial this is to most people trying to learn how to program. I remember sitting in my Java programming class utilizing many fairly standardized methods (toInt and toString as a basic idea) - many of which I didn't know the exact name for, but with my programming knowledge I had an idea as to what I was looking for. One of the other students in the class asked how I was able to find these names so quickly and my reply was that they were fairly standard across languages and therefore fairly obvious. She then asked me something along the lines of who comes up with these 'fairly standard names'
to which I had no good answer at the time - I thought it was just obvious. At that time I felt the PHP documentation was the best, followed by the Java documentation. 3rd party documentation can suck no matter what language it's for...
During my foray into Ruby on Rails documentation was 1 of the major stumbling blocks for me. I'm not sure how much was due to me not understanding Ruby and how much was me not knowing what was going on in RoR, but it seemed a lot of times RoR was just pulling stuff out of thin air. I seemed to ask questions on a constant basis because I was never sure whether I needed to be looking at Ruby documentation or RoR documentation to find my answer. Most of the IRC answers I got was RTFM, but which manual do you read? How long are you supposed to continue searching for an answer before you just consider it a lost cause and go do something else? Sure, some people attempted to be helpful and sent me URLs to documentation, but most seemed to be like 1 site I remember. I went to the site which appeared to be a book on Ruby that covered theories and general ideas, but lacked implementation. How do I program in this language? How are objects and methods defined and created? Give me something that I can sink my teeth into and at some level relate to some other language I've worked with. Give me code samples that actually work.
Compared to PHP the Microsoft languages on the other hand have just always driven me nuts. Firstly you have to know what Microsoft has named something - you can't find anything in the official documentation by searching msdn with what the rest of the world is calling something. The only way I was ever able to find anything in Microsoft documentation was to google what I was looking for until I could find the Microsoft term for it, then go and use the Microsoft search for that term. I probably should have written C++ code and saved myself the aggravation.
While PHP does suck, so does ColdFusion, Perl, C/C++, all the different languages in the .net framework, Ruby, Java, Javascript, CSS, XSLT, and every other programming, framework, script, and markup language that's used. Just pick whichever language sucks less for you and whatever project your working on.
And from personal experience it takes longer to get even computer and gadget geeks to convert (if they ever do) when you beat them over their heads with how wrong they are rather than pointing out the beautiful benefits they'll gain by switching...
Which reminds me... he never presented what he thought was better, my assumption is .net considering he's using it for his new stackoverflow project.
$ curl -I http://www.stackoverflow.com/
HTTP/1.1 200 OK
Content-Length: 913
Content-Type: text/html
Last-Modified: Sun, 04 May 2008 22:29:02 GMT
Accept-Ranges: bytes
ETag: "40a5e14036aec81:0"
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Fri, 23 May 2008 19:24:55 GMT
Svidjaju li Vam se njena
rerialiew (not verified) — Thu, 2009-10-29 15:07Svidjaju li Vam se njena stopala?
Uclanio sam se na njen site i mogu reci da ima jako lijepa stopala!
Stopala su na njoj najbitnija stavka!
My friend on Orkut shared
Jane Goody (not verified) — Fri, 2009-04-24 05:11My friend on Orkut shared this link and I'm not dissapointed that I came here.
Patrick, this started as a
Joseph Hurtado (not verified) — Sat, 2008-05-24 14:28Patrick, this started as a small comment, and then blew up to a full article, so here it goes, you can see it in my website too. I really like your article, one of the few ones that made any sense. Below what I wrote on my blog.
======
Recently Patrick wrote some sensible logical reasons why PHP does not suck, despite Jeff’s opinions to the contrary. So let me add some reality check to the discussion.
Let us refocus the discussion to what matters, and what matters is which computer language can excel at web development.
So we need a basis for discussion, what makes a great development language to begin with?
I would argue 3 factors make a great web development language:
1. Coding is not a Pain. Virtuous Laziness or DRY
The language, not the framework should provide methods, classes and code to build a web app easily and with the least amount of sweat.
So if you need to do AJAX there is code for you to deal with JSON and XML, and REST. You need to do payment processing, no problem. You need to cache a database or even cache page responses, yep code is there. You need to validate forms, yep that is available too. Few languages have all of that available. And that can make a big difference in development time, and that is productivity or Virtuous Laziness or DRY.
PERL is good at this but it has big issues in other areas, Rails is trying hard to do this but it is a framework.
PHP however excels at this, it has methods and classes for just about anything, it is easy to read, and it is logical.
Arguably Python has done good progress at this, and I am interested, but have not checked how far they are in now.
Frameworks deliver this at the expense of a lot of added layers of complexity. Can you spell Rails or J2EE or .Net?
The best framework would be one that is logical and simple to learn, yet not a black box of who knows what is inside of it. Magic is best left to a magician, code should not be magical, it should be clear straight forward, and reliable. Rails is having trouble for too much magic that apparently cannot perform at huge sites with a lot of database and traffic. They are trying to fix it yes, but the problem is there.
So who qualifies for this one: PHP, Python and PERL. Nope, not Ruby, not Java, not .Net. As I said PERL has issues beyond this good advantage though.
2. Code Scales Vertically. It is easy to build from tiny bits to big buildings
This is a tough one; it goes beyond OOP although OOP is mandatory here.
It means your code will be easy to read, maintain, upgrade, expand and debug. It means you do not have to code 20 lines when 5 will do the job. It means you do not have to Google your language time and time again because it is so darn huge it cannot fit in anyone’s brain.
This is PERL’s Achilles heel. This why so many people have either abandoned the language for web development, or isolated it to some niche areas.
So we need a fairly mature language with debugging tools, good OOP, good documentation, good support and NOT verbose.
So the OOP part is easy PHP 5, Java, .Net, Python, Ruby all can do good OOP. If you think PHP 5 and 6 can’t I suggest you read a current manual.
But when you add the code simplicity factor, the lack of gratuitous verbosity, maturity, tools available and documentation, the place becomes deserted and few options remain.
Arguably you are left with PHP, Python and Ruby. Sorry but Java and .Net are too verbose, big and messy.
3. Scale Horizontally. Ability to run a huge website, no excuses please.
This is a big one.
Say that by chance, luck, size of the project, design, or whatever the reason your web application is the new darling of the Internet, with millions of hits. Could your horizontal scalability make it? Meaning can you scale your app so that it will handle success?
PHP has proven it can. Before Google took YouTube, it was mostly PHP with caching and smart database design on Linux, and it worked. It was sold for over a billion dollars, that should say something.
Facebook is now full of extra stuff besides PHP, but there is still a LOT of PHP there, and for the most part it works. Yahoo has PHP all over the place. Heck they are even using MVC and Symfony in the upcoming Delicious.
PHP can be optimized in C, it has a variety of caching solutions, it can be “compiled” and it can be debugged for performance.
Few others can say this... Python yes, pure Ruby probably, but both have limited tools out there, like professional debuggers and IDEs. Net and Java have the tools, but they are very verbose or complex or both.
So who can qualify for these 3 requirements, which language can be a great web development language?
I am certain PHP can.
And probably Python is a strong second. Ruby is trying hard with MERB; it might be there now.
So whenever I hear one more PHP basher, I think: does this guy do web development? Or is he just discussing theory, or doing classic desktop apps? How can he not get it?
Look at the web today, look at real apps, at the big sites out there, what do you see? I see a lot of PHP, a lot of Python at Google, little but good Rails... sorry but very little .Net and J2EE out there. Why? Reality has taught web developers that PHP works, Python works, and some times Ruby works too.
Joseph Hurtado / Web Developer
P.S. I must say however that I truly believe we need the right tool for the job. I am all for heterogeneous languages that are ideal for the task at hand. Java shines in the back-end, C shines for speed, Perl can easily hack the file system, heck even .Net probably can do wonders with windows servers ; )