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!
PHP sucks is incredible misinformed. *Any* language can be considered to suck if it's being written by a programmer who sucks. Yes, the functions are doubled in cases and yes, the parameter lists are annoying at times, but PHP can be just as elegant as any other language, if not more, if a good programmer is writing the code.
Furthermore, compare its execution speed with any of its competitors and I'd bet for PHP more often than not.
I used to be a C# programmer and I have found that with PHP, I am far more productive, I enjoy my programming time significantly more, and my applications are more elegant. Obviously this is subjective, but isn't part of the point of programming to enjoy it, to create elegant solutions, and be productive?
Anyway, that's my 2 cents.
Derek Parnell on May 21, 2008 2:02 AMDon't mix-up bad programmers with a bad language, most PHP code out the looks crappy and ugly because of bad programmers. It is totally possible to make good working beautiful coded applications where code, data and context is separated.
PHP is as good as C and almost as forgiving, this means that the programmer needs to put more discipline into short, readable and good commented code.
Yaa101 on May 21, 2008 2:06 AMI'm surprised that the dollar sign thing in PHP doesn't get critique. Every single time Python is mentioned to an audience, who likely have no idea what it is, the use of white space is mentioned as if some kind of original sin that makes whole language impure. I honestly can't understand how anyone with experience from any other language can stand PHP's requirement to use dollar signs to tell the interpreter that the next thing is a variable.
Couldn't the original language designer bother to read a book about compilers and just threw something together?
No offense meant to PHP users. I know that after a while things like typing $ becomes automatic and there is something to be said about having absolutely no restrictions (types, include files, namespaces etc.). If you are really good programmer, you can do good code without any boilerplate. Unfortunately most programmers are not that good.
Bloodboiler on May 21, 2008 2:07 AMJeff, did you let Reg write this entry without telling us? Next thing you'll be all "blurb this" and "blurb that".
Ethan on May 21, 2008 2:08 AMAt least you got one thing right "... But It Doesn't Matter". I'd like to let everyone know that at least 70% of the web related programming jobs out there will have you working with PHP, most likely using a LAMP stack. If you'd like job security, knowing PHP is pretty handy as it is the standard for web application development.
The PHP Team understands the problems with the language, the advances being made in frameworks, unit testing and the mass conversion from the bastardized OO in 4 to mostly better OO in 5 are mitigating those issues.
Jake on May 21, 2008 2:12 AMThe article completely missing the point of PHP: ease of exploratory web development *and* deployment.
With mod_php, which is widely available even in most basic ISP hosting plans, developing php is like writing html pages, no additional set up necessary, unlike fastcgi/scgi/app servers required by other languages. Deployment is simple as well, just copy the code directory over and you're done. Rails is simple to development but a bitch to deploy with various additional *required* components to choose/setup. The mod_php model also ensures no memory leaks due to PHP scripts. PHP scales because apache/mod_php scales.
The flat namespace and ill thought out libraries of php are ugly, but with the search function of php.net and the helpful comments, nothing can't be worked around quickly.
Until language elitists figure this out. PHP will be the dominant webapp language for a very long time.
Yada, yada, yada, all words. Since PHP is considered by some easier less verbose than C# then put your money where your mouth is by solving the problem below cleanly elegantly:
For this XML:
( http://today.java.net/pub/a/today/2004/08/12/groovyxml.html )
I want to get totals for accounts "a" and "b" and then store everything into a strongly-typed collection or list of objects (or failing that hashtable / dictionary). So basically I want:
id = “a”, total = 1700
id = “b” total = 3400
In C# the solution comprises one line, try to replicate that in 1 line or less:
from account in xDoc.Descendants("account")
group account by account.Attribute("id") into accountGroup
select new
{
id = accountGroup.Key.Value,
total = accountGroup.Elements("transaction").Sum(t = (int)t.Attribute("amount"))
};
Anybody up for a challenge ?
Was it not the great Bjarne Stroustrup that said:
"There are only two types of programming language:
The type everyone complains about.
The type nobody uses or cares about."
I think that you can judge for yourself, based on the amount of b*thcing about PHP, into which of these PHP falls.
memyselfandi on May 21, 2008 2:55 AM"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."
Hehe... good one dude. What I got from the blog is more like "everybody sucks at PHP and it's ruining the language because the sucky features that sucky programmers seem to like (and good programmers hate) is all being rolled into the core language."
This can happen to any language: VB being the prime example. There is nothing fundamentally wrong with VB depending on who you ask. For the most part it is just a programming language. The preponderance of bad VB being set up as "example code" and the developers who aren't good enough to see that the example is bad code, and used it in droves all over the place, caused VB to evolve into a bad code space to be working in.
That is the problem with PHP - not that it's a bad language, or that it's hard to learn or anything. It's that when you adopt PHP, you also get it's whole extended family of crap code, and the crap code that survives long enough seems to be happily folded into the main project as a new function. This is a bad ecosystem to be living in. Survival of the fittest may not be working correctly in the PHP world - and that makes it a bad environment to work in - IF you choose to use the built-in stuff. And if you choose not to use the built-in stuff, then you might as well not use PHP, because it's not much of a language by itself - it's the built-in framework that makes it useful on web sites. And I'm sure there is considerable disagreement over whether functions like a special regex-based substring should be folded into the main project or not.
There's a bunch of reasons why I think those functions should NOT be part of PHP - the main one being what someone else touched on - that it gives me an incentive to not write my own version of the function, and there is no way to choose a different library for that function, or eliminate libraries to make it leaner. You get all the weird functions or you get nothing - not even the language itself.
Let us just start with the old 'its got to many functions' - they may have thrown everything into the toolbox without thinking if it should be in there, but the fact is you do not need to use them, and I probably only use less than 5% of them in a normal day.
One of PHP's greatest advantages and disadvantages is it's simplicity. It allows any old newbie to knock something together which is great, but it also means a lot of very bad code gets written.
Within a well structured team following strict guidelines it can be a beautiful language, coded badly it can be an absolute mess.
I have been programming since the days of BASIC + Assembler (6502,65186) and I have tried most things over the years and always strive for simplicity + the ability to build structured complexity. PHP is the most fit-for-purpose language in the web 2.0 space giving a fine balance between quick to build and scalable given time (and lots of extra's)
Whoah, so many comments.
I liked php when I did it. It was way better than (classic) ASP being far more expressive and easy to use framework. It also had a wicked searchable online reference with decent examples to help you get up and running. The quality of MSDN still isn't always on par for how good that online help was.
Sure the name of some methods suck, but really, if they wanted to change that, they could. You get used to these things.
I think the benefit of compiled languages like C# are the fact that they work better in large teams. There's also a lot of benefit to catching errors at compile time. Stuff like ASP.Net does integrate better into a windows infrastructure. Let's face it, there's a lot of windows infrastructure out there.
Popularity doesn't mean it was done well at the start, but popularity means everyone knows it (and probably hate it to a degree). But it gets the job done in the end, and no methodology gaurantees that, no matter how pretty or perfect it is. Like windows, it's not the best, but it sure is popular.
Seriously, C# is great, but sometimes I get the feeling that there are too many teams in MS pushing too many technologies. My brain can't keep up. I should become a manager I guess.
overloaded on May 21, 2008 3:19 AMAll languages are collections of arbitrary stuff borrowed from other languages. And arguing about how pretty one language vs. another one is like arguing about which language you should use to write a recipe for a cake.
PHP is an interpreted language. That alone should make you want to use another language.
Steven Rogers on May 21, 2008 3:27 AMWell, really, PHP 4 sucks, and PHP 5 isn't all that bad. The PHP 5 object system is pretty decent, and PDO (which is available for PHP 5 and standard with PHP 5.1) is a decent way of accessing a database. The problem is that almost all PHP code in existence is PHP 4, and the PHP developers I know are hardly aware of PHP 5 features, mostly because their hosting companies haven't upgraded yet.
-Max
Max Kanat-Alexander on May 21, 2008 3:35 AMLike others have said, crappy code can be written in any language. PHP just has such an unusually low barrier-to-entry for new programmers that you end up with a lot of people slinging around crappy code.
I've seen some absolutely brilliant engineering done in PHP. There's plenty of modern software constructs available in the language, and plenty of frameworks are available if you really want to make your solutions clean.
I've heard all the arguments before, and like you say Jeff, they really don't matter. When I started coding in C I was constantly looking up library function names and parameter lists, even though they were all logically consistent. Even though you can argue that PHP's function names aren't consistent, that's relatively unimportant to experienced programmers who have most of the commonly used functions and their parameter lists memorized. Not to mention that the manual is fantastic.
"no sensible framework baked into overall product"
Why on earth should a framework be baked into a language and thrust upon you? Separating your framework from your language should be a language designer's primary goal, not something to be avoided...
Bob Somers on May 21, 2008 3:37 AMi couldn't disagree with you more Jeff. php, as a language is easy and sensible. there are a LOT of library functions, but you're making the wrong comparison. if you put php side-by-side with VB + .NET, you'll find that php does what a web developer needs and is simpler and more efficient. i've used both, and will use both again (though i lean more towards c# in the M$ world), but my preference is for php.
marty nickel on May 21, 2008 3:39 AMAlso, it might be interesting to do an article on how almost every "X Language Sucks" article or comment in the world is written by people who have never used X Language extensively, or by people who don't have a good understanding of the features of X Language, or by people who have only used one language and think that any language that works differently automatically sucks.
When I was discussing alternatives to Perl with people, the defenders of Perl were uniformly people who didn't have extensive experience with any other language. Defenders of PHP 4 are often the same--they don't know anything about any other language because they *don't have to*--PHP is so popular that they could program in it for the rest of their lives and never see another language. I'm not saying that either of those languages suck--they have their uses. I'm just pointing out that it's interesting that most of the arguers in this field--on either side--are uninformed.
-Max
Max Kanat-Alexander on May 21, 2008 3:44 AMVery good article!... I agree, PHP may have its downfalls, but all can be resolved with good coding practices, and future releases. The same thing has happened with dozens of other "non-professional" languages. Also, PHP is easy to configure and install, regardless of the machine it is on, and all of its weaknesses are well-documented, with work-arounds readily available to everyone. Also, I think an environment where you *can* make mistakes will teach you not to make them more effectively than one where mistakes are impossible, or unlikely.
To use an analogy:
Fancy running shoes won't make you a sprinter, the best ingredients in the world won't make you a chef and world-class paints and paintbrushes won't make you an artist... only hard work, practice, patience and some talent can.
I've always thought that learning how to *program* is more important than learning a particular language, or how to use a particular editor.
Thomas Borzecki on May 21, 2008 3:48 AMPHP is so popular for a few reasons:
1. It sucks but it's a modern-day kind of suck. Not a 10 years ago kind of suck which is altogether a different kettle of fish.
2. The WWW is still young enough that you can get a lot of eyeballs with applications that are of the "low hanging fruit" variety. Put another way, the apps aren't doing terribly complicated things but what little they do can be popular because we haven't gotten to the more complex things yet.
3. A lot of the complexity lives on the client via javascript or HTML. So PHP is mainly a glue for generating the right HTML/javascript.
4. A lot of the complexity lives on the server (I'm thinking RDBMSs, back-end processing, etc...).
I expect most of those popular websites to move to a more structured framework by the time AJAX 2.0 is passe. They'll crumble under their own weight if they don't.
PERL apps followed a similar trajectory. PERL was so easy to use that you could get a working product out the door in much less time. By the time you're on your 6th version, feature creep + a too-freewheeling language have prompted a rewrite in either java or C++...
The 180 comments in this page shows only one thing:
PHP IS THE MOST FUCKING POPULAR LANGUAGE IN THE PLANET!!
It doesn't suck Jeff, you are just a shitty programmer LOL xD
mark on May 21, 2008 3:56 AMGod... I don't think I've ever seen so many elitists on one web page.
The hammer is only as good as the carpenter, plus, how many hammer do you get (which are free to the public) which don't break?
Some of you assholes need to get over yourselves.
Wolf_22 on May 21, 2008 4:22 AMReading these comments further, if you take nothing else away from this lesson (beating?!), Thomas Borzecki has written one of the concisest, yet most useful comments I have ever seen, particularly the last sentence. Heed and learn, then maybe TRY using PHP (or PHP.net?) or any other language/environment properly before slating it!
Daz on May 21, 2008 4:29 AMI would have to say, coming from Java, PHP was really easy to pick up and start using almost right away.
I am still not used to the Asp.net (VB) and have been using it for almost a year at work. I understand it's a framework but some of it is so hard to use. HttpContext.Current.User.Identity.Name to get a username instead of $_SESSION['username']. Just seems easier. Less stuff to deal with. $_GET, $_POST, $_SESSION, $_FILES is all I really need to know about PHP. Asp.Net there's just so much more to pick up.
But i guess theres a give and take in any situation.
I love Visual Studio, the best IDE i have used however, the new Zend Studio is pretty good too and does have support for Refactoring. OOP and exception handling in PHP 5 are fine with me.
Mike CEZZER on May 21, 2008 4:29 AMI don't know if you're being entirely fair. Having so many functions is evidence of:
- How far PHP takes you before you have to do any of your own library writing, and
- The historical lack of namespaces (coming, I believe, in PHP6).
Re: function name conventions: functionnamelikethis() and FunctionNameLikeThis() are identical. PHP function names are not case sensitive... Admittedly having this_convention() and thisConvention() is kind of a kludge, but it's like that for historical reasons.
And browsing the PHP.net function library will get you 99% of the info you ever need.
@steven rodgers, I suppose you write your websites in C++? Everything else is bytecode or interpreted. Don't be such an elitist. Did you know PHP compiles to bytecode if you use an optimizer? There are many options, many of which are free.
PHP does some wonderful things and the key is that, like C++, it supports many programming approaches and it's up to the developer to follow best practices. (Heck, it even has anonymous/lambda functions, besides objects, literals, and the usual.)
Note, though, that Facebook is partially PHP and partially C++ and Erlang and other languages.
I read PHP's rand function. I read what their developers said about it. They are fools, they know nothing about seeding they know nothing about their silly rand function. rand is broken on win32 because the developers made stupid assumptions and then got blown away by casting floats to longs and assuming their bits were random.
PHP sucks, PHP devs are pretty awful, developers who use PHP - grow up.
Hey Jeff,
I think you failed to mention that Yahoo! is one of the largest PHP shops around. At MIX during the interview of Steve Ballmer by Guy Kawasaki, Steve mentioned how Microsoft was the biggest ASP.NET shop around. Then Guy mentioned that Yahoo! was the biggest PHP show around. Steve followed that up that if the Microsoft merger with Yahoo went through, Microsoft would be the biggest ASP.NET shop AND the biggest PHP shop.
Although PHP has more warts than a hundred toads, that doesn't mean you can't write clean, well-designed code with it. As already mentioned in previous posts, there are various MVC frameworks written in PHP, and there are developers who write object-oriented, n-tier code with unit tests, etc. By the way, most of the crappy PHP out there is written in PHP 4, PHP 5 is a completely different ball game.
Is it not possible to introduce concepts like N-Tier, Unit testing, frameworks to PHP?
I don't think the problem is with the language, but with the communitiy. I like the ASP.NET community more that PHP's. Because PHP''s community seems to be dominated by many "scriptkids" hobbying in in their basements. As a result, there are a lot of bad code examples on the net on PHP. Whereas ASP.NET enjoys much more professional community.
Matthijs on May 21, 2008 5:10 AM@Matthijs
Have you been living under a rock the last 5 years?
This stuff is all available in PHP5.
Just to name a few main stream frameworks:
CakePHP
Symfony
Zend Framework
The unit testing suit for PHP is created by Sebastian Bergmann.
N-Tier is a way of building applications. It should not be build in a language. It's something you should be able to create with any language available.
As far as the function naming goes. i agree. It's a mess. And even the parameter order for the functions are mixed. Like reversing the needle and haystack. But that doesn't cause bad code to be written. I've been a web developer for the past 10 years. And have seen my fare share of bad coding. Not only in PHP. This has nothing to do with the language. It's because PHP is a trend. So everybody jumps on the bandwagon.
This phrase made me smile though :)
PHP isn't so much a language as a random collection of arbitrary stuff, a virtual explosion at the keyword and function factory.
Thijs on May 21, 2008 5:22 AMListen to what inventor of php Rasmus Lerdorf thinks...
http://itc.conversationsnetwork.org/shows/detail3298.html
I think the problem with PHP is the same as with Javascript: too many people have access to it. We all hate Javascript because of the astounding amount of bad Javascript that is out there. And there's a lot of it because everybody with a browser has a compiler. PHP is on most every Apache server out there, so non-programmers who just have a website can use it. It's a step away from Javascript's ubiquity, but close enough.
I write in PHP, but I come from a COBOL background, where I had to structure everything just write and keep under the 4kb memory limit. My stuff is clean, so I will defend PHP as a tool.
As far as apps available written in it: I totally agree that most are worthless.
Chris on May 21, 2008 5:25 AMWhat is wrong with wanting beauty for beauty's sake? It is good to have languages and tools that do not make you queasy all the time! For the reasons you mentioned, I am glad that I do not have to use PHP on a regular basis.
That being said, I do find that I can accomplish a lot in PHP with just a few lines of code. It just always feels like an ugly solution.
Vadim on May 21, 2008 5:28 AMFacebook’s written in PHP too, I think.
Paul D. Waite on May 21, 2008 5:29 AMPHP's lack of namespacing from the beginning is probably a major downfall, but you can go too far the other way if you're not careful (just look at the sheer size of Java and .NET's respective runtimes). Namespacing has a tendancy to encourage growth, especially if it's nice and extensible.
Hopefully PHP 5.3/6 will strike a balance here, though.
Personally, I know that nice, structured, designed code can be written in PHP (it's what I do for a living, and I know I'm not alone in that), but I don't tend to go posting code snippets in forums asking for help. None of this is because I'm an experienced PHP programmer, of course, but because I'm an experienced programmer in general—PHP's biggest failing was giving novices who didn't know better enough rope to hang themselves.
Mo on May 21, 2008 5:30 AMit all depends who's coding...
Tim on May 21, 2008 5:35 AMFacebook’s written in PHP too, I think.
Paul -- thanks. I knew I forgot a big one in there somewhere. Added.
Jeff Atwood on May 21, 2008 5:39 AMI always thought Youtube was built with Python not PHP.
lubos on May 21, 2008 5:41 AMMo:
"PHP's biggest failing was giving novices who didn't know better enough rope to hang themselves."
While I agree that it is a problem giving novices the rope to hang themselves, I believe that this is actually a symptom of an even bigger failing: PHP presents developers an inconsistent environment, because things can be toggled on and off by INI settings.
Magic quotes is a good example here. It's on by default in php.ini-dist and off by default in php.ini-recommended. This means that people who learned on one are going to get it wrong on the other, leading to SQL Injection attacks.
Of course, the correct way for experts to handle it is the use of the magic_quotes_gpc() to see what the current setting is and handling it appropriately.
Another symptom of the same problem is that you cannot rely on anything but the most basic of functions to be present, as most can be turned off at the edit of an ini; either by module by commenting out the module's name or by function using the disable_functions setting.
Powerlord on May 21, 2008 5:41 AMOne huge advantage php has over .NET is the transparency and editability of the source code to front end developers.
Working on a PHP site I can dive in knowing little more than to comment out " and ', and can make changes to id's, divs etc without having to know the language.
However, working on the front end of a .NET site you either have to constantly bother the back-end developers to alter the source for you, or learn a fair bit about the relationships between the controls and the html they output.
If you care about back-end and front-end developers being able to work seamlessly together then php definitely helps.
Rhys on May 21, 2008 5:45 AM@Mo - Like I said, I'm sympathetic because of my background in "non-professional" languages like Basic, but PHP is almost pathologically bad! Here's one example:
http://www.bitstorm.org/edwin/en/php/
--
Some function names consist of more than one word. There are three conventions for combining these words:
1. Glued together: getnumberoffiles
2. Separated with underscores: get_number_of_files
3. Camel case: getNumberOfFiles
Most Languages choose one of these variants. PHP uses *all* of them.
--
YouTube is almost entirely written in Python
http://youtube.com/results.php
http://youtube.com/my_videos.php
http://youtube.com/my_account.php
It is believed that Guido is referring to the YouTube backend. It's also possible Google forced a rewrite, as I don't believe they support PHP on their server farms.
Jeff Atwood on May 21, 2008 5:47 AMThe problem is php originally stood for Personal Home Page. And you can see that in the design. They have been adding one layer of functions on top of the other. This doesn't make it a bad language. It just makes it a badly designed language. If you compare it to C# or others. You don't get the feeling of consistency. Especially when you go into the OO interfaces.
Personally, I used it for big projects because it was the only real thing around a few Years ago. Today I would never put up with this mess. I shouldn't have to care about what SQL backend I use. Even with Cake it is just another layer on the onion.
I liked this...
http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html
The guy learned MVC using rails but didn't like all the "magic" rails does under the covers so he switched back to PHP and re-wrote his app properly.
adrian_m on May 21, 2008 5:53 AMI remember the Facebook code leak, which is also coded in PHP. The code was clean and well-engineered.
It's only a matter of who is programming. You just need some discipline.
Good post. At least an interesting read. I've been a PHP dev guy on and off for a couple of years now, and I'd just like to point out that I think a distinction needs to be made between a languages ABILITY to be written in nice, neat, OO style, and the general trend of developers who CHOOSE NOT to write it that way.
Bet I can write some C, Java, Ruby, or Perl that looks way uglier than most of the PHP you've seen - that is, if we're nitpicking the way code looks.
Chris on May 21, 2008 5:57 AMWhile I was a bit offended by the fact that saying a programmer with even an ounce of talent would find that PHP sucks basically translates to that I must suck because I don't think PHP sucks... I can let that pass, since I'm sure it wasn't your intention to offend anyone ;)
Anyway, while it's true that a lot of PHP code sucks, it's definitely caused by - as highlighted by the other commenters too - the fact that most PHP programmers are hobbyists and "amateurs". I can admit that I was one as well, and my PHP code was as bad as anyones. Today it's a different story, though, as I've actually been coding for so long and in different languages, read books (incl. some that are on your recommended reading list) and so on...
I really like languages like C# and Python, but I can't say that PHP sucks. I've been coding in PHP for over 6 years, which makes it the language I've been using actively for the longest time. After you've been working with something that long, it all actually starts to make sense - but I think that PHP's problems, such as function naming and parameters being inconsistent, and the problems they cause are exaggerated a lot.
Jani on May 21, 2008 5:58 AMI agree with the first part, not so much with the second. Why do I think that my opinion matters? Because less than half a year ago, I've consciously chosen PHP for a web application framwork I've built. All things considered, PHP was the right choice for the job and the resulting application works very well, has a very clear architecture, is extensible, efficient, separates concerns, models MVC, and generally does all the Good Things that you'd want in an application.
And still, PHP sucked. And it DID matter. A lot. How did it matter? I claim that, had the language been better designed, writing the application would have taken half the time. That's right, half the time. Costing half the money. Which, for a small start-up, is a lot.
Saying that “it doesn't matter” seems awfully cynical. Of *course* it matters and I very much regret that I had to spend any time whatsoever working with that defective tool. The thing is, one of the biggest reasons to use PHP (and the main reason we used it) is its wide spread. If you want to run your application anywhere, you've got no choice but PHP. This actually makes me quite mad: I'm mad in part at the inertness of the internet providers who are unable to provide clearly superior tools in their services, and in equal part at the PHP developing community who expose us to such a sucky tool, and who persist in developing new versions. Guys! Give us a break, stop developing that crap and force the providers to switch to better tools!
It's easy for me to lay the blame at someone else's feet and rant at them but this doesn't my anger any less justified. PHP *is* badly designed and this fact won't change in future versions.
Konrad on May 21, 2008 5:58 AMThe problem with say, cleaning up the functions and putting them into the right namespaces and libraries, is of course that you're going to break legacy apps - unless you allow for the old functions to be used next to the new.
Then, you have to simply force everyone to rewrite their tutorials and books; because when a function is aliased, it does not scream "I AM DEPRECATED, STOP USING ME YOU IDIOT", so people will just use the old one.
Simply by showing that message in a bright red bold font, I'm sure you could solve issues really quickly ;). ASP.Net truly crashes and burns with its Yellow Page Of Death; while it's really handy sometimes that PHP doesn't, it also allows the programmer to be a bit more lazy.
Oh yeah, either make the links of the functions point to something useful, or remove them and just color the font - right now every single one of them links to your archive ;).
Rob Janssen on May 21, 2008 6:05 AMhttp://video.google.com/videoplay?docid=-6304964351441328559 re: the youtube architecture. They switched to python a long time before google came knocking. They also use C. But i'm not nitpicking because for the most part you are right.
PHP has its abilities, no doubt. However PHP's ability to scale - code length wise, is just not right. The later PHP's are definately getting better. But look at PHP3. It gets messy quick and thats just the nature of it.
I dunno. I'm sick of these debates.
Mike Scott on May 21, 2008 6:07 AMMy question is how people let a profitable version 1.0 turn into a bloated spaghetti-code 2.0 without at least considering a more elegant and robust language.
Yes, I can't possibly imagine how that would happen!
http://www.codinghorror.com/blog/archives/000256.html
Jeff Atwood on May 21, 2008 6:07 AMI love PHP. I don't know why people don't like it, but I don't use the frameworks of the day and engineer everything myself, so my code is elegant and there's an easy transition to blocks when coming from Java and for some reason I just love weak/dynamic typing when working on the web (everything IS a string in the end).
Scott Preston on May 21, 2008 6:08 AMI have to disagree a little bit. Right now I am working on a small website and a backend admin interface for a local theatre. I have never worked with PHP before and I am learning all the time. I use the Code Igniter framework and the experience has been quite pleasant so far. Example from one of the "views", that produce HTML output from data supplied by the controller:
| if ($acts-num_rows () 0)
| {
| function acts_to_str ($i)
| {
| return anchor ("admin/play/show/{$i-play_id}", $i-title);
| }
|
| entry ('Acts in',
| ul (array_map ('acts_to_str', $acts-result ())));
| }
This will produce an ul list of plays an actor shows in, if any. I think this is quite nice. Forms work in a similar way.
| field ('Description',
| form_input (array (
| 'name' = 'description',
| 'value' = $this-validation-description,
| 'size' = 50
| )),
| $this-validation-description_error
| );
Yes, some programmers can write FORTRAN in any language. I also came to the conclusion that it is possible to write LISP in almost any language. You may then object why not use LISP in the first place. Well, it is not always possible. This particular client has very tight budget and cheap hosting in my country (Czech Republic, but I suspect this is the same everywhere) means MySQL and PHP.
Keo on May 21, 2008 6:10 AMHas no one else seen the rails crap that is in some of the open source projects? Jeff you are correct, you can write crap in any language despite best intentions.
Imagine most novices trying to write a web application without rails or a framework - thats what most php developers are doing. Its quite an impressive feat when you think about it, what other language is so simple to prototype in? With rails you have to go through many, many more steps to get a hello world, and most non-developers won't bother.
Plus, php is installed on every server on the planet.
Make your PHP suck less using this miniscule (60 line) MVC engine; I've used it to develop the web UI on an embedded device manufactured by Cisco, for TimeWarner:
http://code.google.com/p/barebonesmvc-php/
George Jempty on May 21, 2008 6:13 AMWhat personally makes me laugh in my mind is how everyone always says how PHP is so badly designed etc., but never can actually show how it slows down their app development. I think PHP's manual is stellar, and it's very easy to find a function for the job and its parameters and such...
No one has really been able to properly argument *why* it is that PHP sucks. The usual issues are always:
- Magic quotes and register globals: anyone who knows what they're doing can turn them off.
- Function naming: while they may be a bit inconsistent, the functions for a specific area (like array manipulation) do follow conventions ok and should not pose a problem for a talented guy (the manual as I mentioned, a good IDE will show the params etc.)
- It just sucks: omigosh, really? =)
What? Oy! That hurts. I guess now I know how it feels to be a fan boy (or perhaps zealot).
Perhaps it is due to my inexperience with other web languages (with the other being the ASP.NET) but I wouldn't call it a bad language. Certainly, as bad as PHP scripts are, I've seen nightmare code born out of undergrads doing ASP.NET. One might argue that's the undergrad's fault and that they are not really programmers but people using WYSIWYG.
And I argue PHP has the same problems. It's easy enough in that you can hack something up and it works, and given the surge of internet pages, these people may not even be interested in anything but getting the job done. Skip OO theory. Heck, they might even skip functions as merely being "useful". That's why there's ugly perl. And that's why (probably) there will be ugly code for all the new and hip languages (once it get popular enough)
I don't see why good code can't be written in PHP even by just someone who learned proper programming concepts. It's just that PHP is too mainstream. It's the myspace of server side scripting. Perl is probably livejournal. Python and Ruby is probably Facebook or Pownce. (Metaphor falls apart because it suggests there's a lot of functionality differences).
Those who are really interested in programming flock to the 'fun' new languages. Those who left are those who probably don't bother improving themselves and newbies.
I suppose I should be showing pure coding examples, and this may just be irrelevant but I do really think that PHP is not bad and I kind of like it. And maybe I'm just a little nutty and that I love programming so much that I even like the worst one.
M. Firdaus on May 21, 2008 6:18 AMNotice a pattern here?
Yes, but not your one.
PHP hosting is free and everywhere, that's why we see so much PHP apps out there. Now take Python, Lisp, Ruby, Haskell, etc. web apps and you'll have to pay for hosting.
Wikipedia, Digg, Wordpress can easily be done in thoses languages too (even with a clearer code I suppose). We only have to wait to see free hosting companies supporting these languages and PHP will not stay on top for sure!
kib2 on May 21, 2008 6:21 AMNo, we all hate javascript because of all the subtleties in different browser implementations. We all hate html for the same reason.
Maybe installing PHP has become easier, but I don't recall it was 'easy'. A real pain when you have to verify PHP on the machine is set up to the applications needs. You had to know what modules were in use and get/compile them if missing. Failing to do so broke your php app. When you went to upgrade, you had to remember the union of all modules in use across all applications and hope that there were no breaking changes.
No better than COM objects in classic ASP land, but it's worth mentioning to the rosy glassed crowd. It's called DLL hell for a reason.
I don't use php anymore, so maybe it's better now as more things get folded in. Heck, that's probably why there are so many things folded into the mainline trunk.
RE no framework ... PHP is a framework. How does it have $_GET and $_POST for variables in html request/responses if it's not got a built in web framework. ASP.NET is a framework for web pages in .net, but C# itself doesn't have a framework. ASP.NET doesn't force n-tier, but it is capable.
n-tier is just a logical way to separate responsibilities, it's not anything a computer cares about when executing code. It's a layer of abstraction for the monkeys on the keyboard.
Who learns a language by reading an alphabetical listing of the API?? That's like reading the phone book to learn how to dial a phone. Let's print out the Win32 API's while we're at it. There is a division between API and the language itself. In PHP's case, they're fairly tightly coupled. But it is possible to write PHP without any API calls, it just won't do very much.
The only thing that sucks about PHP is that the barrier to entry is low and the rules are very relaxed. So you get a lot of folks that are barely programmers writing code that Just Works and Smells Bad.
Paul on May 21, 2008 6:23 AMFor platform independent web applications I believe that PHP is one of the better choices. It is in no way an elegant OO language even though OO has been introduced recently. The list of functions IS scary and have all sorts of problems as mentioned previously.
However, despite the lack of objects encompassing the built in methods it is very possible to design and code well thought out solutions. The language doesn't FORCE you into good design, but it's available for the taking.
I have no doubt the language will evolve to the point where good design is encouraged if not enforced, but for the moment - it seems to be one of the better options if the hardware/software platform is undefined.
`Josh on May 21, 2008 6:23 AMAlright it's like this...
I pay about 100 dollars a year total to host lots of web sites, most of which I coded in PHP because the WEB HOSTING FOR PHP IS CHEAP! And I'm cheap. And the hosting to do a ASP.NET site is expensive.
And to do down and dirty cheap stuff that doesn't require a whole lot, it's easy to mock it up in PHP. I think it just grows past that. Facebook was probably just mocked up in PHP and then it kept going because it was too hard to convert.
Long live the ghetto king of the web languages, PHP.
Matt on May 21, 2008 6:24 AMI think that the problems with the PHP language itself are greatly overshadowed with the quality of code coming out of the community. I'm a professional PHP developer and I have seen a lot of truly awful code written in the language, but I also know it is not hard to right elegant, beautiful solutions.
Stuff like function naming is awful, true, but day-to-day I'm much more likely to be interacting with well designed classes and objects than directly with those functions.
I believe it is the number of amateurs using it that gives us the comparisons to VB rather than the language design itself.
A bit of discipline, keeping to one class per file, putting everything you possibly can in a class, etc. can make PHP a joy to work with. I certainly prefer it to Java, Perl, C++, VB, Ruby... and the languages I do like (C, C#, JavaScript) are simply not as appropriate for the domain as PHP.
Mat Scales on May 21, 2008 6:27 AM@Paul
Who learns a language by reading an alphabetical listing of the API??
Familiarising myself with a language's API and object model is one of the first steps I take towards learning a new language.
Is that just me?
Joe on May 21, 2008 6:27 AM"""
YouTube is almost entirely written in Python
a href="http://youtube.com/results.php"http://youtube.com/results.php/a
a href="http://youtube.com/my_videos.php"http://youtube.com/my_videos.php/a
a href="http://youtube.com/my_account.php"http://youtube.com/my_account.php/a
It is believed that Guido is referring to the YouTube backend. It's also possible Google forced a rewrite, as I don't believe they support PHP on their server farms.
"""
Let's leave aside the fact that having an url ending with .php doesn't prove anything wrt/ the underlying techno - FWIW, I've maintained a mixed .php / .html url space on my wife's website for 2 full years after migration from a QD php solution to a Zope-based one. The point is that the OP wrote that YouTube was "*almost* entirely" written in Python - so what's the point of collecting three urls from the front-end that may - or not - be still in php ?
wrt/ the "forced rewrite" argument, I just don't buy it, sorry. IIRC, Youtube being *mostly* written in Python was public knowledge before Google bought Youtube.
bruno on May 21, 2008 6:29 AM
@Jeff - so I take it you WON'T be using PHP for your new site? You'll be sticking with VB.NET? ;-) I mean Visual Basic 2008...?
VBMan on May 21, 2008 6:31 AMPHP was crufted together over time and it shows, that's why it is inconsistent, yes it is badly designed, and so it is easy to write terrible code, but it is easy to write terrible code in C, C++, Basic, VB etc ...
So why is it popular?
Because it is a scripting language - No compiling, instant feedback
Because it is forgiving - Aliased old function names, compatabilitt settings etc ...
Because it is simple at first - Like VB it is easy to write simple programs, there is not steep learning curve
All of these attract amateurs, who try and be helpful to other amateurs and so there are loads of 'Getting started' pages and cut'n'paste code samples which give the impression of an amateur language, PHP5 is moving away from this ... slowly ...
If you want to create a community for developers, statements like the above, are the wrong way to go about it.
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.
Also: those statements are deliberately over the top. It's supposed to be a little wry, a bit tongue in cheek. You know, humor?
That said, I absolutely think it's important for PHP devs to be aware of the architectural limitations of PHP, and understand the alternatives. I'm not asking them to stop coding in PHP, just to have some context.
But as I said in the post -- results are what matters!
Jeff Atwood on May 21, 2008 6:38 AMIt's another example of the Worse is Better principle, I believe. The tool the majority uses might not be the best for the job, rather it's the tool these people are the most comfortable with.
Delmania on May 21, 2008 6:39 AMI like PHP because there is no impedance mismatch to get your idea up and running. PHP has been around long enough such that its supported in virtually every webserver. There is no compilation involved, just create a page and go.
monsur on May 21, 2008 6:39 AM@jeff
I agree the function naming in PHP is very bad. But it's legacy. And very hard to change and keep backwards compatibility. However camelCase naming is not used in the PHP function names. It's either a complete phrase or _ separated words. In PHP 5 some core objects were added like Date, Reflection, etc. These do use camelCase naming for the methods.
The example comes from a href="http://www.bitstorm.org/edwin/en/php/"http://www.bitstorm.org/edwin/en/php//a. But i think it's more about case sensitivity then actual function naming.
By the way some of the functions you named in the a* list. Are not core functions. They only become available when loading the extension. This doesn't really have anything to do with your article. But i thought i would provide you with this info anyway. The ArrayIterator methods are not functions. they are object methods. And i guess here you can see a trend in "new" naming convention. All are camelcase.
I love PHP =(
=( on May 21, 2008 6:44 AMThe other correlation of your PHP examples is that none of them matter.
I'm quite serious - if any of those sites has an outage, it's annoying, but it isn't mission-critical to anyone. They're barely more than technology demos. If a comment was missing from Digg, who would know? If a page was missing from Google's index, who, apart from the site owner, would know? These systems are error-tolerant in that no-one knows that there is an error.
Over on CodeProject - now rewritten at considerable expense in ASP.NET - we have a community largely of professional programmers that bitches loudly any time they receive an error. There tends to be high visibility of any problems.
Mike Dimmick on May 21, 2008 6:48 AMA lot of people do use it as a frontend, all right. I tend to suspect that its current prominence is more of a fad than anything else, though; when you look at it first it looks very easy, and webhosts tend to support it. It's a bit of a mess actually writing anything big in it though... It's not a horrible templating system, but once you start doing anything else, things get nasty.
A lot of Facebook's backend is in C++, Java, Python, Erlang and other things, apparently, by the way.
Robert Synnott on May 21, 2008 6:48 AMMy rule of thumb is use php for anything up to but not including login functionality (if your hiring someone to do it). An Average .net dev still costs 40% more than a really good php dev in my experience.
Scott Cowan on May 21, 2008 6:50 AMOh, besides that, it has no closures, no namespaces and very weird scoping. Urgh.
I used to use it, by the way; it seemed like a simpler way to write websites than C++ or Java, and I never could stand Perl. Python and Common Lisp were _such_ a revelation.
Robert Synnott on May 21, 2008 6:51 AM@VBMan Jeff said he'll use ASP.NET Ajax and it's MVC framework for StackOverflow.
Also, nice one, Jeff. This is exactly why I don't like PHP.
KTamas on May 21, 2008 6:52 AM@Mat Scales
"I believe it is the number of amateurs using it that gives us the comparisons to VB rather than the language design itself."
I don't disagree with that statement, put a shitty programmer in front of C# and his code will be shitty. But PHP itself is full of poor usage - extremely limited use of exceptions, limited use of OO, no sensible framework baked into overall product. I've programmed in CakePHP and it's a joke when compared to other MVC + ActiveRecord patterns. Even so, I'd take CakePHP as a pretty big step up, but the adoption seems to be fractions of the PHP community. (Akelos seems like a much better implementation, but it's adoption is even worse.)
karl on May 21, 2008 6:53 AMI don't think this applies to PHP only. The .Net framework is probably as inconsistent (in it's own way) as the PHP framework (the language itself isn't that bad, actually). The core of the problem is a functionality overload: there's a function (or class) for about anything. And it's hard to remember all of those.
The major difference between PHP and .Net (for example) is that the .Net framework has an excellent toolset available which migitates a bit of that functionality overload: Visual Studio (Express) and Intellisense. While PHP has those too, they're a lot less visible and available than Visual Studio. In fact: it's harder to start developing an ASP.Net site without Visual Studio than with Visual Studio (even for experts).
So while I agree with Jeff's post, I think there's more to it than he claims.
Inferis on May 21, 2008 6:56 AMOh, and no sensible Unicode support. How many modern languages, especially languages targetted towards the Internet, can you say that of?
Robert Synnott on May 21, 2008 7:00 AM@Rhys
oh ffs... What kind of developer are you talking about?! You can go on a rampage and blindly dump every .net control into an application and don't care about the html code it generates... But it is lousy programming and it gets you to great examples of brainfuck code (http://en.wikipedia.org/wiki/Brainfuck#Commands) in any language!
One of the problems is that even some of the more well known PHP frameworks are kinda crappy... like karl mentioned CakePHP. That makes everyone who does not bother digging a bit deeper, or those who haven't really looked into PHP for a while, think it's a bad language that can't be used to make anything nice.
There are seriously good frameworks too. Zend Framework combined with Doctrine ORM are a *major* win. They have some very talented people behind them.
Btw, if you listed all the classes/methods from the .NET Framework which begin with A, I believe it would be quite confusing =)
PHP hosting is cheaper you know.
That is why young web developers almost always use PHP.
When the app they built gets big, it becomes a problem. Thats it.
Joomla , my favorite CMS is written in php...
most popular boards (phpbb , smf, vbuletin etc) are written in php.
Myself I write some script in php.
I love the simplicity of it.
I love the incredibly big collection of function, that allows to do almost anything. I doubt for instance, that there's a Levenshtein function in ASP.
Who would care if the "english human language" wasn't perfectly designed, if you can express anything you want with it ?
That's the same with the computer language php: I can program anything in php , and everything is well documented.
Yeah, those other guys create crappy PHP but mine is elegant and slick.
Ouch! Broke my eye winking so hard.
old fart on May 21, 2008 7:13 AMTo all the people wanting to find more Python, Ruby, etc... on cheap hosts: these hosts will only install what their customers demand. And their customers will only demand your language of choice if there's software they want to use that's written in it.
So to fix the problem, write software people want to use in the language you prefer and release it!
Joseph LeBlanc on May 21, 2008 7:14 AMno, no and no. PHP 5 has OO and exception handling similar to java and phpunit is very similar to junit (so unit testing is not a problem, only problem is that most of the php developers don't use it).
Because PHP gives you a freedom to write your code in several ways (with php5 you can write pretty good oo stuff), it's easier to write crappy code (or fortran).
I agree about php function names, they are very inconsistent and it's annoying. One other thing i really hate is that there are no consistency about arguments: sometitmes it's func1(needle, haystack) other times it's func2(haystack, needle). Often you have to check reference just to be sure that you are using arguments in correct order.
There is one reflection strikingly absent from all the comments so far: why did ever PHP become the de-fact-choice of all web hosters? Well, it's because of the off-the-shelf php appz, dood! (answer B: it's because that's what the devs asked to hosters). If you go back in time 10 years, finding php hosting would not be so easy. In other terms: demand drives offer - it's just that hosting companies are slow to respond. If everybody asks for python now, they will have it cheap and easy in 5 years time.
I found the post very funny, but mostly agree with Ilia - a bad language is not such because of a humongous function collection or inconsistent parameter ordering. The online, user-commented php manual was php's gift to comp science, and by itself it solves the function naming problem.
A good language otoh makes the simple things trivial and the hard ones simple. And few things can beat php at that (and few other communities have produce such a boatload of really, really crappy code that is still good enough to run the web).
gaetano on May 21, 2008 7:16 AMI still enjoy PHP from time to time. It's almost universally installed on webservers and if you need to make a quick web app it takes second to throw one together. Last year, I rescued a mailing list for a bar owner/friend. We created a simple 10 line query to pull the entire list into a csv file. Import into Excel and some clean up and now he's got a useable mail merge for his office.
Over the years I backed away from PHP: 1) .NET developer jobs were paying 10K+ for equivalent positions. 2) I liked the cleanliness of having namespaces and real typed variables. 3) Until PHP5, OO felt like a loosely bolted on 5th wheel. It was there but few were using it correctly or at all.
I do believe there is less noise and better coders in the .NET camp. On the freelance level I was competing for cheapskate businesses who wanted good websites but paying scriptkiddy money.
My experience has been that someone that pays for a dedicated server, IDE, and SDK is heavily invested in their idea. Anyone can get a $10/mo server that does little more than PHP and MySQL and scoff at that idea that a good developer is going to cost $1000s
All programming languages suck. They just suck in different ways. The sensible programmer knows it's all about 'horses for courses' and uses what's appropriate for the task at hand.
Pascal and Ada are examples of a languages that were created to be philosophically pure. PHP and Perl are examples of languages that were originally created as duct tape to get jobs done. Oddly enough, the latter are more popular than the former, despite the objections of anal retentive purists.
Rather than bashing a language for its historical legacy, Jeff, how about you mention how you would make the best of things in PHP to produce a good PHP application. I'm sure that would benefit your readers immensely.
Pete on May 21, 2008 7:19 AM@mart:
I think you're missing the point. It isn't that PHP doesn't have support for those - it's that most PHP developers don't leverage them nearly to their fullest potential. In fact, the PHP library itself doesn't.
There is one big secret in software, which is known to everyone, who has some experience in the *reading* of code: the dominating majority of software is messy unmaintainable crap. There is another secret, which is known to ones who is used to read a lot: the code written with newest OOP concepts in mind is much more messy and unmantainable comparing with simple traditional procedural concept. It is so easy to replace one function call by another one. It is much harder to replace class hierarchies.
vtolkov on May 21, 2008 7:20 AMWOW JEFF!!!
I didn't take you as a microsoft apologist, but saying PHP Sucks is ignorant.... you can't have it both way naming some of the biggest sites currently on the net and arguing that they all are using terrible langs is outright offensive.
Seeing how facebook was written by a couple of people they would've picked the best language available for them to achieve results.... I'd hate to break it to you, but ASP is not a good solution, and I'd take PHP over ASP anyday....
EB on May 21, 2008 7:25 AMThe major advantage of PHP is that you never run into something you can't do. At least I haven't. And I do all kinds of crazy stuff. Websites, Intranet utilities, it talks to everything and with very little research it just works.
Rails? Ha! Waste of time. Only if you want to write nothing but blogs and demos (which most do). Sure it makes the designers happy, but I am not a designer. I want to do MORE.
Python is a fine alternative. I think it's practically the same language with different syntax.
But yes, it is inelegant. Very inelegant. And how elegant your code is—is totally irrelevant.
Jeff Davis on May 21, 2008 7:27 AMfunctions are not part of the language, if you don't like the functions name, it doesn't mean that the language is not good.
It's like complaining that C is a bad language because of the standard library, use your own functions, name them what you want.
I find PHP a great language.
As Bjarne Stroustrup once said "There are only two kinds of languages: the ones people complain about and the ones nobody uses."
Roger on May 21, 2008 7:29 AMPHP is simple and fast. In many ways, due to the awesome online reference, it's easier to figure out how to do complex things with PHP than with other more popular technologies like JSP/ASP. Also, due to the RAD design of technologies like ASP.Net (which I have done professionally since it was in beta), they are slow and clunky. Sure, if you avoid using postbacks and the control tree, you can reach the same performance levels PHP provides, but I rarely see that done. Because PHP writes directly to the response stream still like old ASP did, it encourages the old coding styles which in turn gives better performance. PHP's lack of packages/namespacing is indeed a problem, but the only way to get rid of that is to fork the project into PHPlus or something like that, and organize all of the functionality into logical groups, standardize naming conventions, and re-release it with a converter program that will convert old PHP to the new PHP. Without a converter, it would be doomed to fail.
Justin on May 21, 2008 7:30 AMDear Jeff,
PHP started as a language designed to add flexibility for serving HTML content on http calls. One http call = one run. This means for the complex web applications we are using now: you basically need to re-initialise the whole application on each call in one state, bring it to another state, output content and save the state, if necessary. This is inefficient. AJAX is only haf a relief because you need not to send the whole page anymore, just the bits that change.
For me, the problem is beyound: why do developers choose with PHP an application model for the system they want to create that does not support object caching and view-based state caching in an efficient way itself? For me, application development starts before: build an abstract software model and decide then, which kind of application model suits it best. And this is something you do not usually learn when learning to program.
So long - Tobias
Tobias on May 21, 2008 7:31 AMIf in any language one can write beautiful code (with that I agree 100%) I wonder what makes some laguages produce sphagetti and others lead to good code.. For instance PHP and Perl tend to be maintenance nightmare, while Java and Python source code is much more maintainable.
- is it low entry barrier? (Perl has high barrier to entry)
- or too fast learning curve? (python is quick to learn)
- or maybe standard libraries influence programmers (but Java had an old collections framework that was ugly but that didn't pollute programmers' minds worldwide)
What is the reason most successful frameworks like JUnit, Spring, Hibernate happen in Java world first before being ported to .NET, Ruby, Python, PHP? Is it that majority of experts and creative people do mainly Java? Or perhaps there is something in the language that stops developers from bad practices and enforces them to seek for better solutions? Or in problem space they deal with? Or perhaps in the platform, or in the ecosystem around given language? Or in books that people start learning the language from?
So, which of these you think contain core root of the problem?
There are a lot of upcoming new languages like Groovy, Scala etc, what should focus their creators on to minimalize the risk of them evolving to another maintenance nightmare? Perhaps it would be easaier to anser "opposite" question: how to design a bad language that will result in tons of mess?
The comments to this entry are closed.
|
|
Traffic Stats |