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!
It's worth pointing out that in addition to some of the other big names mentioned above, Yahoo! also standardized on PHP some years back, and, as far as I understand, many of their properties have been built using it.
Roger on May 21, 2008 7:33 AMThe unfortunate fact of the matter is is that PHP is that is virtually on every server in the world. Why? Because its really easy to deploy with no hassle. This means that PHP is not going away anytime soon.
While I agree PHP is ... crappy (to be nice :) ... it has its ups in that the time to market for php code is extremely fast. In the past couple of weeks, I've made quick apps that work just fine with PHP. I would never create a large scale app with it, but for quick and dirty things, it's pretty ideal.
Benny on May 21, 2008 7:33 AMThe unfortunate fact of the matter is is that PHP is that is virtually on every server in the world. Why? Because its really easy to deploy with no hassle. This means that PHP is not going away anytime soon.
While I agree PHP is ... crappy (to be nice :) ... it has its ups in that the time to market for php code is extremely fast. In the past couple of weeks, I've made quick apps that work just fine with PHP. I would never create a large scale app with it, but for quick and dirty things, it's pretty ideal.
Benny on May 21, 2008 7:34 AMThere are two egregious logical fallacies in your argument. First, by attempting to use facts to make a case for the languages goodness or badness, you commit a naturalistic fallacy. PHP doesn't suck because it allows you to write function names in three different ways. It does not suck because you consider it ungraceful. It does not suck because crappy coders use it. By the same token, it does not *rock* because its used by some of the biggest web properties.
Secondly and to a lesser extent, you've got a "post hoc ergo propter hoc" (after this, therefore because of this). Just because you used what some consider to be crappy languages in the past, does not validate what you are saying now about PHP. While I can understand and appreciate the effort to "commiserate," I fell it is expressed under false pretenses.
Plus, to be perfectly honest, we PHP developers don't need it. I find PHP to be a tremendously effective language, blending all the useful parts of C, C++, Java, and Perl (which also contributes to its hodgepodge nature) to tackle the monster that is the web. I have no trouble reading it, but then again I build on the platform professionally, full-time, and write in an excessively clean fashion.
The lack of concrete evidence to support your argument, and the overriding presence of pure opinion-based references, makes your argument look like nothing more than fanboy ranting. If you're interested, I'll have a post up on my own blog to counter your arguments pertaining to the language's utility later this week.
This is two posts now where I think you've gone off the rails, Jeff. I hope you won't make a habit of this. ;-)
Frank on May 21, 2008 7:34 AMWithout reading all the other comments, and as a long time PHPer, let me first agree that PHP is messy. The reason I got into PHP was the low entry barrier. It is not a disciplined language. It's very easy to get started and thus you can find a bunch of junk code and duct-tape solutions.
But in that same stroke, getting good at PHP actually requires discipline. I'm not claiming to be a PHP guru, but I've written many, many enterprise-level web apps that have stood the test of time and that have helped many, many people. I spent time studying "good" programming practices from other languages and did my best to apply them to PHP. And it worked pretty well.
PHP is powerful and can do a lot, but that doesn't distinguish it from other languages. In fact, nothing does - shy of it running some of the most popular sites on the internet. But again, I would suggest that choice was made due to the availability (and free-ness) of PHP. It's a very low overhead language.
But I suppose in the end, what's it matter? I know it sounds like a cop out excuse, but ASP, PHP, Java...they're all just tools. Thing is that if it were not for file extensions, we wouldn't know what any web site/app uses.
I've made a nice living working PHP magic. If you actually take PHP beyond downloading and installing pre-fab software, it's extremely handy. But since it doesn't force you to learn proper programming methods, you actually have to learn them and understand them. Something you might not get from IDE and languages that do it for you.
Morning Toast on May 21, 2008 7:35 AMJeff - I'm having a hard time agreeing with you. I have several reasons - but keep in mind that I have limited .NET experience (I've never taken the time to learn it/use it)
I agree that PHP feels like a hodgepodge of functions that have been pieced together. However....
A couple of years back, I was using the (choirs of voices in the background) all-powerful **Java** language to code a website. The use of beans was pretty cool and I enjoyed basically having the full power of Java at my fingertips. That was when a funny thing happened. I had to handle a file upload. OMG!!! JSP had no default means to handle a simple multipart/form-data submission. I had to build a whole crap-load of header-parsing nightmare just so my users could upload a stinkin' image. What a pain. Arrays? What a joke. An array could have an int as an index but not an Integer? (they are different, of course) - 1 is not the same as 1 in Java, I suppose.
So I learned to hate Java pretty quickly. I eventually wrote version 2 of the app in PHP. My file upload problem was solved with the global $_FILES collection without any extra coding. Arrays could be associative with the same array() function and I could sort and all that.
For some reason, PHP just *feels* like it was made for the web...and only for the web. Java and .NET are like hybrids that allow me to write a web app or a windows app with the same language.
I can use a screwdriver to put in a screw and the handle to pound in a nail; but shouldn't I just use a hammer for the nail?
/bad_metaphor
One point that struck me when I read this article was:
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.
Seeing how these successfully and *functional* these large projects have been, it's important to look higher than the language it was implemented in. When I see Wikipedia, I think of the immense contribution of data and knowledge, not the PHP scripts that power them.
On the other hand, for aspiring software engineers, it's more important to choose the cleanest and most maintainable approach to making the next useful app. Just because other successful projects have used PHP, doesn't mean that PHP is a good choice to build with. This also applies to whatever language is in vogue at the moment. A designer should choose a framework like Ruby on Rails for it's technical merits rather than the hype around it.
Jerry on May 21, 2008 7:39 AMPHP always reminded me a lot of classic ASP.net... not structured as well, but the way it worked and made a mess of spagetti code. ASP thankfully evolved into ASP.net, PHP is still PHP.
I've got to think it's wildly popular because it's really the best option you have for sites using Unix. You don't see very many Windows developers using PHP.
Let's at least agree that it's a step up from using Perl to create interactive websites.
Kris on May 21, 2008 7:42 AMI meant to say "PHP always reminded me a lot of classic ASP" in that comment... not sure why I tacked .Net onto the end of it. Oops.
Kris on May 21, 2008 7:43 AMI don't usually comment on your blog, but I read them every chance I get. Anyways, I code professionally in C# and VB.net, but I use PHP every chance I get for personal projects. Why? Because, PHP is streamlined for the web and has built-in functions for just about anything I can think of to make building a dynamic website easier.
I'm able to get a nice, cleanly written, fast and functional PHP built site in half the time that it takes me to do the same in C# and .NET. Combine PHP with Apache and MySQL and I haven't found anything I like better.
I don't think you can say the language sucks when so many of the best biggest sites on the web run on it. You can say the programmer sucks though. I look back at PHP code I wrote 5 years ago and its a mess, but today I follow a lot of structure to my code and feel that its just as managable as anything I've written in C#.
I have a Halo 3 Multiplayer stats website, http://halocharts.com, that is written in PHP that's getting over 3000 unique people a day and tracking over 50,000 players. It would have taken me months longer to write the same site in C# and SQL Server, plus all of the licensing fees would have been a pain...
firestream on May 21, 2008 7:44 AMI see PHP as a language that allows choice. I started with PHP out of necessity to get a job done. It was either PHP or ASP, and I was leaning toward ASP except I could find absolutely NO documentation on the net for ASP at the time, but more than enough for PHP.
PHP also let me choose my OS and my web server platform, which ASP did not. I'm a big proponent of choice.
You're right. I can code spaghetti code really quickly in PHP but I don't have to. The language let's me choose my programming style. I can (since PHP 5) go the object oriented route or complete procedural if I want. I can code sloppily or code extremely cleanly -- it depends on me. The function_list_that_goes_on_forever seems to be the same as the namespace.that.goes.on.forever, just a different convention.
It's choice. I'm grateful I have it to make. I choose to code responsibly and be wise in my coding convention, commenting and holding to an overall convention. If other people do not, then they've made that choice.
Danlb on May 21, 2008 7:49 AM
I think most people forget the Human Factor. The #1 reason IMHO that php is so popular is because it brings the productivity to the human side. In Java and other older languages, you have to learn one of the bazillions of frameworks out there and hope that the framework does what you want. When you remove that factor, the speed that a developer can code (without errors of course) is linearly proportional to the speed he gets new features out. You want more features, just have to type faster! Haha!
Developers feel better if they think that the bottleneck of productivity is on their side, ie, one only needs to transcribe mental ideas to code to create new stuff, instead of having to learn some new API in an unfamiliar framework just to produce a Hello World. The problem is, not everyone is brilliant and almost everyone creates bad code. The difference between php and say java is that some of the components of an app (db acess, controllers, etc) are already solved out in a reasonably way for you if you use some framework.
IMHO frameworks like rails or grails managed to balance the needs of most common web app aplications into the framework itself, so that the developer effectively gets things done with minimum effort.
As for the maintainability myth, my view is that maintanability is much more design/architecture related than language related. Code aArchitectures normally don't scale in the sense that adding new functionality becomes more and more harder, instead of being a constant value.
My .2 €
Miguel Ping on May 21, 2008 7:50 AMI tend to like programming languages that everybody else complains about, like C++, Perl, Javascript, Visual Basic, and PHP.
All of those languages can be ugly, all can have weaknesses, all have some bad design here and there.
But they all work, they all get the job done, and all are in widespread usage.
I agree with another poster, who put it very well - comparing these so called "ugly" languages to great cities like New York, Paris, and London. Those cities have dark underbellies, and rift-raft, and crime and poverty, and so on. But they're great cities that are homes to millions of people, and are visited by millions, and are exciting. Then the other poster compared more "pure" languages, like Java, C#, Python, etc, to works of art - very beautiful, but limited in usefulness.
Anyway, I love PHP. It's fun, easy, productive, flexible, powerful, efficient (for an interpreted language), and extremely useful. PHP, much like C++ and Perl, can be really ugly. But also like C++ and Perl, it's extremely useful.
To solve real world programming problems, I'll take utility over beauty any day.
Besides, PHP has scoreboard - Yahoo, Facebook, Tiobe, Wikipedia, YouTube, Word Press, Sugar CRM, and so on. A language that truly "sucks" simply can't produce great web apps like that. A language that is perhaps ugly, but useful, does.
JeffS on May 21, 2008 7:50 AMThe great thing about PHP is its freedom. Professionals can use it in a growing industry, as well as "script kiddies" can use it in their mom's basement.
The structure and maintainability of the code is largely dependent and determined by the skill of the programmer. The way it should be...?
I am personally tired of hearing Microsoft fanboys denounce the PHP language for flaws that it had in version 4. Maybe you haven't checked in sometime, but version 5 is now out in production.
"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."
Wow, ignorance is bliss. I don't think you are qualified to come up with statements like this when you say you are a Visual Basic programmer. I have programmed in Visual Basic before, and I thought I was losing intelligence throughout the entire experience. A Visual Basic programmer, is a lazy, ill-informed programmer. That's just my two cents anyway.
I could be partially biased however, because I work with a VB programmer, and he doesn't know how to "write" code. He copies C, C++, and C# scripts from the internet, and runs them through a X to VB converter. Obviously that makes some pretty (sarcasm) code. ;)
So your argument is, essentially, that PHP is OK, because all the cool kids are using it?
Jacques Chester on May 21, 2008 7:52 AMSaying "results are what matters" is like saying "we should kill our current set of politicians and lobbyists to deal with economic, oil shortage, food shortage and global warming problems."
And by the way, your sense of humor about PHP? It sucks.
And arriving to the conclusion that PHP sucks on the quality of code written by anonymous? It's hardly fair to a language that can be easily picked up by beginners.
What would be interesting to know is how well does an average person without programming experience picks up any language within a time constraint.
everling on May 21, 2008 7:55 AMWhy is a language bad? The worst crap I've seen many times was in the revered C++. Some of my best code in college was in Fortran, for crunching numbers. The Paradox Application Language (PAL) for DOS was completely logical and stylish.
Perhaps we judge a language based on the (pseudo) framework it's used in? I despise .NET Master pages and the mangling that occurs when the page is assembled and my viewstate is mis-placed. Case sensitive languages are retarded. Ruby is good but Merb is a better framework than Rails?
In the end it's what @monsur referred to as low "impedance mismatch", then it's the reliability, maintainability, etc., that the language offers.
100% agreed. I started with assembly, moved to C then C++, then to Perl and Java (per for quick CGI and Java for "real apps". I woudn't touch "Personal Home Page" for anything.
About 4 years ago I changed my mind, and for exactly one reason: every commercial hosting account you can get - from $1.99 / month up, supports PHP.
Nick on May 21, 2008 8:02 AMI think the whole argument here makes a very big mistake! It mixes language and API. So do most articles you quoted or linked to.
This is a big mistake most people usually do with Java.
int i = 10;
String s = "Hello World";
Object o = new Object();
float[] farray = new float[20];
This is *language*.
ArrayList ar = new ArrayList(20);
Iterator it = ar.iterator();
JPanel jp = new JPanel();
jp.getContentPane().add(new JLabel("Hello World"));
This is not! This is *API*.
PHP as a language is very clean, has very little elements. It defines a couple of data types, primitive operation on them (add, sub, mul, div, and, or, xor, etc.), it declares functions, it declares objects, arrays and hashes.
The huge amount of functions, with inconsistent namings and unexpected behaviors because two similar functions might have entirely different behavior, these are all API. They are the default API, that means they are there on a fresh PHP installation without installing any plugins; but they are not really part of the language itself.
I admit, while it is very clear what is language and what not for other languages like Java or Perl (because this is documented), the borders are pretty blurred for PHP. However, PHP is not the only language where the borders are so blurred. Another familiar one, and probably mostly used language in computer technology today, is C. E.g. this is langua in C:
char * buffer = calloc(sizof(char), 100);
But C does not guarantee int's to be 32 Bit, so programmers like to go there and do
u_int32_t num = 10;
or
uint32_t num = 10;
and when you want to open a socket (for network data transfer), they do:
int so = socket(AF_INET, SOCK_STREAM, 0);
However, this is all not language. No C compiler in the world needs to successfully compile that. u_int32_t is actually nothing at all (where the heck does this come from? Only because it's there on most system doesn't mean it has a right to exist). The only thing the C standard specifies is int32_t, that is signed, not unsigned. uint32_t is defined in the POSIX Standard, but not every platform that supports C needs to support POSIX (many don't support POSIX). And the socket function is also only defined in POSIX. Linux is mainly POSIX compatible, so is MacOS X, but Windows for example is far away from being POSIX compliant.
Long post, short summary:
It's not PHP that sucks here, it's the default API of PHP that sucks, because of all the negative issues quoted or reported on other pages.
I agree with Jon's comment above, about PHP being a "WOP" (Web-Oriented Programming) language. People often ask rhetorically "But *why* is PHP so popular for Web programming?". Clearly, it's not because PHP is elegant from a formal language design point of view.
Just take a look, for example, at O'Reilly's "Learning" series of books. Compare "Learning Perl" and "Learning Python" with "Learning PHP5" (I'm doing it now using their Safari service). The first two barely address Web programming at all (at least not explicitly on the contents pages) and are clearly general purpose programming/scripting languages spiritually at home on Unix and derivatives. The PHP book, on the other hand, has a few chapters on language basics, and then gets right into processing forms, connecting to databases, managing user session, processing XML and uploaded files, etc. It has appendices that include information about configuring IIS and Apache, and the book doesn't assume its audience is is using or deploying to Linux or BSD.
This difference of emphasis is played out across the publishing industry and online resources, it's reflected in the nature of the advocacy for the respective languages, and consequently I don't find it surprising at all that PHP is used so frequently for web programming.
My main gripes as a PHP dev: no console and no first-class functions. I do like, though, that *the* data structure in PHP is an ordered dictionary. If the array functions were namespaced, "import array" would be as cool as "import antigravity"; you get a queue, a stack, a dictionary, and a list in one.
Braden on May 21, 2008 8:08 AMJust because it's easy/possible to create spaghetti code doesn't mean you can't create efficient and maintainable php apps. My apps are object oriented, business logic is separated from the html, and I probably only use 5% of those 'a' functions.
sgb on May 21, 2008 8:08 AMFunny, I've written a PHP Sucks article myself (and got lambasted for it) but I've put together one site in PHP and am starting another one and yes PHP still sucks, but you can get a lot of work done in it. I debated Java vs Ruby for my new site for weeks and finally decided, I'm tired of debating with myself, just get it done in PHP.
codist on May 21, 2008 8:09 AMAt my very first ever job as a Professional Software Developer(tm), I had to maintain a PHP app. I sometimes have nightmares about it.
Grandy Peace on May 21, 2008 8:10 AMWhy is pascal getting popular again?
Goran on May 21, 2008 8:14 AMI'm not going to make dumb generalizations about everyone who writes code with PHP but it does seem that the way the language is designed really does encourage sloppy and procedural style code. I believe that better language design would help a lot with the quality and maintainablity of PHP projects that are available.
o.s. on May 21, 2008 8:14 AM@steve:
Some languages are bad because they limit, restrict or force your choices. Take the example of namespaces. In a language without namespaces, I have to find a way to avoid name collisions. In a language without closures, you can't pass code encapsulated in a closure. That forces you to solve the problems using a solution you consider not to be the best. This is where some design patterns might help you out, they are a cristallization of a solution for a problem on a unique domain (example being multimethods and the visitor pattern).
OTOH, the more power you have the more rope you have to hang yourself into.
Miguel Ping on May 21, 2008 8:20 AMThe only conclusion I can draw is that building a compelling application is far more important than choice of language
Pfft. PHP is good at what it does, and sucks at what it's not designed for.
It's like claiming PERL sucks (merely) because it has a very dense syntax, or because it is terrible at high performance computing.
PHP was designed to embed code inside of HTML pages, and it does it very well. tag tag tag... "Hello ?=$name? how are you today? I see you have ?=$wallet? dollars left in your wallet."
It's fine.
Bill on May 21, 2008 8:20 AMLanguages don't much matter. Programmers do. Garbage in, garbage out. A language doesn't magically transform your application into a work of art.
Bitter on May 21, 2008 8:21 AM@Mecki
That defense is old in the tooth. Who cares if it's the "language" or the "API" - we all know what Jeff is talking about. Even the pro-PHP comments here admit that there's something less than ideal in the PHPsphere.
Besides, can't the problems in the library potentially be attributed to the language? I mean, if you want to draw lines in the sand and make the argument about language vs library, PHP is a good language, but is it a great language? I mean, no closures, no pure OOP (maybe you consider that a benefit, i don't), no mixins (i have seen hackish implementations), namespaces, late static binding (coming soon), horrible scope resolution (you need $this- infront of everything..)
So even if you are right that we're all mixing library from language, it doesn't magically make all the problems of both the library and the language go away.
karl on May 21, 2008 8:22 AMPHP Bringing order to the madness: http://www.qcodo.com/
Javierfish on May 21, 2008 8:25 AMi think the great skill with languages like php (such as 'classic' asp) is to "program into the language" not just program in the language.
This is a Steve McConnell idea -- he harps on about it on every second page of Code Complete.
i've seen some very well structured, somewhat beautiful classic asp -- and it shows great discipline on the part of the developers.
lb
secretGeek on May 21, 2008 8:28 AMSince I was quoted in this post, I figured that I would make a contribution to the steady stream of comments.
In my opinion PHP sucks because:
a) Incredibly inconsistent naming
... 1) Mixing of underscored and non-underscored
... 2) Inconsistent abbreviations, e.g: using "i" or "case" to imply case-insensitivity
b) Somewhat inconsistent argument order
... array_map(func, arr) vs. array_walk(arr, func)
c) Expression de-referencing
... Meaning doing something like: "echo (array(1,2))[0];" will fail miserably. Except that it works for object references... IN SOME CASES, could it get any more inconsistent ?
d) No (proper) support for lambdas or closures
e) No support for namespaces, yes it's coming in 5.3/6 but it should've been there from the beginning - in maybe 3-4 years we will be able to use namespaces in production code.
f) Usage of array() instead of a simpler syntax such as [] or {} for creating arrays, which makes it incredibly ugly and hard to read when you need to nest several arrays
g) Usage of - instead of . as the object operator, this is actually more a convenience concern then aesthetic, writing - (at least on Swedish keyboard is a PITA)
h) Incredibly old fashioned object model, it got a worse feature set then Java had back in -96. They've tried to launch PHP as an "OO"-scripting language, right.
i) A lot of functions that mostly do the same thing, takes the TIMTOWTDI to a whole new level.
There are a couple of more issues for me personally, but these are the nine main ones. And all the issues with the "hobby" community, etc.
So yeah, PHP sucks. However I still use it because it puts food on my table and pays my bills.
Fredrik Holmstrm on May 21, 2008 8:31 AMThis same argument was once used for COBOL. PHP will eventually be replaced as COBOL was. Sad thing is, it will take very long. Even today COBOL struggles on some reincarnations.
jm on May 21, 2008 8:36 AMIsn't the classic "but you write PHP that doesn't suck" example Drupal? It usually comes up in these kinds of discussion anyway.
hpr122i on May 21, 2008 8:36 AMIt's patently clear very few people posting comments here (or Jeff) has used PHP any time recently. There's no other explanation for the foolish and incorrect things stated here.
I used PHP in 2001. It was slapdash. Using it as a comparison is called a "straw man." Boo.
I use PHP in 2008. It's got everything you need to build stable, well-designed, scalable apps. Period.
The *only* legitimate complaint I have ever seen about the language itself is lack of namespacing. Welcome to PHP6.
There's nothing wrong with the language.
People who use it poorly have themselves to blame.
Kyle Hale on May 21, 2008 8:36 AMAs someone who codes VB6 and PHP pretty much exclusively (though I have gone on to VB.NET, 'cuz it was free and all), I just want to say that my goals are never to be elegant. My goals are to be quick. I am an experimenter, a tinkerer. I am not a computer scientist by training. I am a historian who can code a bit.
Having languages like VB and PHP allows someone like me -- who doesn't want to do memory management or worry about callbacks and etc. -- to quickly throw together things that other people won't. Can I beat the computer scientists when it comes to writing efficient code? No way. Can I beat them when it comes to writing code I can use? That's the whole point.
So what's my point, in the end? The people who bash PHP aren't taking into account the crucial social aspect of it. Why does it matter that Wikipedia and Wordpress are written in PHP? Because practically anybody can work on them. In a land where processor time is cheap, the ability to quickly modify an existing program is king.
I write my own database interfaces in PHP because the off-the-shelf programs for historians, like EndNote, suck a big one, in my opinion. They aren't set up for me and they can't be customized to my needs easily -- something that's a big problem in the humanities, because my work doesn't fit into nice little boxes each time. Each project has its own needs and considerations. A well-structured program is, well, a little too well-structured. Something made out of PHP can be mashed about, changed, new things added quickly, etc., on the fly. And it works.
Should an entire OS be made out of languages like this? Should critical programs be made out of languages like this? No way. Should programs that place a high, high priority on being easy to edit by people without CS degrees be made out of languages like this? Yes. And _of course_ that's going to bug people with CS degrees -- PHP makes those of us without them think we can nudge you out of the picture. ;-)
Shmork on May 21, 2008 8:36 AMPHP is successful for exactly the same reason VB was successful: they both made a simple thing very simple while no-one else cared.
Unfortunately both sucked in every other possible aspect, thus repelling most good programmers and attracting hordes of bad/amateur programmers, building a huge environment of crappy coding standards.
And unfortunately PHP still has a big selling point: want to do a web app that you can install everywhere? Do it in PHP.
And so we are stuck with PHP for a long time.
Also, it is true that a bad programmer can write bad programs in every language, but the reverse is not true.
- If you don't have namespaces you are stuck with adding 'whatever_' in front of all your functions,
- if the language doesn't have a consistent naming convention you can pick one, but you will still live in the mess
- if (for example) you don't have function pointers or first class functions you are stuck with doing the big 'switch' statements
...
You can make bad code with anything.
And the converse is also true: you can make GOOD apps with anything -- that's the point of this post.
Jeff Atwood on May 21, 2008 8:38 AMHaving used PHP 4 for some years on my own site, and PHP 5 to make a website for a small company, I'd say there are lots of reasons why PHP is a good idea:
- The "User contributed notes" are actually useful and usable.
- There's no "architecture astronaut" tendencies - The simple option is usually the default, while more advanced functionality is available with more parameters or other functions.
- The web pages are better than for .NET - Faster, much tighter hierarchy, no JS bugs to break the whole site in Firefox.
- It's platform independent, open source and Just Works.
In short, it's built by developers (so it's messy) and for developers (so it actually works).
Victor on May 21, 2008 8:40 AM"SQL wrapped in spaghetti PHP wrapped in spaghetti HTML", you got it in one. The whole thing is a mess...
kcg on May 21, 2008 8:41 AMEverthing suck, Windows, Linux, UNIX, BSD, Mac OS all suck. Operating systems suck. Languages suck. With that in mind you are left to question yourself, what does suck less for my purpose?
Hoffmann on May 21, 2008 8:46 AMso I should learn PHP now ? :)
For me the syntax is just as important as the framework and for me the php syntax was never somthing I felt comftable with. But again alot has happened.
Peter Palludan on May 21, 2008 8:50 AM"As someone who codes VB6 and PHP pretty much exclusively (though I have gone on to VB.NET, 'cuz it was free and all), I just want to say that my goals are never to be elegant. My goals are to be quick."
Someday you'll have to maintain some code written by someone with the same goal.
Charles on May 21, 2008 8:53 AMAnother one for the list... Flickr is also developed using PHP.
As other commenters have mentioned, PHP is vastly available - almost all shared web-hosting supports it! Which is why a lot of open-source apps are developed in PHP, (quick-n-easy deployment).
I think a root cause of poor PHP coding practices comes from the lack of an established IDE. (I know of Eclipse, but never used it). Could you imagine developing C# without Visual Studio?! (No thanks, I want my IntelliSense!)
A good IDE goes a long way towards guiding coding practices for would-be spaghetti developers.
Lee Kelleher on May 21, 2008 8:57 AMI love these discussions.
First off, I'll agree with the Jeff here. I'm not going to stand here and say that PHP doesn't have it's drawbacks and it's flaws. But it is successful for one MAJOR reason, it WORKS and works easily.
Hey, I can be a very disgusting coder if I really want to be. No matter the language I can spew out some very nasty code. So I'm really fed up of people blaming the language for their crappy code.
Because PHP is so light weight, it makes it easy to get stuff out the door with less of the safety measures that would be required in other languages because the thing compiles. That's why you have people sticking an entire application in one index.php file that works off of URL parameters.
Also, people need to realize that ASP.NET is a FRAMEWORK and not solely a language people. PHP is only a language. Frameworks such as CakePHP are now evening out the playing field a bit.
Now, I can't help but comment on this dude (cdbaby.com?) that scrapped 2 years of Rails to "code it properly" in PHP. I don't even know where to comment on that. Anything can be coded in any language, but it escapes me how a Framework like Rails didn't seem to satisfy his needs.
3 years ago if you'd ask me what I'd use to start a web application, I would have said ASP.NET. Because that's all I knew that had a high enough level to take me away from all the grit work. But that's because I didn't know about things like Rails and CakePHP. Right now, CakePHP is at the top of my list. It gives me the high level I want in a framework (really, at this stage I don't need to be messing around with pretty URLS and crap like that. Also, unless it's real complex and need to be hand written to be efficient, I'd rather stay away from SQL. Not because I'm scared of it, but because 'select blah, blah from blah' get's old after the 5th time) and the get up and go that PHP allows.
I'm sorry, I agree 100%, PHP may suck, but who cares? It works! It's much like what I've said before:
a href="http://www.webdevelopment2.com/choice-web-development-framework-matter/"http://www.webdevelopment2.com/choice-web-development-framework-matter//a
"If you have an idea, PHP gives you a quick and dirty 1.0 (a la 37signals) implementation for cheap."
Um, well not really at least if you consider that 37signals stuff is all written in ruby on rails ;-P
Bunglemeister on May 21, 2008 9:00 AMPHP might not be as elegant as Python but it's a still a very good language to get 'something' done. I think it's the quality of programmers/developers who apply a language to solving problems effectively that makes a difference. Any fool can write bad code in Ruby or Python as much as PHP. But nobody will disagree that PHP isn't the most well designed language or has a well thought of library.
With all that said I don't think the PHP development community should rush into patching PHP up to look/feel like Python or Ruby. Let PHP progress in it's own path - you can never have too many alternative tools to solving problems.
Rohit on May 21, 2008 9:03 AMJeff, have you read how the TIOBE index is compiled?
From their site:
"The ratings are calculated by counting hits of the most popular search engines"
That is NOT the same as counting the number of sites built in a language. Nor is it an indication of the number of developers working in a particular language. After all, Java coders might need to do more google queries than C# coders...
Never mind the fact that PL/SQL, MySQL (not rated), and Transact-SQL queries make up less than 0.71% of the total. Using your logic, the implication is that less than 1 out of 100 programmers use a database backend...
Further, going from "Some of the largest sites..." to "...powering so much of the internet" takes a bit of mental gymnastics.
Chris Lively on May 21, 2008 9:06 AMAfter years of avoiding php, because of all the ugly examples I had seen, it quickly became my favorite web language. Apart from the dollar signs, it works well with how I think. All my php code is short, clear, and fast. Almost all the things I had to write from scratch before are built into the language.
http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html
David on May 21, 2008 9:07 AMAs one who has been working with PHP since the mid-90s, I can say with absolute certainty that my comfort level with the huge array of built-in functionality, as well as my memory of needle/haystack mixups throughout are both quite high. I can work quickly and elegantly.
The ego I am reading here in the comments is not surprising to me. An awful lot of people complaining about PHP circa 2001, and not looking at all to the future of this dynamic, useful, broad-reaching language.
But if you want to keep bashing it because it's not branded with a giant corporate logo, or doesn't come with its own IDE, or has no built in make_website_work() functions, fine.
Stephen on May 21, 2008 9:09 AMI agree completely.
Programming skill is the important thing in php. You can build ur program completely scalably with code reuse etc, or you can build a nice bowl of spaghetti. I've written some php and using simple OO patterns you can have very elegant looking code ... or not.
mordy on May 21, 2008 9:12 AM"SQL wrapped in spaghetti PHP wrapped in spaghetti HTML" - That means that you suck, not the language. And does this also mean that HTML and SQL arent any good?
This is obviously just an emotionally charged rant. Its also missing information - You seem to have no idea that there are MVC frameworks for PHP. And speaking of that, your article a while back on MVC sucked too. Oh well
PHP is everywhere
PHP is free
PHP is fast
PHP is feature rich
PHP is well supported
PHP has an excellent user base
PHP has many community developed tools
PHP is well documented with an excellent online manual
PHP isnt Microsoft ( because monopolies are bad competition is good )
And no, my friend, PHP doesnt suck, but unfortunately many of its users do, as with anything thats popular.
Ben on May 21, 2008 9:18 AMYou may be missing the problem-space php is meant to address. That list of keywords isn't long, by any comparison. The function list is long, unless you think of the underscore as a namespace scope character, then it just feels like a normal library. Do you want to compare the list of php functions to the list of .NET methods? php is common because it doesn't generally screw around with overengineered object models, instead it tends to use handles. It's small and fast. It scales.
Because of this C sensibility that eschews much of the overwrought object casting, reflection, narrow-casting, boxing and unboxing, factory patterns, c., it fits on thin middle (presentation) tiers.
I have to say, after the whiny, amateurish article about XML and the whiny, amateurish article on php, this site no longer holds any value for me. I haven't seen any aggressive stances on real problems for months. I'm outta here.
Brianary on May 21, 2008 9:21 AMPython philosophy is about having a concise powerfull language, philosophy which has proven to be a good choice (As explained in code complete).
I still prefer PHP though it is a mess (non consistent function naming, useless once in a lifetime function proned to be unsufficiently eyeballed/tested).
Why do I prefer php ? Easy to use and powerful, with a low and high level control. 'Rail' like framework (Cake/symfony) are even being ported on PHP. So what is the problem with PHP ?
As a sysadmin however I am really scared of PHP because its community is flaming hardened PHP project though security is a major issue in php not only because of the language in itself but also because of bad habits among developpers PHP.
(interview of stephen esser on php security that is quite uneasing)
http://www.securityfocus.com/columnists/432/2
And as for any open source project, I do think the project has the value of its community, and its community in my opinions are a bunch of careless freaks that just stack up functionnalities without regards for the core of the language, especially security.
I know the claim of php6 on security, but the simple presence of the mail() function is unbelievable. Using this function is like asking to be spanked naked on the web.
I am still an happy php user but not very confident in its future.
Jeff, you really really need to learn the difference between a language and an API.
Meanwhile, a language which sucks so bad and has no financial backing still comes out with a higher market share than the language you defend so often and has the world's richest company peddling it... doesn't it just get to you?
Oh, it does. But it shows only a little.
I will agree that certain aspects of PHP suck, for instance having to use functions on arrays instead of seeing them as objects and using the array-function way of doing it.
But PHP fulfills it's purpose brilliantly. It's designed for the web, and I haven't found another web-based programming language that makes it as easy as PHP does. What requires one line in PHP can take at 6 to 10 lines and objects in say, Python (I know Python is used for things other than the web, but still).
For what it is designed for it works great.
Some complain about the $ and - notation, but this just gives personality to the language.
Others have complained that there are so many different configuration possiblities, like magic quotes or register_globals, but any experienced PHP programmer knows how to either disable these, or completely code around them.
And Jeff, you've complained about the sheer number of functions in PHP. Now I'll agree that they could use namespacing, but that doesn't matter really. PHP's manual is the best and most comprehensive manual for any programming language I've ever seen, and you can quickly find a function and its parameters based on what you want. You cannot honestly tell me you jsut look at one giant alphabetic list of functions to try and find the one you want. If you are, then you are effectively nullifying your argument, as the developers have given you a great resource and you are just ignoring it.
And on the subject of script kiddies, I'll concede that there are far too many out there, and the code they write is atrocious. But the beauty of PHP is that it is simple enough for that to happen, but still incredibly powerful and powerful enough for experienced programmers to write clean, ordered and well-written code that goes like the clappers.
I think you're just nitpicking really, and PHP is a great tool to anyone who knows how to use it properly, despite some of it's flaws.
Matt Wilkinson on May 21, 2008 9:22 AMSeriously, what's up with the stats on the TIOBE page?
According to the "Delta in position" column, PASCAL, COBOL and LUA (whatever the heck that is) are GROWING STRONGLY.
Meanwhile, C++ and JavaScript seem to be dropping in popularity.
How can that possibly make sense?
Rofa on May 21, 2008 9:23 AMPHP itself isn't that bad really, the problem is that it easly allows people to write big ball of mud applications. However, you are always free to write good structured and clear applications. So the problem comes probably not from the language itself, but from the people, who use it.
That's probably why everybody always says PHP doesn't have OO. Yeah, it does! Just because people don't use, doesn't mean it's not there. I think it's very well possible to write good PHP application, just as long as they don't get too big, because web-scaling is a whole other issue.
Funny thing is, when someone ask around office, if there a PHP function to do task X, the answer is usally:
"PHP has a function for EVERYTHING!"
And it's true! Wether or not that's good, i don't now.
greg on May 21, 2008 9:28 AMI've written about 200k lines of php in the last year. I've also written a huge amount of VB.NET and C# too. I find that the largest difference is that php will let you do what you want to, ugly or clean, whereas the others tend to guide you toward cleaner code. You can be clean with php, you're just not going to learn it from online tutorial sites. OO only really came with PHP5, so most of the stuff out there - even though 5 has been out awhile now - hasn't really been moved over. The frameworks are nice, and can really help, but often times it feels like you're just bring out a bigger sledge hammer.
Chris on May 21, 2008 9:35 AM-------------------------------------------------------------------
Seriously, what's up with the stats on the TIOBE page?
According to the "Delta in position" column, PASCAL, COBOL and LUA (whatever the heck that is) are GROWING STRONGLY.
Meanwhile, C++ and JavaScript seem to be dropping in popularity.
How can that possibly make sense?
Rofa on May 21, 2008 08:23 AM
-------------------------------------------------------------------
I've heard COBOL is still used by the majority of banking systems and LUA is an upcoming scripting language used a lot in Games today (for example World of Warcraft and Civilisation 4).
greg on May 21, 2008 9:36 AM"And does this also mean that HTML and SQL arent any good?"
Actually... it does! SQL is a curse for computer science, huge legacy of bad choices both from the semantic and the syntactic point of view. It would take me too many words to explain why SQL is a bad programming language.
HTML took forever to decide if it was a language to describe the structure of a document or its aspect, it's full of legacy tags that nobody uses nor knows what they were for. Add CSS and JS to the mix and you get something that nobody fully implements, nor understands.
E[X] on May 21, 2008 9:37 AMSmells like a troll.
"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."
So the guys that coded all the popular websites you mentionned don't have an ounce of programming talent ?
You can make bad code with anything.
manu on May 21, 2008 9:40 AMIt lets people actually get the job done and for those who pay the bills that's what matters. While I like the concept of logical syntax and clean code, working code is what most other people expect. PHP seems to produce results for a lot of people.
Larry on May 21, 2008 9:40 AM"What 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."
Huh? What? Did you not notice the lengthy blog post above the comments section? You might go and read some of the links. Choosing PHP over something else is a choice between money and time. What do you want to spend more of? You must pick one.
Yes, trivial PHP apps can be set up faster than trivial apps in other languages, but trivial apps don't really mean squat in the real world. I would rather spend two weeks setting up a good environment like ASP.Net, than spend any time debugging a complex PHP application.
Good developers have a 'spider sense' for bad code - I can tell bad code from 20 feet away, without even seeing the actual characters. I can sometimes tell bad code without seeing it at all, just by how the app behaves. PHP code is almost always bad code - meaning it's unstructured, unsafe, incoherent, littered with dependencies, and hard to read. Sure, it's possible to write good code with PHP, but the properties of the language itself and its community more often result in code that reminds me of "made-up-of-different-stuff-guy" from the Pepsi commercials.
Jasmine on May 21, 2008 9:43 AM@karl:
Well, it matters in that aspect, that I can take the freely available source code of PHP, strip away all of it's default API and ship exactly the same language (same syntax, same abilities) with a completely different default library of my own.
Maybe there even exist alternative libraries for PHP already. Perl has plenty of them. Perl has many build-in functions, but also many that are not. If you want to get webpages (HTTP requests) or send e-mails, you don't use anything from the stardard Perl lib, but you install a custom plugin from CPAN. And here for one and the same task, three different plugins could exist. And if one sucks, why not taking the other one?
I just remember this way too well in Java forums. First people came there and said *Java* sucks, because with AWT you can't create usable user interfaces. AWT is just part of the default lib, it is not Java. Then Sun released Swing, which could everything AWT was lacking - and people said Java sucks, because Swing does not look truly native and it's way slower than AWT. However, IBM has SWT, which is as fast as AWT, needs much less resoures than Swing, still can do almost everything that Swing can do and it looks as native as possible on every platform supported. So, when you use this, does Java then still suck? No... but wait, it's still the same language, isn't it? So it actually never sucked. It was the AWT and then Swing API that annoyed people, not the language per se.
Of course you do have some valid points about the language itself in your post.
no closures,
Like many other languages - I don't see this critical.
no pure OOP
Since when needs a language to be pure OOP to be good? Many are not even OOP at all and many are OOP, but don't force OOP down your throat. I see no problem with that.
no mixins
See above, I see no problem in that. Since when must languages have that? Actually the wast majority of languages don't have that. And I don't think it is good either. It leads to very dirty code and confusion.
namespaces
Yes, that is indeed bad. Namespaces are important. But C has no namespaces either, not even Objective-C on Mac has it (and it's full OO Support to C in a much cleaner way than C++ does). And in many languages that actually have it, people don't use it anyway.
horrible scope resolution (you need $this- infront of everything..)
Just like you need "self" in front for Objective-C code. Okay, you wouldn't need it to access instance variables of the current object, but I think you can use it there as well and it has the advantage that you see it is an instance variable (not one in the current method scope) and also makes sure the instance variable is used, even if there is a variable of the same name in the current scope.
So these are all no killer arguments to call PHP a bad language. All valid, but not killer.
Mecki on May 21, 2008 9:49 AMYour main points for calling PHP a bad language choice is its function list and sample code written by others... I am a PHP programmer for my job and by choice on my freelance web projects. I also write in C# but for windows applications only because lets face it ASP and ASP.NET are the slowest choices for web langauges on the net. PHP is fast and easy, like lots of individuals have stated before myself. It is lightweight and with the use of Zend Studio easy to debug.
One might not call the developers on the PHP project of genius stature but one thing you can give them is the rapid pace at bug fixes. I do agree their function naming conventions could use some work, but one can always write useful wrapper classes that use those functions and have your naming conventions.
As you have said before in a previous blog "your code sucks", and the same is true for PHP code and coders. Most coders do not use good naming conventions and best practices so their code is hard to read and modify. The last time I looked PHP was the most widely used langauge on the web, so you are going to run into more bad code than the others for web projects.
At the end of the day one needs to use the technologies they know and are comfortable working with. So to me instead of throwing it out with not ever really using it, or developing with it on your own I challenge you to do so. That is how I found that I do not like coding in Ruby or even the .net framework for the web not by analyzing from the outside looking in and just saying they are bad languages for the web.
Matt on May 21, 2008 9:58 AM"And does this also mean that HTML and SQL arent any good?"
Actually... it does! SQL is a curse for computer science, huge
legacy of bad choices both from the semantic and the syntactic
point of view. It would take me too many words to explain why SQL
is a bad programming language.
The point of that was to show how the logic is flawed, not that SQL or HTML actually suck. Anyway, SQL is not a programming language. Its designed for getting data out of tables.
"...Add CSS and JS to the mix and you get something that
nobody fully implements, nor understands."
I think the guy above said it best... everything suck - And at all times. This the human problem we're facing here, a language problem, which is sliding down the heap from VB to PHP, and now to English
This article should be deleted
Ben on May 21, 2008 9:58 AMyoutube *is 100% python*:
http://highscalability.com/youtube-architecture
Wow,
Fun little article with alot of titty tatty comments underneath...
So let me indulge:
1. To all the ASP is better because there are more professionals involved people:
Just stop right there. I can show BILLIONS of examples where I work and other places of applications written in .Net something and the code is simply unmaintainable. Don't even get me started on compiled DLL's and binary signatured project files... Remember MS is the company that made Ctrl-Alt-Del famous because their OS locked up too much.
If PHP is bad because of all the "ScriptKids" then ASP is bad because of all the "I just read ASP for Dummies and I love drag and drop" n00bs!
2. For all the PHP nay sayers because its hard to keep PHP clean:
Just stop right there again. Most php books/references will tell you to use notepad simply because they expect you to be a stupid moron who doesn't know how to torrent Dreamweaver or install Notepad++. Use a real editor, put down the PHP for dummies book, goto to university, learn how to program, learn what it means to "include" something, learn OO programming, rewrite your application, then gives us your 2 cents... maybe we'll listen.
3. FFS use SVN when doing a project, its not hard to setup and will help you 53,757 times.
4. There are just too many "Oh I read dummies books, please let me be a web developer" people out there. Learn how to program from a college first before you go spewing forth ASP spaghetti on the rest of us.
5. Web Development is not PowerPoint, stop trying pretend like it is.
Rob on May 21, 2008 10:01 AMI love it when people use the infamous array function list as an example of PHP suckage. Sure that's a huge list, but PHP has better array support than any other language I've ever used. You're just jealous.
The list can get a bit confusing at times, but that's why PHP has the best online documentation in existence. Don't know what a function does or need a refresher? http://php.net/functionname.
The few posts above which dared to argue that PHP doesn't scale are horribly mistaken. First, the front end tier is rarely the source of scaling issues. Second, opcode caching systems such as APC and Zend Platform work remarkably well. Finally, Apache is a huge memory hog and that is often mistaken for a problem with PHP itself. Luckily, PHP runs on lighttpd and many other lightweight web servers.
Last but not least, arguing that "low barrier to entry" is a bad thing sure sounds elitist. You can get a closer shave with a straight edge razor, but do people still use them? No, because in the age of throwaway safety razors they're impractical.
Gil on May 21, 2008 10:04 AMSimpleTest[1] is a unit testing framework for PHP. It's growing in popularity in the PHP world, and at least one popular PHP project (Drupal) has adopted it broadly for both core development and many contributed modules.
Sam C on May 21, 2008 10:05 AM"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."
Actually, 1 3 are the same thing as PHP isn't case sensitive when it comes to function names, it is in other aspects tho, making it suck even more.
krs on May 21, 2008 10:07 AM-----
I've heard COBOL is still used by the majority of banking systems and LUA is an upcoming scripting language used a lot in Games today (for example World of Warcraft and Civilisation 4).
-----
Yes COBOL is still used far too much ...
Lua is a scripting language that is designed to be embedded in other systems, e.g. Games but it is also used as a Web Scripting language, and even a webserver! ... the core is a very simple language (with all the things people say are missing from PHP) that is designed to be extended by libraries and the host system
Dear Jeff,
I have been an ardent reader of your blog. I have always enjoyed reading you arguing against the common notions of programming, I did believe you are truly a pragmatic programmer as you believed in getting the job done and not care too much about some of the academically approved approaches to solve a problem, something that purists rant much about. But I must say I am extremely disappointed with your disapproval of PHP as a programming language. If you are a truly rational thinker, why cant you justify using a language thats so much more productive in the web environment than any other options we have.
I am quoting from a presentation by rasmus, this is how you parse an Atom data in php
$url = 'http://www.flickr.com/services/feeds/photos_public.gne';
foreach(simplexml_load_file($url)-entry as $it) echo $it-content;
Now why would anyone not use it if it has this kind of power ? Since when you have become a language purist, who hates to see functions named rather inconsistently ? After all you are the one who has said that a href="http://www.codinghorror.com/blog/archives/001062.html" code is not beautiful /a, remember ? , you are the one who said (commenting on joel spolsky inventing a new language for his product) that a href="http://www.codinghorror.com/blog/archives/001022.html"the language does not matter /a.
I thought all you cared about is user experience, and for a language that is designed to work optimally in web environment, if its going to make you super-productive, how is it not good for the end-users ?
Why do you care about how the code looks like ? why do you blame the language for the bad code that not so careful programmers produce ?
I do believe, the reason you are seeing bad php code all over, is due to the fact that php is such an easy language to learn that anyone who might not have any programming experience can jump in and write some code over a weekend.
Are you looking for a language that PREVENTS bad programmers to output bad code ? do you really believe any such language exists ? don't you think that design/architecture of you application is more significant than the syntax of the language you used to code ?
Come on.. give me a rational (and honest) answer, will you ?
The problem with PHP is that almost everyone and anyone can write functions for PHP. For example, there are FIVE functions you can use to replace a substring in a string:
* str_replace
* str_ireplace
* ereg_replace
* eregi_replace
* preg_replace
Notice str_replace and str_ireplace vs. ereg_replace vs. ereg_ireplace.
I hate PHP and it drives me crazy because I can never remember exactly how to do everything.
PHP's saving grace is its ability to be incorporated into HTML. That means you can quickly create a web-based application. Plus, since it is executed on the server site, you don't have to worry, like you do in JavaScript, whether the user's browser will be able to execute your code.
I may hate PHP, but it's what I use when I do my work.
David W. on May 21, 2008 10:12 AMWhat I find interesting is how infrequently people talk about the maintainability of PHP. I absolutely agree it's a great language to slap out version 1.0 of your site, as long as you have a really small team and not to complex website.
But once you grow, adding features and developers, the big productivity gains you had quickly disappear. After about a dozen people are working on a PHP app it generally starts to falter in terms of maintainability. Never mind 2-3 versions of features.
Initial productivity is great and speed to market is great. But it's not everything. When I start a business I expect to last at least several years, so I prepare for that. Sure initially I might have to absorb a little bit more cost, but in the long run it will pay off in spades. If you think speed to market is the end all be all, you might want to watch DHH's video at: http://www.justin.tv/hackertv/97862/DHH_Talk__Startup_School_2008
One last note, the fact that the language hampers the ability to create functions due to namespacing issues, this tells a lot. Especially as the source and team grows, it really hampers keeping the code clean...
Stephane Grenier on May 21, 2008 10:15 AMJeff,
honestly, PHP/VB doesn'tmatterism aside, are you driving mindless traffic to your site with these somewhat outrageous posts (screen touching, then error page with clouds and now PHP)? This site is turning (slowly) to Oprah Magazine of coding-related blogs.
Yes, language design is hard. So is programming. But that does not imply that beautifully designed languages are good for the job. VB is an example of a language that should have never left Redmond labs. I wonder how many developers out there have suffered direct and indirect indignation because of the "cloud of doom" called VB, the rapid dev. environment which broke all rules of OOP, OOD and language design and shed serious doubt to many a developer's ability to think in OO terms (whether that doubt was justified or not is another matter).
Bottom line: if you don't like the language (and I also do not fancy PHP), just friggin move on. Power up a C++ compiler, do whatever you have to do. Program in assembler for a while, you will learn to appreciate programming as an art much more after that.
Best,
BugFree
BugFree on May 21, 2008 10:17 AMOn the subject: a href="http://www.mysqlperformanceblog.com/2008/05/20/apache-php-mysql-and-runaway-scripts/"http://www.mysqlperformanceblog.com/2008/05/20/apache-php-mysql-and-runaway-scripts//a
(Summation; certain runaway PHP scripts will NEVER be killed, and there is no obvious graceful way to avoid this. FastCGI would work, I suppose, but neither PHP nor Apache are actually very FastCGI friendly)
Robert Synnott on May 21, 2008 10:18 AMPeople use PHP for the same reason they use Linux; because they are masochists. Why do something simple like run a tiny install program when you can recompile the OS?
Mitur Binesderty on May 21, 2008 10:20 AM"Anyway, SQL is not a programming language. Its designed for getting data out of tables."
That depends on how you define 'programming language'.
"I think the guy above said it best... everything suck - And at all times."
Not true, there are things that most definetly suck less than PHP in many aspects.
@ Mecki:
no closures,
Like many other languages
no pure OOP
Since when needs a language to be pure OOP to be good?
no mixins
See above, I see no problem in that.
So PHP can't do good OOP, can't do good Functional Programing and (obviously) can't do good Logic Programming. Wonderful.
namespaces
Yes, that is indeed bad. Namespaces are important. But C has no namespaces either,
So, we should uniform to a language designed 40 years ago? At least C can be excused because it runs fast.
And in many languages that actually have it, people don't use it anyway.
That's not true. If you have them then most libraries use it, user code maybe doesn't, but you can write bad code even with good languages.
This blog is giving me strange error pages.
E[X] on May 21, 2008 10:21 AMThe list of function beginning with an 'A' does not convince me that PHP sucks. Most functions are equivalents of C library functions and the syntax itself is similar to C.
What suck(ed) about PHP were attempts to ease things for programmers:
o using values from GET and POST an
o quoting variables to avoid trouble when building SQL statements by
adding strings
But luckely this nonsense can be switched off and with the addition of the PDO library in PHP5, SQL handling has become sane.
But the reason why most sites use PHP is that the most webspace providers offer PHP. (Yeah you can upload Linux binaries to sites like Godaddy but because they don't support .cgi files, you have to wrap 'em with PHP.)
Mark-Andr Hopf on May 21, 2008 10:21 AMWhat's wrong with FORTRAN? It's just BASIC from 1960.
Miles Archer on May 21, 2008 10:27 AMI used to really enjoy visiting your site for some interesting articles but since you picked up on the idea of just being dramatic to draw more visitors (like the wordpress article and then this one) I am starting to question your general attitude.
First of all, the list of functions you posted above is not the native list - you included a whole bunch of items from external modules like the APC and APD ones. Remove those and the list is half the size.
Secondly, PHP evolved over nearly a decade and had to increase functionality while maintaining backwards compatibility. It's easy to look at something with a decade of hindsight and say "oh this could have been simplier/cleaner" (same thing goes for WordPress btw)
PHP is about getting things done and allows even novice programmers to be incredibly productive in a very short amount of time. If someone knows just a little javascript, they can easily code in PHP very quickly.
Leave coding elitism in the labs. I've got bills to pay and things to get done. PHP has been wonderful.
I like PHP because it is very similar to C, which is the greatest language in the whole universe. Now, you are saying that PHP is not good because its language design sucks and you are entitled to your opinion, without ever using C, PHP or UNIX. Still, you are entitled to your opinion. However, i consider you as an inexperienced douche bag that loves BASIC, .NET, everything that has the brand of M$ on it and nothing else.
PHP suports O.O. but not a lot of people choose to use it. I guess after all O.O. is not the "Holy Grial" of programming. You forgot to mention that PHP is an extensible language and you can use multiple frameworks or maybe you just didn't know that.
Anyhow, isn't it good talking shit about things you don't know about?
This kinda harkens me back to a previous post of yours (Nobody cares what your code looks like), it doesn't matter whether the code is ugly or if it's damned beast, all that matters is that it does the work it's supposed to.
This is supposing PHP is a bad language to begin with, but to my rather minimal knowledge, when you say a language is bad, it means that it doesn't do what you need it to (obviously not the case here), true, you may have quite a few nights of hair pulling over messy code, but we see those in all languages..
Viredae on May 21, 2008 10:36 AMThe first language I learned, aside from HTML was PHP, and as I progressed it became very clear to me that in order to learn a lot of other languages I would need to ditch what PHP had instilled within me.
I agree that PHP sucks, but it works, and it's available almost everywhere. If you want to make a website with a back-end the default is PHP.
I'm starting to warm to Haskell now. Perhaps with all the recent developments it'll pass over to the web?
Mike on May 21, 2008 10:37 AMPHP_does_not_suck();
PHP has a wider vocabulary.
Marcel on May 21, 2008 10:39 AMWhy on earth do so many people seem to think that whether PHP sucks or not is in any way related to whether ASP.NET or anything else sucks or not?
The central thesis is that PHP sucks (to develop with). Doesn't matter whether ASP sucks, or whether Microsoft sucks, or whether PHP has been successfully used. What matters is that PHP sucks.
And for god's sake, the fact that facebook was developed using the tools the people making it knew, not tools that came out of a comprehensive study of which language sucks the least. I know I've done a thing or two in the "wrong" language, because I didn't know about the right one, or I knew it but the cost of using the "wrong" language was less than the cost of learning another language and I just wasn't feeling the "20% programmer" vibe at that moment, or because there was some library of code that did 90% of what I wanted which only had easily accessible APIs in language X, or because the last guy working on it used that language and his code wasn't so horrific that it was better to throw it away and start anew.
Disclaimer: I don't personally know if PHP sucks. Never used it. I've done a very slight bit of ASP.NET on my own time because I was working with something written in ASP. I'm a Systems Programmer, for the most part. I use C, and sometimes C++ except avoiding those nasty performance-sapping things like exceptions (yes, yes, I know -- and yes, the perf is so important that it's the right call). Delve into some assembly now and again on a variety of embedded processors but also x86 and amd64.
When I want to do something quick and dirty I use Python because I know it and it's like C but without the agony. My point is, I don't know if PHP sucks. I just know that most of the things you've said are irrelevant.
Ens on May 21, 2008 10:39 AMYour analogies are prety weak this time around. You basically say, well there is a plethora of spaghetti code out there for a language THEREFORE it sucks. The fact that PHP is easy to get into should not count against it. That has probably been one of the facts that brings it to the front in terms of adoption. It takes the finesse of a GOOD programmer to write GOOD PHP code like with ANY OTHER language. A crap programmer will write crap code, end of story.
Andrew Revak on May 21, 2008 10:42 AMAs a contractor, I've lead the development of various large enterprise level applications in both PHP and ASP.NET.
It's my opinion that ASP.NET is better simply because it's well organized and there's better community support, but that's just my experience. You have to be an amazingly disciplined programmer to build a large, well-written PHP application, and most people just don't have what it takes. I've also ran into more problems building apps around PHP than ASP.NET. For example, once our team built our data access around PDO only to find that some of the features we needed to call stored procedures were not yet completed! How do you explain that one to a client? Oh yeah.. it's open source.
Of course, the last time I used PHP was before the Zend Framework came out, so it might be getting better. The fact is, PHP has to get better or die. Search any job board for ASP.NET jobs versus PHP jobs and it will explain itself.
Justin on May 21, 2008 10:46 AMSee what you've done, Jeff - you attracted the attention of the people who write "Perl" in ALL CAPS. Didn't you know that if you insult a language, you'd draw out its proponents in droves? Given that inevitability, what did you think would happen when you insulted a crappy language?
It never ceases to amaze me that there are so many people who ignore the difference in quality between languages, because hey, they're all Turing-complete, ain't they! I *can* write bad code Ada, therefore I might as well use VB to code everything... right?
It's tough to get into the minds of these folks. My current best guess is that learning a second language would be way too much effort.
Josh on May 21, 2008 10:46 AMPeople need to compare PHP to Ruby, not to RoR.
RoR is just a framework. We need to get ruby either bundled _with_ RoR, or (much better) strengthen ruby's inbuilt stuff to tackle php.
PHP made it easy to create something, but with ruby this is a lot simpler. We need to find the few key areas where PHP shines.
It is NOT availability of web servers! In the beginning hardly anyone offered PHP on their host.
It is about producing _results_ that are USEFUL.
markus on May 21, 2008 10:48 AMOk, PHP sucks. So does a vacuum cleaner, but when you want to get dirt off the floor it comes in pretty handy.
So, why did/do all these monumental successes that you reference use PHP? Is it because all the founders are stupid? Or just non-technical enough not to know the difference? What's so great about PHP, or is it just a big coincidence that all those sites use it? Inquiring minds want to know...
"I'm starting to warm to Haskell now. Perhaps with all the recent developments it'll pass over to the web?"
No. Haskell never will.
Haskell is a language for the smart.
PHP never was.
If you have an elitist language like Haskell, it will NEVER become mainstream simply because NOT EVERYONE is an elitist and wants to study maths before writing in Haskell.
markus on May 21, 2008 10:49 AMThe thing about PHP is that it's a bad language to learn programming with -- it doesn't teach discipline. However, if you've learned discipline using a different language, it's very easy and straightforward to write elegant PHP code. The crappy parts can be ignored.
Leo Petr on May 21, 2008 10:52 AMUnsuscribe. This post sucks more than PHP. Unscoped, unreal.
suscribed_guy on May 21, 2008 10:53 AMHi Jeff,
I'm about to wager that this post will get a lot more comments than usual. It's already apparent by the comments that it's becoming a holy war of whether or not the language is good rather than regardless of whether or not it's good it still has a purpose and place :)
Stephane Grenier on May 21, 2008 10:54 AMThijs - right on! PHP's biggest problem is the inconsistent and messy function naming. Reversing needle and haystack. Making me look up the functions all the time by accessing php.net/function_name.
Otherwise, it's really, really powerful. And fast. And all I gotta do to deploy is place the file in the correct place.
PHP5 and OOP brought many, many web frameworks over the past 5 years. PHP on Trax, Solar, symfony, Cake, PRADO (which is similar to ASP.NET, Jeff), and much, much more.
Once you have those frameworks, developing on PHP is fast. And if you want to speed it up, use a cache like APC or XCache. Only thing is, sometimes these caches seem to fubar my exception handling, and I don't know why. I'm doing some heavy duty shit with it, though.
Now, it's true -- ruby and all these other "fast-CGI" languages have an inherent drawback of constantly having to recreate all your classes, etc. on each request. But with the caches, that's no longer a problem - I have about a 1ms overhead for including a zillion files.
In FACT, PHP is way more powerful and expressive than you imagine when you first start it. With things like $$varname, __autoload, and __call, __set, etc., it can be used to write code really quickly and easily.
I've written an entire MVC + ORM framework in PHP, and I can develop web applications incredibly quickly with it. Take a look, you might like it too:
http://code.google.com/p/pal-framework
That lets you code PHP-style :)
Greg Magarshak on May 21, 2008 10:56 AMlol @ all the PHP fanatics absolutely losing it over someone else's opinion.
It's ironic the way people can just bash Microsoft all day long, but if you say anything about their stuff simply being "disorganized" they nearly have a heart attack.
But that's just the way it goes I guess...
HB on May 21, 2008 10:57 AMThe comments to this entry are closed.
|
|
Traffic Stats |