Jeff Atwood’s latest post on Coding Horror provides great insight into the history and mindset of one of the Computer Science greats, Alan Kay. It’s a good read for any computer professional looking to delve further into the advances that Kay worked on.
Unfortunately, Jeff has a pretty strong distaste of PHP, and blindly jumps on a perceived opportunity to back up his case. He cites an ACM Queue article where Kay discusses why software development does not happen faster. Here’s the important section that Atwood quoted. Bolding is Atwood’s emphasis:
Let’s say the adoption of programming languages has very often been somewhat accidental, and the emphasis has very often been on how easy it is to implement the programming language rather than on its actual merits and features. For instance, Basic would never have surfaced because there was always a language better than Basic for that purpose. That language was Joss, which predated Basic and was beautiful. But Basic happened to be on a GE timesharing system that was done by Dartmouth, and when GE decided to franchise that, it started spreading Basic around just because it was there, not because it had any intrinsic merits whatsoever.
He follows his citation with this comment:
Any similarity between the above and PHP is, I’m sure, completely coincidental. That sound you’re hearing is just a little bit of history repeating.
His link here goes to an earlier post where he lambastes PHP for, well, existing really. I took issue with the post at the time, finding several glaring holes in his logic and generally disagreeing with the premise (obviously). I replied in the comments (look for my name), and expounded further in a rebuttal post on my own site. I didn’t let him get away with unfounded arguments then, and I’m not going to now.
In the ACM Queue article, Alan Kay discusses the evolution of programming languages. He and his colleagues expected the next big leap in programming language structure to occur somewhere around 1984, with the introduction of a new generation of programmers. It never happened — to Kay’s satisfaction, anyway — and he believes that commercial software development doomed this advancement, and has stagnated the evolution of programming theory. This leads to Jeff’s quote and PHP quip.
Two problems here. First, Kay was discussing evolutionary leaps, not the quality of the current crop. Kay doesn’t know how language theory will evolve, he’s waiting for someone to come along with the next bright idea (otherwise he would have done it, duh). Labeling any current language as subpar simply because someone theorizes “we can do better” is complete non-sequitor. I believe Kay knows this and his words in the article back it up.
To put it another way, using Atwood’s logic, wouldn’t VB.NET would fall into the same category of failure? Kay may not be worshiping at the altar of PHP, but I don’t see him anywhere near Microsoft’s temple either.
Second, PHP is successful because of its merits, not in spite of their lacking. Jeff needs to read the Wikipedia article on PHP. The very first paragraph on the page reads:
PHP originally stood for Personal Home Page. It began in 1994 as a set of Common Gateway Interface binaries written in the C programming language by the Danish/Greenlandic programmer Rasmus Lerdorf. Lerdorf initially created these Personal Home Page Tools to replace a small set of Perl scripts he had been using to maintain his personal homepage. The tools were used to perform tasks such as displaying his résumé and recording how much traffic his page was receiving. He combined these binaries with his Form Interpreter to create PHP/FI, which had more functionality. PHP/FI included a larger implementation for the C programming language and could communicate with databases, enabling the building of simple, dynamic web applications. Lerdorf released PHP publicly on June 8, 1995 to accelerate bug location and improve the code. This release was named PHP version 2 and already had the basic functionality that PHP has today. This included Perl-like variables, form handling, and the ability to embed HTML. The syntax was similar to Perl but was more limited, simpler, and less consistent.
PHP is 100% grass-roots success, starting out as one guy’s collection of useful tools for building websites. I refuse to believe that, in this age of abundant choice, all these programmers picked up PHP because it was “easy.” The numbers are just too big, features and power must enter into the equation at some point.
Nonetheless, Atwood’s application of Kay’s quote would lead you to believe that PHP exists because Zend Technologies pushed the language financially, just as GE backed BASIC. The truth is exactly the opposite: Zend Technologies exists because of PHP’s overwhelming success. Coming from a hard core VB.NET programmer, I find the insinuation here a little insulting; Zend Technologies is hardly MS Borg.
When it comes to having a discussion about programming philosophy, I wouldn’t even put myself in the room with Kay. I don’t know enough on programming language evolution to even join the discussion. Atwood, on the other hand, gets too close to the fire and gets burned. He erroneously applies Kay’s argument to his own beliefs which, when scrutinized, deflate much like the previous one.
This is the second time now Jeff has taken a unfounded shot at PHP. The complete lack of substance behind his claims make him look like nothing more than your average “my language is better than yours” fan boy. I could ignore it, but his audience is large enough to effect real influence. So like anyone else in a position of power, he must be called on the outlandish claims.
I read your blog all the time, Jeff, I know you can do better than this.
Absolutely, 100% agree. The PHP bashing from Jeff is getting very old. It’s actually turning me away from Jeff’s blog, sadly as he used to have very good content.
Thanks, Erlingur, but I have to disagree with you on Jeff’s content. By and large his posts are very insightful, and they’ve helped me more than once with an actual project. He just has this Achilles’ heel for PHP. I guess it’s the uber-geek in him rearing up.
If the overall quality starts to go, then I might stop reading. Until then, I’m happy to call “shenanigans” when necessary.
Although this issue redefines ‘dead horse’, I do appreciate someone stepping up on PHP’s behalf. I never understood his random distaste for it. Sure, it’s got it downsides, but all languages do, and the numbers speak for themselves.
I’ll continue to read Jeff’s stuff (his content is pretty darn good), but you’ve definitely reminded me to take everything in with a grain of salt.
I stumbled across your blog when you first responded to Jeff’ first PHP shot. I was impressed with how you formed a rational rebuttal without throwing mud. Once again I am reminded of why this page was added to my RSS list. Very well done!
That being said, I too agree that Jeff’s blog is a very good one. I might add the creation of Stackoverflow has also been a valuable resource as I develop my own programming skills.
Keep up the good work Frank! I look forward to hearing more about the progress of FWD:Vault.
That’s the best compliment I’ve received from someone other than my wife all week. Thanks, Ethan.
You also raise another excellent example. StackOverflow is a sweet idea, and fills a gaping hole in the web. If I never come across another non-answer on that subscription-only piece-of-crap Experts Exchange, it will be too soon.
I’m planning a beta test of the email backup functionality in the next few weeks. If you submit your email address to the signup on the homepage, you’ll get notified when that happens.
My additional comment here derives from the rage that I have for subscription sites like Experts Exchange and the flat out reason why I believe shared knowledge is key.
Let me wave a flag and stand up and say that the number one reason I am actively supporting other users is a direct result of the insult that a pay-for-forum like Experts Exchange runs. I was troubleshooting hardware long before we could search for answers using ‘Google’. Once it became second nature to use a search engine to find these answers, the positive sides of human nature were quite evident. That was, until I came across my first top ranked solution through Experts Exchange.
This experience was the first of many that eventually drove me toward the open source community. I wanted to find answers to problems that others had already experienced and learn from their examples. Coincidentally, this was also similar to experiences I had with learning MS favored programming languages. When I wanted to learn, the extended hands came from the open source community.
Therefore, I am left to respect those who helped me by helping others. This cyclicle approach must surely outlast the alternative.
Keep up the hard work. I will surely submit my email to beta test….
Regards,
-e
I just stumbled upon your blog and I must admit that I found your well structured argument to be a nice change of pace. Too often developers let the fanboy in them derive faulty arguments for or against a given language. Although I’m not a fan of PHP, I don’t agree with Jeff’s take on the subject.
Thank you for posting this as I agree entirely. As a professional PHP programmer, it irks me a bit when I see the PHP bashing all of the time. Yes, it has some problems and some, “why on earth did they design it like that?” questions, but for the most part, its remarkably stable, has a huge wealth of community support, and is amazingly efficient.
An interesting insight that PHP was made popular by the community rather than companies as no one noticed until one day PHP was the number 1 web language.
I’m actually quoted in one of Jeff’s articles about PHP and honestly I agree with him – I still do the occasional work in PHP because I’m sometimes forced to – but if I have a choice I would *never ever* pick PHP for anything.
And why PHP got big? Shared hosting, ease of deployment and low maintenance – still doesn’t change the fact that the language is horrible in every regard.
I agree with Reed Hedges and Alan Kay that computers need to be redesigned from the ground up to support user programming. That was the essence of HyperCard, and of HyperLook, which it inspired. I described HyperLook and other related ideas on the OLPC mailing list here: http://lists.laptop.org/pipermail/sugar/2006-December/001022.html
The OLPC includes Alan Kay’s Smalltalk/Squeak/eToys environment, but it is not built around it. Rather, it’s built around Python. eToys is there to inspire people to do the same thing with Python as has been done with Smalltalk. Smalltalk is not the “official” programming language of the OLPC — Python is.
You can read some interesting discissions I’ve had with Alan Kay about programming languages on my web site: http://www.DonHopkins.com
What’s wrong with taking cheap shots at PHP? It deserves it. The fan boys should stop wasting their time apologizing for it, and learn a better language. PHP’s own designer, Rasmus Lerdorf, admits he had “absolutely no idea how to write a programming language” — what better reason could there be not to use PHP??!
Here is why “PHP Will Ruin You Mind”:
http://ask.slashdot.org/comments.pl?sid=621541&cid=24287825
And if you’re still not convinced the design of PHP is deeply flawed, because language design is HARD and should only be attempted on purpose by experienced people, here’s what the Father of PHP Rasmus Lerdorf himself said in an ITConversations interview [itconversations.com], quoted in “Why PHP sucks, Part III” [dasgenie.com]:
“I don’t know how to stop it, there was never any intend to write a programming language [...] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way”.
If you’re a PHP programmer, you’re irresponsible if you’re not already aware of its flaws, because you have not educated yourself by reading any of the following well publicized articles. Once you understand the flaws of PHP, you can’t honestly make the statement that it’s a well designed language suitable for teaching programming to kids.
First there is this classic article, Edwin Martin’s “What I don’t Like about PHP” http://www.bitstorm.org/edwin/en/php/ , which goes into detail about the following fundamental flaws:
1. Bad recursion
2. Many PHP-modules are not thread safe
3. PHP is crippled for commercial reasons
4. No namespaces
5. Non-standard date format characters
6. Confusing licenses
7. Inconsequent function naming convention
8. Magic quotes hell
9. Framework seldom used
10. No Unicode
11. Slow
Then there is the mind-set of the PHP language designers and community, which is deeply flawed. Ian Bicking’s “PHP Ghetto” article http://blog.ianbicking.org/php-ghetto.html sums up the problem with PHP’s design and community pretty well:
I think the Broken Windows http://en.wikipedia.org/wiki/Broken_Windows theory applies here. PHP is such a load of crap, right down to the standard library, that it creates a culture where it’s acceptable to write horrible code. The bugs and security holes are so common, it doesn’t seem so important to keep everything in order and audited. Fixes get applied wholesale, with monstrosities like magic quotes http://us2.php.net/manual/en/security.magicquotes.php . It’s like a shoot-first-ask-questions-later policing policy — sure some apps get messed up, but maybe you catch a few attacks in the process. It’s what happened when the language designers gave up. Maybe with PHP 5 they are trying to clean up the neighborhood, but that doesn’t change the fact when you program in PHP you are programming in a dump.
Jonathan Ellis’ “Why PHP sucks” article http://spyced.blogspot.com/2005/06/why-php-sucks.html makes a lot of good points and links to many other sites with more information to back up the claim that PHP sucks.
He perfectly summarizes the yapping of the PHP apologists when he says: Basically these all boil down to, “I don’t have enough experience to recognize PHP’s flaws because I haven’t used anything better.”
He summarizes:
In short, PHP sucks because, PHP’s authors are prone to confuse “pragmatism” (a fine design goal, if done well) with “adding random features without considering how they impact the language as a whole.” Thus, its authors have found it necessary to correct obvious flaws in both minor and major releases, with the result that the recent PHP5 breaks with the past to an unprecedented degree while still leaving many fundamental flaws un-addressed. I don’t know if this is because they didn’t recognize those flaws, or more likely, because they were willing to impose “requires a lot of pain to upgrade” but not “requires a complete re-write.”
There is also a lot of great stuff about why PHP is so bad on http://www.ranting-wolf.info/category/technology/programming/php/ including a concise description of why the “Smarty” templating system is such a horribly ill conceive and terribly implemented idea.
And if you’re still not convinced the design of PHP is deeply flawed, because language design is HARD and should only be attempted on purpose by experienced people, here’s what the Father of PHP Rasmus Lerdorf himself said in an ITConversations interview http://www.itconversations.com/detail.php?id=58 , quoted in “Why PHP sucks, Part III” http://www.dasgenie.com/scrap/archives/000060.html :
“I don’t know how to stop it, there was never any intend to write a programming language [...] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way”.
There you go. The designer of PHP himself admits he literally had no idea what he was doing! It’s absolutely foolish to teach PHP as a first programming language. Kids deserve much better than that.
-Don
For some more constructive criticism and comparison with much better systems, see also:
PHP will ruin your mind, but Smarty is worse
http://ask.slashdot.org/comments.pl?sid=621541&cid=24331919
@ethan: With you 100%. Experts Exchange actually scrapes a lot of their answers from other sites. So when you find a “solution” on their site, rerun your search using the exact same text from their problem description page. I come across source material 9 times out of 10.
@Mike: Glad you like what you’re seeing. Feel free to RSS and stick around.
@Vic: When you’re 100% grass roots, any and all growth is merit-based. There’s simply no other alternative. If PHP really sucked, it would have died like so many languages before it.
@Anyone: Obviously I’m getting lots of support from PHP developers, however this is not necessarily a defense of PHP specifically. The larger issue was calling Jeff out on a baseless attack. He doesn’t like it, and that’s totally fine. But you have to tell me why you don’t like it. What’s wrong, where are the shortcomings? If you can’t formulate the argument, you’re only adding noise, and noise doesn’t help anybody.
@Fredrik:
Why, what’s the problem? If it’s so horrible, surely you can give me a few concrete examples. And don’t look now, but you made two argument in favor of PHP: ease of deployment and low maintenance are huge benefits. Ask any system admin.
I’d also argue that your claims about about hosting support are backwards. It became a popular coding choice, and then went mainstream, getting picked up by hosts. Why else would hosting companies even consider it in the first place?
Jeff Atwood is wrong!?!?!
The worst part about the article is not his opinion that PHP is crap, which it kind of is, but rather that he’s leaching off of Alan Kay with this I-know-alan-kay-so-listen-to-my-opinion article.
Also, you cited a Wikipedia article as proof of PHP’s greatness. I’m sure Jeff has changed his opinion.
@Don:
No-one here is talking about using php as a teaching language. Unbunch your panties, stop copy/pasting your own rants from slashdot, and tone down the arrogance.
“The fan boys should stop wasting their time apologizing for it, and learn a better language.”
I’m current in a number of languages, from Ocaml through to C#, taking in a number of others along the way including python and ruby. By ‘current’, I mean I actually use those languages regularly in both my day job and on various open source projects.
Yet I decided to write my current side-project in PHP, simply for convenience. If you know what PHP gets wrong, and know how to code around the security issues (not that hard), it’s perfectly serviceable.
“”"”I refuse to believe that, in this age of abundant choice, all these programmers picked up PHP because it was “easy.” The numbers are just too big, features and power must enter into the equation at some point.”"”
Easy IS a feature and easy is a powerful motivator.
I have never met a programmer in real-life who used PHP and a few other languages and said that PHP had gret “features and power”. Rather I hear: “it’s so easy to deploy, so easy to embed, so easy to learn, so easy to …”
Congratulations to PHP’s developers for making it such an easy development and deployment environment. That’s a real accomplishment! But we don’t have to confuse it with another, separate and unrelated accomplishment of making a quality PROGRAMMING LANGUAGE.
You’ve done nothing to defend PHP.
PHP suffers from never having any real vision behind it. Even perl had vision. PHP didn’t all of its evolution came from people bitching. Now it is too late. You have a community drowning in really terrible code with terrible architecture.
Really if you can’t make this observation you haven’t programmed in any other language.
@John: I am pointing out that PHP is a grass-roots effort; the source is almost inconsequential. I also don’t expect Jeff to even acknowledge I exist.
@Paul: Easy is the introduction (and a feature, yes), but I’d argue that power and flexibility are the long tail. Check what I’m doing with Fwd:Vault (100% PHP-based) to see that power and flexibility at work.
For those making the argument “People write crappy PHP code, therefore PHP is a crappy language,” that’s called a Confusion of the Inverse fallacy. There are crappy coders in every language, it has zero bearing on the language itself.
@Don Hopkins
I’m relatively amateur I guess, the only scripting language I know is PHP. A little Java and C from University and thats it basically.
I thought your comment was interesting, and started reading through those references you posted. Half of them are fairly dated – you know that yes? 04/05 mostly.
I don’t know about the inner workings of PHP, how it handles recursion for example. But it seems that some of the other arguments are fairly trivial to me:
Inconsistent naming of functions, its never really bothered me. Some of them have underscores in them, yes its not consistent BUT the functions are written for you and there are a lot of them. Use a reference of some kind.
Bad practices in coding, broken windows, not using MVC. The onus is on the programmer there. I don’t really follow how this is a criticism of PHP itself. People implement the language in many different ways, its flexible. I think that is a plus.
Not backwards compatible with PHP4. Well, they had to make some changes didn’t they. Is Python 3000 compatible with the older versions?
Rasmus Lerdorf doesn’t know how to create a language – is this a criticism of PHP? He said you couldn’t make it perform well under loads the likes of Yahoo! have and that is only achieved by c compiled, that no scripting languages could handle that load. Maybe he doesn’t know how to create a language, but there are a lot of people working on PHP and making it better with every release – I don’t see why it can’t evolve just like every other language out there.
I don’t know, I read all these ‘PHP sucks’ posts looking for that argument that makes me go ‘Oh, no shit. Wow, I guess it does suck’. But in the 5 years I’ve been using it I’ve never seemed to have problems with many of the issues people are complaining about. I’m coding medium sized projects and it seems to work well. I employ different programming patterns and have fun with it.
And there is one other good argument as to why PHP does not suck: ubiquity. You are going to get a job programming PHP.
Frank: nobody disputes you can do cool stuff in PHP as you can in any language.
The question is whether that is because it is a quality programming language or because you are a good programmer and can make do with lesser tools. Can you please point to language features of Python or Ruby that would have made the project infeasible or harder in Django or Rails or Merb or Pylons?
Frank, sure – they’ve been iterated like a million times already:
1) Slow
2) Incredibly slow recursion
3) Inconsistent naming
4) Horribly verbose syntax, e.g. array(array(“lol”)) s. [["lol"]] in python, “function($var) use($foo) {}” vs. “lambda var: foo” in python – If you want to write Java with the verbose horrible syntax and no speed – use PHP.
5) Bad object model (even in PHP5) with a few tacked on “magic” features to keep the masses happy (__get, __set, __call, etc.) (compare this to ruby or python for example)
6) magic_quotes_gpc
7) Inconsistent argument order
8) A type system which is stupid beyond belief, e.g.
$var = “0″; if(empty($var)) echo ‘PHP considers “0″ to be an empty string…’;
9) Namespace seperator is the world wide escape character \
10) Basically can’t dereference anything, this gives an parse error: function test() { return array(1, 2); } echo test()[0];
These are just the ten first things of the top of my head, if you dig deep enough (which you usually end up doing when working with it) you can find 10-20 more *REALLY* stupid/annoying things.
Guys, you’re still not hearing me. We’re all geeks, and we can argue the qualities of any language for hours on end. I honestly don’t care what language you use, or what you think of my own choice. I am simply tired of seeing programmers spouting off about something they “hate” without any rationale behind it other than “it’s not what I use.” That’s what Jeff did and that’s what I’m calling him on in this post.
Paul and Fredrik, both of your recent posts provide some reason supporting your opinion. You put thought into it. Great. I could disagree of course, but that’s not the point. You put forth more effort than Jeff did, so mission accomplished as far as I’m concerned.
I’m sure Jeff has some reasons for his opinion (I hope), but until he voices them succinctly his comments are usual fanboy blather.
Of course, I’m happy to host and referee Round 314159265 of the language battles, so feel free to continue!
i must say that, when i started programming, i picked php because it was easy. and in my experience, most people starts with php because it is easy (to learn and to deploy). php has some nice things, but the language design is simply horrible (because there is *no* design). if i had a clue when i started, i’d have picked something else.
Nicely written article, Frank.
I code both PHP and C# and I have seen well-written apps and horribly-written apps in both languages. I agree that PHP engine and the language design are not as clean as those of C# but it all comes down to how you use it.
They are merely tools in my opinion thus it’s a matter of preferences. Some can build a nice deck with a hammer and some can’t build a dog house with an automatic hammer.
BTW
It’s hard to read Capcha words.
@aston: I never understood his random distaste for it.
What makes you think it’s random? If *I* can have non-random distate for PHP then surely Atwood can.
I always wonder why PHP gets such strong opinions. It reminds me of the anti Microsoft people around the world. Sure Windows isn’t the best OS out there, and sure there are far better alternatives. Sure it’s not the safest OS out there and there are lots of reasons not to use.
Still it controls over 90% of the pc market.
The analogy with PHP is simple: it doesn’t matter how broken, bad or unsafe something is. The only thing that matters is, if it works. Look at the top 1000 websites of the world. Look at how many of them use PHP. Last time I checked it was close to 80%. Maybe it went down a bit, but it’s at least above 50%.
So for all you fanatics, think about that next time you feel inclined to point out what a stupid language PHP is. Perl, Python and Ruby combined don’t even come close to the massive number of sites this ‘buggy’ language powers.
If it comes to webdevelopment, PHP is king, if you like it or not. So instead of all this negative energy, try to do what the people did: make a better, more appealing alternative. Or fix PHP so it’s less broken. Either way, use your time for something better than telling other people how bad PHP is: everyone knows already and no one cares.
I respect the PHP community for its enthusiasm and for its persistent hard work to better the PHP stack all the time.
I wish that other languages will be accompanied by frameworks with so much built-in shortcuts as PHP does.
The fact that PHP ********* mixes language with html ********** is absolutely horrible, disgusting and deplorable. I have no words to describe the offense I take at this fact.
I use languages / frameworks where code is attached to the tag id of the document. The page remains purely attractive and usable by all parties involved. When I see a framework that does this in PHP I will take a second look. Till then, good riddance.
Sometimes I think I understand why some people are so detested with PHP.
As a web developer it pains me to see Internet Explorer to be the #1 browser in planet. But then again, I have to support that crappy thing for the sake of browser compatibility. Why you guys are so pissed off for?
PHP is and will be one of the most popular languages in the web arena.
Accept the fact and suck it up.
So much has been written about this.
PHP was a success despite being a crap language.
Personally I refuse to use it since several years.
Ruby has replaced it. I can still understand people who use PHP,
but this does not change the fact that PHP as a language is simply horrible,
and I am glad that I no longer need to use it.
The only thing that makes me sad is that the other languages did not yet dethrone PHP, which shows that dethroning another language is not an easy task.
If 10000000000000 flies eat shit, that doesnt mean that shit tastes any good.
Meh, let him knock PHP all he wants.
Meanwhile I’ll keep on making good software easily and quickly, and getting paid well to do it while he waits for ‘the next big thing’.
THERE ARE 2 TYPE OF LANGUAGES: the ones everybody complains about and the ones nobody uses
- Ruby? No one uses it any more. There are better alternatives, like JRuby.
- Python? Sys admin love it. Hey, it’s much better than shell scripting right?
- PHP? Programmers use it, web developers use it, web designer use it, my mom uses it and even my dog uses it. Why use something else?
Python and Ruby cannot and will never compete with languages like Java and/or C, so stop dreaming about it. They might be able to comete against PHP, it’s the only popular scripting language and has its flwas. But, to compete you need to offer something new or solve a problem that hasn’t already been solved.
The biggest issue with Ruby is that its popularity is fading away and they now have a very small and angry community. The issue with Python is that Linux is supporting it, and therefore sys admins are supporting it. And of course, Google supports it, an because of that, lot of fanboys are supporting it as well. The same fanoboys that go from blog to blog writing rants about Java, C, PHP and Ruby.
For me, Ruby is like Delphi, and PHP like Visual Basic. And you know what, although Delphi is far much superior than VB, no one uses it anymore. And you know why? Because it didn’t bring anything new to the table.
Does Python bring something new? No, it’s just another scripting language. But it’s fast, stable, has a great execution model and Google pays one of the best software architects, Guido, to maintain it and improve it.
And about Jeff Atwood, what do you expect from an ASP developer? ASP was the biggest joke in the history of programming languages.
Google pays one of the best software architects, Guido, to maintain it and improve it.
I’ve heard Guido referred to as many things but “best software architect” hasn’t been one of them.
And about Jeff Atwood, what do you expect from an ASP developer? ASP was the biggest joke in the history of programming languages.
That’s a cheap shot. I would almost call it guilt by association but it isn’t even that good. Its more like guilt by the poster being an idiot.
PHP’s success comes down to four things:
(1) Ease of parameter handling. No fiddling with a CGI extension and request parser and all that; the request parameters are magically available as global variables.
(2) Ease of error handling. You just ignore errors, and usually the program will keep on going and do approximately what you want. For a lay user or inexperienced developer this lack of complexity is attractive.
(3) Put the code directly in the HTML page. This reduces the need to deal with program structure and separation of data from presentation, and lets you focus on the short-term reward of building a single page easily.
(4) Adoption by web hosts. At a time when the alternatives were CGI and CGI/Perl, PHP offered an alternative that was easy for the host to support and easy to developers and non-developers alike to use.
And of course points (1) to (3) also explain why PHP is a poor programming language(*) and prone to security problems – it does magic things, it encourages you to ignore errors, and it discourages separation of concerns.
Since someone linked to my PHP Is A Ghetto post, I thought I’d exemplify the ability to hold two contradictory perspectives in your head at once: http://blog.ianbicking.org/2008/01/12/what-php-deployment-gets-right/
A hammer is a better tool than a refrigerator.
A wrench makes a better hammer than a mug.
No hammer is as great as the sledge hammer.
These statements are utter gibberish – obviously – for one simple reason. There is no context. There is no “when” or “as long as” or “wherever” clause to follow, qualifying when, why, or how, these tools compare to one another.
I see arguments where PHP is a poor (read: horrible) choice for recursion. You know something, I’d have to agree with that. My question becomes… why would you use PHP for recursion? I’ve gotten into a slew of complex algorithms lately, in game design, web crawling, even just automated filesystem maintenance. All with recursive problems. All solved iteratively. To put it simply, given enough time and storage, yes, recursion is one of the most graceful strategies for computation in a dev’s belt. But we, collectively, never have enough time or storage. So, we come up with iterative algorithms. My question, better stated: Why would you use ANY language for recursion? I’ve never yet seen a recursive algorithm that couldn’t be done iteratively.
And, on top of that pile, what language IS good with recursion? Oh sure, some languages may make it seem nice and handy, but under the hood, it’s doing the same things. Pushing and popping mind-boggling numbers of activation records on the runtime stack, quickly ballooning. Go ahead and try running the classic recursive fibonacci function (recursively) on your best PC. Do… say… fib( 100 ). Bet it takes longer than you’d think. Any language you pick.
I picked on the “PHP is poor for recursion” argument off of that initial list of 11 because it was the easiest to make my point, which is this: You wouldn’t use a roll of duct tape as a hammer, and you wouldn’t use a keyboard as a screwdriver. You can take any language, and come up with an infinite number of situations where that language is a poor choice. We can all do that. The trick, the real trick where the “goodness” of a language, and the skill of a programmer comes into play, is that said programmer knows what tool (language) to use for what job, and do so well. You can’t solve every problem with a hammer, and you shouldn’t try to, or else I’d recommend finding a good attorney.
Welcome to the discussion, Ian! Glad to see I’m not the only one who can put aside the downsides and still see the good.
Thanks to Paul for pointing out that “easy” IS a feature. Here’s two things that make PHP easy.
1. PHP is very flexible. If you don’t want to mix up all your code (as you shouldn’t), and you don’t want to use one of the myriad of framework options out there, it’s incredibly easy to separate your data logic, controller, and view. Hell, you can practically do it with just file includes. Want to keep your data functions separate? Put your data functions in separate files, and include as needed. Want a front controller instead of having the user hit separate files? Send everything through index.php, and use the $_GET data to load whatever controller you’d like. And for your view? Well, PHP is practically a templating language in itself, so just don’t put non-view logic in your view includes!
2. The crap function naming would actually be a pain in the ass if the manual wasn’t so damn useful. It’s 1 part manual, 1 part cookbook. At least half the time I go looking for a php function to solve a simple problem, someone in the comments has already provided me with something I can use. I can’t say this about any other language.
All in all, I know and like ruby, and I know and like python. I also know that I don’t like C# and Java because they aren’t fun to program in for me, although I do appreciate the niche they fill. But I still choose PHP for web projects, because despite the well thought out and articulated lists of flaws provided, it’s got a ton of perks, it’s very flexible, and it does it’s job admirably.
@florin
I don’t understand what you mean by code attached to the “tag id”. Are you talking about having code represented as tags in your view? PRADO (www.xisc.com) does that, and it’s been around since PHP 5.
Hi I am so grateful I found your site, I really found
you by mistake, while I was searching on Yahoo for something else, Anyhow I am here now and would just like to say many thanks for a incredible post and a all round thrilling blog (I also love
the theme/design), I dont have time to browse it all
at the minute but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back
to read a great deal more, Please do keep up the great b.
xgow [url=http://www.itosweb.com/thomassabocharms.html]http://www.itosweb.com/thomassabocharms.html[/url] [url=http://www.itosweb.com/thomas-sabo.html]cheap thomas sabo bracelet outlet[/url] dqsk
[url=http://www.itosweb.com/thomassabocharms.html]cheap thomas sabo bracelet buy[/url] [url=http://www.itosweb.com/thomas-sabo.html]thomas sabo charms[/url] tyep
[url=http://www.itosweb.com/thomassabocharms.html]http://www.itosweb.com/thomassabocharms.html[/url] [url=http://www.itosweb.com/thomas-sabo.html]thomas sabo bracelet[/url] mmex
[url=http://www.itosweb.com/thomassabocharms.html]thomas sabo bracelet[/url] [url=http://www.itosweb.com/thomas-sabo.html]thomas sabo bracelet[/url] ythi
rfmu
tvoi
egvo [url=http://www.itosweb.com/thomassabocharms.html][/url] [url=http://www.itosweb.com/thomas-sabo.html][/url]