Hacker News new | past | comments | ask | show | jobs | submit login
PHP Sucks, But It Doesn't Matter (codinghorror.com)
158 points by tony_le_montana on April 10, 2012 | hide | past | favorite | 106 comments



Note that this is a response to:

EDIT: refer https://twitter.com/#!/codinghorror/status/18957165652253491... - Jeff's 4 year old response is still valid.

http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...

Jeff gets it right - the language is poorly designed, but it hasn't stopped PHP powering many of the biggest most important sites on the internet today. Banging on about the language's flaws [again] is not very interesting. What would be fascinating would be an attempt to understand why PHP remains so dominant despite the well-known flaws.

Seriously - http://stackoverflow.com/questions/tagged/php throws up so many pearls of WTF that you wonder how PHP could possibly be so important. And yet!

Time to stop the PHP bashing. It's like comp.lang.js complaining about the flaws of jQuery (and, indeed, any JS library) and expounding the many and various reasons you should never use a third party library. The reality is: when the keyboard meets the road, stuff has to get done, and these are the tools that seem to work.


This is the wrong way to think about it. Just because people can hop on one leg across the finish line doesn't mean that's a smart way to run a race.

Ask yourself this: would the Instagram team have been as successful had they chosen PHP? I think not.

Javascript is different because we're stuck with it for historical reasons but there are so many better choices on the back end that there is absolutely no excuse to start new work in PHP. Similar negligence would be considered unprofessional in any other engineering discipline.


> Ask yourself this: would the Instagram team have been as successful had they chosen PHP? I think not.

I chuckled a little bit when I read this.

I like video games, so I'll make a video game analogy. I'm playing a lot of BF3 right now, so let's run with that. A website called Symthic publishes a list of damage and ballistics information [1] for all the weapons in BF3. They also publishes TTK (time-to-kill) information [2] for all the weapons. With these two pieces of information, it is possible to empirically determine the "best" weapons in the game for a given scenario; that is close-quarters, mid-range, or long-range engagements. Yet I can equip the perfect weapon for a given scenario and still go 2/12 [kills/deaths] -- or worse -- in a round.

No one is scratching their head after reading the above. The answer is obvious. Even given the best weapon, my skills (or lack thereof) relative to the other players in the game result in a net negative kill/death ratio.

Programming languages are no different. PHP may not scratch your itch, but if you collect a group of talented, motivated PHP programmers, you're likely to end up with a working product. The end-user doesn't really care if the application was written with PHP, Python, Ruby, Haskell, Lua, Scala, Java... They don't care. They care that it solves their problem. They care that it makes them feel good to use the product.

In today's development landscape, these goals can be achieved with a staggering number of languages. Some won't look as pretty on the back end, and some may not be as hip as another, but to focus on that aspect is to miss a large part of the point. If you want to build successful software, the tools you use should be mid-pack on your list of priorities.

1 - http://symthic.com/?s=bf3 2 - http://symthic.com/?s=bf3&sb=timetokill


In every field of human endeavor where competition is extremely intense you'll find professionals optimizing their gear down to the last trivial detail. I very much doubt at professional gaming tournaments you'll find serious contestants using anything but the optimal weapons.

Nobody's saying you can't build app X in PHP, but it's likely that your competitor using a better language will get there first.

If you disagree with this, take it up with Paul Graham. The idea that a good tool can give you a competitive advantage underlies many of his essays on startups and software development.


Nobody disputes "that a good tool can give you a competitive advantage". What's at dispute is whether other things, such as skill or tacit knowledge in a field, give you greater advantages than this possibly over-optimized tool selection.

Also, why should anyone take your unproven assertion up with Paul Graham? His essays don't support your insistence that the "better" tool wins. On the contrary, I'd argue PG believes a whole host of factors contribute to success before optimizing tool selection down to the last detail.


> Nobody's saying you can't build app X in PHP, but it's likely that your competitor using a better language will get there first.

This is far more subtle than you think it is. The "speed" at which a team develops has very little to do with the actual language. The amount of time spent writing with the language pales in comparison to the time spent considering how your application will function, how you will structure it, and what you will call everything.

You may find, however, that it is easier to find teams that think in the "right way" in some language communities versus others. IMO, the community of developers that fit this "right way" of thinking (for startups) is migratory, so the answer today might not be the answer tomorrow. You need a team that balances conceptual purity with the pragmatism of results-based decisions.

The speed at which one language can be written versus another only applies in an "all other things being equal" scenario, and these scenarios almost never exist. The big differences in "time to successful solution" will almost always be decisions that aren't related to the language you choose.


The "speed" at which a team develops has very little to do with the actual language.

This is strongly contrary to my experience and extensive reports online. You wouldn't hesitate to argue that PHP is probably at least an order of magnitude more efficient for building web apps than C, right?

So why is it so hard to imagine that a cleaner and more expressive language than PHP might be as much as 2x better than PHP?


Ask yourself this: would the Instagram team have been as successful had they chosen PHP? I think not.

Why not? You do realize the "team", facebook, that acquired them (worth many multiples of them at the time of acquisition) is a PHP-based company right?


The interesting thing to ask should be if Facebook or Wikipedia's engineers would use PHP if they had to start from scratch. I used PHP for a big project before for legacy reasons but I wouldn't choose it for anything new even with a machine gun pointed to my manly parts. Neither would I use Java or VB for that matter.


Facebook and Wikipedia (and Wordpress) were born outside the software engineering establishment using lowest common denominator tools [1]. There's a reason for that: LAMP/WAMP has an extremely lower barrier to entry. A billion monkeys banging away on typewriters can make world-beating products, even if they don't compare to the works of Shakespeare in terms of literary quality.

Once these products prove themselves in the market then "professionals" are brought in to handle them, and these people probably know and like more refined tools such as Python or Java or something. It doesn't matter what language these new caretakers would choose for a rewrite though; PHP gave their system its first breath and that's how it stays long past the point in the lifecycle where PHP is a competitive advantage.

[1] http://en.wikipedia.org/wiki/MediaWiki#History


Pretty sure they would agree. The Quora and Asana founders seized on the opportunity to leave it behind, and what I've heard from Facebook staff is that they've managed to live with PHP. I can't remember anyone saying they like it.

http://www.quora.com/Quora-Infrastructure/Why-did-Quora-choo...


Our main takeaway from that experience is that programming language choice is very important and is extremely costly to change.

Taken directly from the horse's mouth, handwavy arguments about languages making no difference to the contrary.


"there are so many better choices"

This is absolutely true, assuming you're working on a blue-sky project or some niche purpose-built app. For the rest of the web, other available languages are (currently) missing one or more of the following:

- A wide selection of CMS's to choose from

- A wide selection of CRM's to choose from

- A wide selection of development frameworks to choose from

- commodity hosting environments ready to roll with little or no server configuration required

Declaring the choice of PHP over some other back-end language negligent in all cases is misguided.


Ask yourself this: would the Instagram team have been as successful had they chosen PHP?

They absolutely would.

Building an actual application is a hard problem; a lot harder than the kinks of individual programming languages. Whichever tools you choose it is never going to be an easy ride.

Anyone who has written, deployed or maintained a large scale application of the sort listed there knows this.

It's the step after ranting about how bad X language is.


Building an actual application is a hard problem.

It is. Which is why you can't afford to have the challenges of building something non-trivial compounded by the frustration of working in a broken language. If you're just slapping together another spaghetti CRUD app maybe you don't suffer enough to care.

I wonder if people in other engineering disciplines defend broken practices so irrationally. I suspect they don't have the luxury.


PHP has its frustrations. It's not outright broken.

But my point was that all other programming languages suffer their own "broken" problems. I managed a team working in Ruby not long ago; they had no end of gripes and frustrations.

The key point is that compared to the challenge of building a complex application, those "difficulties" are trivial. And once you are at that stage, anyway, you're so used to the way your chosen language works it doesn't matter.

These are not constraints on what the language can achieve or do and simply require knowing about them so that you don't paint yourself into a corner.

Because application design is a hard problem it doesn't matter, given a relatively skilled team, what language is chosen.

This is identical in other engineering disciplines; a friend of mine works in motor design (electrical motor) and is constantly griping about nuances in the tools and equipment. Same issues.


Recognizing that all languages have their problems is one thing. Arguing that all languages are essentially equivalent in the larger sense is another.

Sorry I just don't buy it. Tools aren't the only factor but they do matter.


I think we're a bit spoiled these days. Five or ten years ago, we didn't have Ruby (or at least a mature RoR), Django, Clojure, or Scala (to name a few), so PHP was a pretty decent option for someone trying to get something out there efficiently. These days, there are lots of interesting platform choices (all with different barriers for entry), so many "serious" developers have moved in different directions.


You're missing the point.

PHP works. A priori arguments from faults in the language don't explain its success. Replaying that old record doesn't add anything to What We Already Know.

Also: I didn't say that Javascript is different - I'm talking about the curmudgeons in comp.lang.js who argue that the practical benefits of using a JS library are outweighed by their flaws. This is clearly dis-proven by their popularity and demonstrable economic benefit. As for PHP, this remains true.


I know why it's successful.

I remember when PHP was becoming popular. It allowed for inroads to code from front end designers who hated coding in Flash at a time when academia-based Java people were running all the big websites. If you wanted to hack up and put up a website, you can do so in a few minutes with a LAMP stack where a Java stack needed some lessons in Java.

Same is pretty much true today, but it's 10 languages instead of Java.

You know, Java was the same way. It was originally made in the 90s as a language made for embedded devices (toasters, refrigerators, etc). No one expected it to be a web language.

But Java offered something that was attractive to C++ coders: garbage collection. that made learning the language a lot easier. C++ people joked about Java never becoming popular. It crashed a lot! (core dumps - a common issue in PHP)

PHP reminds me a lot of what Java was 10 years ago. It's not as well put together as Java was. And it too took about 8-10 years to introduce templating.

My point:

1) PHP is popular because it has a more welcoming barrier of entry into coding.

2) PHP's problems appear the same to me as Java's problems 10 years ago.

That's all. Not saying one is better than another. Use whatever the fuck you want. I use both so as long as my employer pays me. Tell me to code mindfuck and I will. As I get older, I think I hate them all.


I remember that PHP became popular because of mod_php. If you wanted to script a web application on Linux or UNIX your choices were either Perl with CGI or a much faster PHP with mod_php.

It was incredibly easy to setup both in production and for development - hence the LAMP stack and the thousands of cheap shared hosts that had PHP enabled, which lead to a lot of pre-install applications being written in PHP.

Other web applications only recently became easy to install, and they didn't beat 'ftp into the site and drag files over' until cloud platforms and virtualization.


They still haven't beaten PHP in ease-of-deployment. I've been writing for the web in Python for 2 years. Deploying your own server is a full-time job.

The only thing that's getting better is that things like Heroku now exist. Heroku makes it insanely easy to deploy Python, compared to deploying on your own server. It's still harder to do than FTP + copy files, which most people know how to do.


"(core dumps - a common issue in PHP)"

Ummm.... I've been working with PHP for 16 years, and I could count the number of coredumps I've had in production on one hand (maybe 2). Early on, when compiling extensions by hand, I'd get some when I compiled something wrong, but that was always in test areas on dev machines.

If 'core dumps' were 'a common issue', I doubt it would be as widely used as it is now.


Bahh.. it was at where I worked. It was because we relied on C libraries that PHP connected to. When PHP is slow, they make links to C libs to get speed. Java did the same with JNI. PHP simply isn't fast enough in some situations where C libs are necessary to hook up with. (private message me if you disagree.. I'll be glad to go into details)

We were typically getting up to 200 req/second on our stack. So it was pretty heavy traffic to begin with. We solved the core dumps though. And the java core dumps were for the same reason (necessary to connect to JNI).


Sure... when dealing with custom C code and hand-rolled non-vanilla PHP, I can see that happening. Understand that your experience was in the realm of the .01% of PHP usage. 200/req second isn't all that outrageous for run of the mill PHP (depending on hardware) but when you're throwing in custom connector stuff on top of that, yeah, you'll get core dumps. :/


That's all I said though, is that it reminded me of my Java years.

And yeah, connecting to C libs is commonplace in large PHP places. In fact, that's how PHP gets a lot of it's work done to be quick. Your ".01%" is a number you're throwing out of your ass and you know it.

I'm not surveying PHP usage, merely telling my experience. If you work on a website and need to connect to an external system that only has a C lib, guess what? You're going to connect using C libs.


> Tell me to code mindfuck and I will.

I believe you referred to brainfuck, just for the record.

> As I get older, I think I hate them all.

There is some deep pessimism in the software world that I feel constructive.

When engineers talk about how much they hate the tools even they don't have to use, I think it shows the care they have toward the profession.


Bahh.. Don't be so patronizing. I'm a nerd dude. I was joking when I said I hate them all. I'll fuck Java and PHP in a 3some if given the chance.

I'm saying as long as I get paid I'll do the job because I'm an hourly coder (pays more, have mouths to feed). I do plenty of "fun" work and open source work.


It's the same reason people in any field put down things - they like to feel superior by putting down the tools that others use, thereby increasing their own relative stature.


I hate people who put down people. They're assholes and stupid.

Just kidding dude. I was just joking when I said that. I love coding. I'd fuck a node.js program and even let XML lick my balls at the same time.


On the other hand, you can generally complain the longest about the things you know the best.


There's also a "familiarity breeds contempt" angle.


What in the world does language in which the site was made in has to do with success? They were never acquired for technology - in fact, go read about their setup on HA, it's very standard stuff.

If you build a product that gets traction and solid user base with some viral aspect in step 2, you will sell - even if your app/site were made in QBasic.


This kind of careless, selfish attitude really pisses me off. If I walked into a doctor's office for an operation, saw a tray full of old rusty instruments, was told by the doctor that they were "good enough" and that I should just worry about the result then I would not only walk out of that office but also file a complaint with the hospital.

If you're selling your services as a professional to clients you owe them the best work you can do. There are legitimate reasons to prefer Python or Ruby or Scala or whatever but if you're just too damn lazy to stop using PHP then you're essentially guilty of professional malpractice.


Are you serious? PHP is not "tray full of old rusty instruments". Please give me one concrete example what is wrong with a blog running on PHP. Or a small store? How is the END result differ between say Magento or something running on Django? Could you tell the difference? No, you could not. And while the PHP version would have been up and ready, you would still try to figure out how to properly run WSGI server in shared hosting.

Good luck with your endeavors.


> Please give me one concrete example what is wrong with a blog running on PHP. Or a small store? How is the END result differ between say Magento or something running on Django? Could you tell the difference? No, you could not.

I think I could, pretty often at least:

http://duckduckgo.com/?q=wordpress+%22hacked+by%22


Right, because no other language is hackable.

https://github.com/rails/rails/commit/b83965785db1eec019edf1...


Should languages be required to ensure the security of the code produced for them?

IMHO this is more of a complaint about the security of Wordpress, not the PHP core. People love to bring up phpBB or Wordpress in these discussions, but there are many, many more systems using large-scale PHP about whose security you just don't hear, because they are coded by professionals who know how to produce secure code in PHP.


> PHP is not "tray full of old rusty instruments".

Clearly that's a matter of opinion.


Or your clients find it easier to find suitable PHP developers in which case you are doing them a disservice using anything else.

PHP isn't a good language but it's not so bad to be unusable. I think you're really overstating the problems with it.


Someone's being a little too serious for his own good. Every language has its quirks, pick your poison. In the end, the idea that is realized is what matters.

Also... how did you draw a relationship of PHP's quirks to rusty old instruments? Is C++ pretty much dust then?


  > Instagram team have been as successful had they chosen
  > PHP? I think not.
Can you elaborate, why you think so? PHP worked OK for Facebook and Wikipedia.


The time you don't waste fighting with the language and coding around its deficiencies is time you can spend improving existing features and adding new ones. If you're trying to run a lean startup with only three backend people like Instagram these effects are very important. Those three engineers could have coded something similar in PHP but I'll guarantee you it wouldn't have been as good.

Facebook can afford to throw money at the problem and nobody's really trying to compete with Wikipedia so they can get away with it.


I've developed large applications in PHP for years. Currently we're using other languages at my current company for a couple of reasons. They could have coded the exact same thing in PHP and I doubt it would have taken them any longer. The language isn't great but I never found myself truly fighting it just displeased with some of the syntax.

Facebook started with PHP they weren't always the massive company they are today and managed to displace other entrenched social networks.


  > fighting with the language and coding around its
  > deficiencies
That's still too vague. Sure PHP has it warts, but I don't recall anything I could call "fighting with the language". Yep, stack/needle mess and inconsistency in naming is annoying, but not exactly a huge time waster.


Time savings? How's downloading the entire feature set for content creation, categorization,user management & authentication, and menuing in 45 seconds stack up to arsing around in a text editor setting up your file structure for a new development project?


> Facebook can afford to throw money at the problem

Aaah the good old circular reasoning of dismissing the big guy - they did get big enough to be able to afford money by using PHP too you know.


This sounds very much like the new version of "I can tell it's a rails app by how it looks".

The idea that the server tier language has a direct effect on the user at the level of code quality we are discussing is naive at best and trollish at worst.


Are you seriously arguing that all backend languages are essentially interchangeable?

Give competent team A six months to build something in PHP and competent team B six months to build something in any of the better options and team B will build a better product every time.


Do you have any evidence to back up this assertion?

Because I would imagine it depended a lot on the skill of the teams in question - and if evenly matched they would produce similar quality.


I would have thought Instagram would have been popular no matter what they used. People liked the product and functionality. They don't give two hoots about what is powering it.


> there is absolutely no excuse to start new work in PHP.

I hate PHP myself, but as far as my personal projects go, PHP is perfect for cheap shared web hosting. Some fairly basic and crappy functionality to prevent users from stomping on each other's files is included. Something that can reasonably replace PHP in that role would be what it took to phase it out of my personal use, and what people choose for their own work affects their choices on all work.


Ask yourself this: would the Instagram team have been as successful had they chosen PHP? I think not.

Instagram was only succesful (i.e. bought) because they had something (lotsa users' photo habits) that someone with lotsa money (facebook) wanted.


90 % of end users wont be even knowing if they used Python/ Django or anything.


> What would be fascinating would be an attempt to understand why PHP remains so dominant despite the well-known flaws.

I've actually put a fair amount of thought into this. I've arrived at the conclusion that it's because it ships with the Big Three parts of any web app in a single package: Request/response handler, scripting engine, and template engine. To the novice, there is no distance between the query string in the URL and the parameters available in $_GET and the ability to write those parameters back to the page via <?php echo ?>. They're all wrapped up in a handy mod_php binary that runs in Apache, and you probably don't even have to do any extra work to get it to run. It Just Works. This has nothing to do with PHP as a language, but it has everything to do with PHP as a web-oriented product. PHP isn't for systems administration, or generalized scripting, or embedding in your game to serve as its scripting engine. It assumes it's web-facing, and that removes a lot of the friction that otherwise trips people up.

What this means is that it's trivial to deploy full-blown applications like Wordpress, phpBB, Joomla, Drupal, and a host of others. They are literally as simple as "unzip this file and go to http://yoursite.com/package. That's huge! As a Ruby web developer, I'm envious of that. I wish I could give people a zip, say "drop this here and unpack it and you're up and running".

PHP is the lowest-user-overhead "make things happen on webpages" language in use right now. This comes with all kinds of downsides which many of us are familiar with here, but PHP's success has nothing to do with the language itself, and everything to do with how easy it is to deploy a full PHP stack itself, and then any PHP application on top of that.


That's a really good analysis. I'm currently mostly using Python, but I've had a lot of PHP experience. Once everything is configured python is a dream, but if I just want to prototype a simple website, it just isn't worth it. Same for the average blog or small scale business site.

To me this signifies a significant hole in the market that competing products could fill. We've already seen that, to some degree, with platforms like AppEngine, but not so much with self-hosted solutions. Or do such things exist? If so, why are they not more prominent?

Another huge bonus for PHP is that a AMP stack is easy to run on Windows, Mac or Nix. The same cannot be said for Rails or Python.


Exactly. To get Python running, you need your webserver, some kind of fcgi/wsgi module or interface running in your webserver, specialized configuration for your app in your webserver, Python installed, some enumeration of your app's packages installed, and finally, your application running.

We laugh at PHP as a giant glob of senseless stdlib crap, but for its purpose as a web-facing product, it works. Users almost never have to worry about installing extra libraries or modules. mod_php means that you never worry about whether or not you have mod_proxy and some fcgi wrapper installed. You don't have to worry about process management.

This doesn't make PHP less of a disaster from a purist's standpoint, but I think it's exactly the things that make it a disaster (gigantic stdlib, no real package manager to speak of, single-threaded, designed to run in short-lived processes and then die off, etc) that make it widely accessible as it is.

I still think there are huge issues with PHP as a language, and I'm long past the point where I'd consider it an ideal candidate for web applications development (because I can deploy python and ruby apps with ease now!), but it has wildly succeeded at hiding all the underlying machinery from the user so that Joe Average can just start scripting his webpages.


Note that Jeff's blogpost is almost 4 years old. Posting this to HN might have been a response to the veekun.com article, but that's not what it was written for…


Thanks, noted.


Things that don't matter:

  - OS
  - Language
  - Compiler 
  - Runtime
  - Editor
  - Testing process
  - Deployment process
  - Bug management systems
The thing that does matter:

  - Building something successful that people want
Frankly, I don't care what language you used to build it. I don't care what shoddy infrastructure supports it. I don't care what hacks you put into place to scale that infrastructure. You know why? Because your customers don't care. They just care that the thing you built works.

So just build something successful that people want. And do it however you want.


That's absolutely right. I've established that there's a market for digging trenches for subterranean cables, and my decision to use teaspoons instead of pneumatic drills and mechanical diggers has no bearing whatsoever on my venture's prospects.


That would be a very valid analogy if no other trenches had been dug with teaspoons, but a high percentage have, including some of the largest and most successful.


The analogy wasn't particularly about PHP, it was about tools.

It might be true that the choice of tool is irrelevant to an end user, investor or other person that's not capable of or interested in judging the tool's merits, but if you're actually trying to build something the choice of tool matters quite a lot. The fact ryannielson doesn't know or care what I do all day doesn't help me get stuff done.

Epilogue: The company I work for recently bought a Content Management System / web framework for half a million bucks, then spent another half a million bucks trying to make it work, then abandoned it in favour of the system we were running before. I think the decision to go with that tool was a poor one.


This is the right attitude.

If you want to do business that is how it is supposed to work. The customer won't care less how the product was developed, and if he cares, he will be defining the tools anyway.


Woe betide developers actually feeling good and having fun whilst developing this app. You won't attract skilled new developers with technical debt and a crusty old language.


These are two different questions:

1. Should I care what successful product X was written in?

2. What influence does my choice of language have on the success of my product.


While I agree with your priorities, I think it's misleading to say they "don't matter". They do matter. They just don't matter as much.


What exactly is the argument that we're having?

If somebody were arguing that a website loses value by virtue of having been made in PHP, all else being equal, you're right, but nobody's arguing that.

If somebody were arguing that PHP should fall off the face of the earth, you would be right to say that this is an awful argument because so many people are already used to PHP and are productive, and learning a new language takes time. And I think not many people are arguing this either.

The relevant argument is, for the sake of maximizing the potential to Build Something Successful that People Want, PHP should rarely be advocated, because better languages and platforms exist. If you come back to me by pointing to Facebook and Wikipedia, I would ask you to explain to me how, given the challenges leveled againste PHP as a language, it could possibly be a preferable language to Python or Ruby.

The only redeeming value of PHP that I can think of is the easy setup. And I don't think that would help Facebook or Wikipedia if they started today (I'll grant you that PHP may have been the right choice given a lack of web frameworks at the time they started, I actually don't know why they chose what they did).

So by this reasoning, unless there can be a list of benefits to PHP that would lead you to believe that it would help lead to Facebook's and Wikipedia's success if they started today, the rest of us are left with the conclusion that, based on these ridiculous deficiencies, there's no reason it could possibly help them and it would probably hamper them. But more importantly, it's a losing proposition to learn and use to start a new project, other than something that's starting small and needs to get off the ground really quick.

Is that unreasonable? Imagine everybody was "doing just fine" making successful websites in assembly? How about a realistic case study: Ok Cupid wrote their own webserver in C++. They still use it because it's not worth redoing their whole infrastructure. But if they started today, they would have used Apache. They don't advocate anybody, themselves included, to write a web server in C++ (edit: today), despite the fact that they're "doing just fine" with it.

So if somebody is criticized for using PHP, and their response is, "Yeah, I know, but it's what I know" that's perfectly fine, learning a new language takes time and it may not be worth it, it's not my place to make judgement calls like that for people. If their response is "Hey man, I'm plenty productive with this, to each his own" imagine if they said that about assembly. Yeah, I guess they could be wired in such a way that it's more productive for them, but it's got to be such an oddball case that it doesn't justify the existence of the language. Yes, part of me wants to live and let live. But I can't sit back and accept this subjectivist attitude toward languages, there's actual reasons a language is good or not.


But when starting a project you still have to make all those decisions. So knowing that PHP sucks is useful information.


Many both pro and con PHP articles are missing the point about PHP. PHP is a great success in spite of its obvious shortcomings because it supports iterative development. (Saying that language choice is less important for a project than other factors doesn't explain anything - all other things being equal, a language with fewer traps and idiosyncrasies would be the better choice.)

The killer feature of PHP is that you can FTP to the server and start adding arbitrary code to a static html file by adding a single tag. Other frameworks deliberately makes this more complicated with more overhead, because they want to promote a better architecture with separation of concerns and so on. Basically these frameworks have "encoded" the waterfall-method, because they assume you know from the start that you need a complex site. PHP supports iterative improvement from the simplest site (static HTML files on a server) to arbitrary complex code, without requiring major speedbumps where you have to rethink the whole app.

This also mirrors how many web developers have learnt to code - starts out with making html/css, then gradually learn php by inserting simple snippets of code to make banner rotate and so on. (The "right way" of course would be to take a pause for a few years to get a CS degree before adding the banner rotator.)

When an app grows beyond a certain level of complexity, changing to a better platform might improve quality, but then you have already made an investment in existing code.


Thank you! Iterative development is key.

Out of any language I've ever used, PHP has most allowed me to just get stuff done fast. It certainly isn't elegant, but it works. And even as you grow and scale up, as long as you constantly refactor at critical moments, you can avoid spaghetti code just fine.


As someone who has written PHP for years, I would say it's starting to matter. The inability for PHP to adapt in a speedy fashion to new programming trends, the continuous implementation of features in a half-assed fashion (namespaces, anonymous functions, etc), and the unwillingness to even attempt to clean up the standard library have begun to marginalize PHP.

It's now easier and faster to get up and running with JavaScript or even Ruby, and these languages have more internal consistency than PHP, meaning that long-term they will see more skilled developers using them and thus will eventually have more and better libraries than PHP.

In addition, the JVM has reached a point where languages like Scala can compete, and apart from the initial cost, C#/.NET will actually save you money in the long term.

So, in short, while PHP is just fine as a language and I use and abuse it every day, I have a feeling that we will be seeing its twilight sooner rather than later, unless something like HPHP takes center stage, breaks backwards compatibility, and shakes up the ecosystem enough to revitalize the language.


>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.

I'd say life is too short to write in terrible languages. Yes, PHP was once the language of choice and now that it glorious days are beginning to set, I don't think a little PHP bashing is too inappropriate.

Speaking of PHP popularity, are there any notable startups that launched recently (<1 year) that used PHP? Given the popularity of Rails, Django, Node etc. it feels completely dead. On that side note, let me get back to my Java Server Pages assignment in college (I'm not even kidding).


PHP is the textbook example of worse is better. It shows two important things:

1. The success of a programming language has nothing to do with elegance and everything to do with raw capability, ie. what does the language make dramatically easier.

2. Technical warts will not prevent great things from being done in a language. It's certainly true that Haskell will not allow you write as broken a piece of software as PHP, but in many cases you can write something just as elegant in PHP as you can in Haskell (laziness/pattern-matching/type-inference notwithstanding).

Now, personally I will do my best to ever write any PHP again, and if someone asks me my opinion I'll tell them that I believe using PHP exclusively will stunt your growth as a software craftsmen. But those are just opinions. I don't feel the need to go out and advocate against PHP because the software communities where I devote my attention are doing just fine. If somebody likes PHP then more power to them, it certainly won't prevent them from doing great things.


The article claims that YouTube is written in PHP. As someone who worked there, I can tell you it's not. YouTube is written mostly in Python plus some Go. Some of it is a mess, but that's beside the point.


You should have finished the paragraph

>> (Update: While YouTube was originally written in PHP, it migrated to Python fairly early on, per Matt Cutts and Guido van Rossum.)


Youtube was first launched using PHP but ported to Python around the time this article was written, if I recall correctly. Having trouble finding a source - best I can do it second hand on Quora - http://screencast.com/t/NZD0KIHdF / http://www.quora.com/Is-YouTube-still-written-in-PHP/answer/...


This was actually the reason why I started learning Python for web development. I can't remember how long ago it was, but I had spent months/years burying myself in PHP and hoping to see the light... after having a short affair with rails, Python was the language that called out to me from... eh, usenet probably. It seemed so simple and pleasant, yet with the performance to be powering the 'Tube.


do i understand you correctly - you found it harder to learn PHP because its so unorganized and inconsistent ,

and found Python easier to understand and learn than PHP ...

anyone else here with similar experience ?


Absolutely. I feel like I wasted some of my most able years fiddling with code that was complete garbage (my fault) and not learning much of anything because I was constantly looking for explanations of, well, everything. Granted, I was young, foolish, and accepted what everyone was saying ("All you need for webdev is PHP... shhhh shhhh"). I didn't really 'get' programming due to all that. But Python was a breath of fresh air, and while I'm no expert I feel much better for it even while going through snippets of PHP.

Basically, I saw PHP as the pragmatic solution to programming for the web. Problem was I didn't really understand programming until Python showed me the light, and while I'm much happier now using and [still] learning C I found it to be an immense help.


You chose python for its performance?

Well, I guess it's no Ruby.


[As only a novice could...] But yeah, I've only recently gotten back in to Ruby because performance be damned, it's fun in its own way (to someone who doesn't do any programming for a living at least). Edit: though I'll freely admit that for my purposes, performance has yet to be much of an issue.


There is really nothing wrong with Python performance-wise, the bigger issues will be things like the speed of your database, what kinds of caching and algorithms you use, etc.

Maybe worry about recoding the whole thing in ASM (or something equally macho) when you find that you have a good working idea which is only really hampered by time differences measured in ns.

Most web apps do not require you to carry out ray tracing. For typical cases Python can indeed be pretty fast.

If you have the most fun using Ruby then use it, life is short


Any critic of PHP who advocates other languages, like Ruby, Python or Java has to answer a question "Where are the apps?"

PHP has accomplished code reuse on the app level: applications like Wordpress and Drupal are world class and you just can't find installable web apps in other languages that have reached anywhere near the level of success. Occasionally you find an app in another language and generally it doesn't have the fit-and-finish that the successful PHP apps have.

Other languages, on the other hand, grow frameworks like cancer cells, and I wonder what disease they have that prevents these frameworks from being actually usable to build apps.


The only reason Wordpress and Drupal became successful is because PHP is present on basically every shared host you can find on the internet. They stayed successful by building a community of plugins and themes.

The actual internals of both are a complete mess, and trying to get them to do anything outside of trivial blog hosting and content management is a nightmare.

Just because you don't know of any Python/Ruby/Java "apps" doesn't mean they don't exist. Jenkins, Redmine, Trac, etc.


Note that all three examples of yours are software project management systems. That's a very narrow segment of the market.

You've also got to ask the question of why PHP is so widespread compared to the others.


Like it or hate it, PHP stack is easy to start coding webpages if all you know is HTML.

PHP is an easy to enter arena. Memorizing APIs is easier than Computer Science. But PHP works fine with CS concepts. But it also offers a shit ton of commands that allow for both styles to mingle (often times, not nicely).

I'm sick of "your language sucks" arguments. There's good in all of them.


I don't see why a couple of badly named functions can make a whole language crappy.

All those people bashing PHP suffer from some kind of superior complex. It's like bullies beating up the ugly nerdy kid that has glasses and pimples.

Or maybe it's just envy that something, that might not win the next language design contest can be so popular.

To all the PHP haters out there: hate away. I don't care. All the other PHP programmers making a living don't care. Mark Zuckerberg clearly doesn't care.

It's time to grow up, people.


PHP is like English: a mutated fugly cockroach of a language that defies logical explanation, contains more exceptions to any syntax rule than the rule covers and yet its very ugliness is also its strength: you can always, always find someone who can work in it.

Don't underestimate how useful it is that anyone can come along and hate your codebase just as much as you do in a very short period of time.


After reading through the comments I have to leave my comment about PHP.

I have been developing in PHP, Java, and a little of C#, I also have done a few things with Python.

From my exprience it does not matter what language I'm using, it's just a matter of syntax and knowing the language.

My personal preference goes to PHP or Java, and while Python is nice I can't stand the whitespace thing, I like to be able to write my code without thinking about how it looks, only after its written I care about the look for later reading (in my case tell my IDE to make it pretty, by hand its boring but easy too).

While C# as a language is good for me, the msdn documentation sometimes seems rather lacking when compared to PHP or Java and in the case of Java the exceptions it thrown (btw if someone knows where there is a reference for the exceptions a method throws in C# please tell me, I can't find them in msdn).

Yes PHP has its frustrations and quirks, but it is possible to write well structured code for web applications and separating everything using MVC. Same applies to Java or C#, Python etc.

Don't like it? Stop caring about it.


Sure, Facebook and Wikipedia are built on PHP, and they serve to very many happy users. But are the developers very happy? PHP works, but for most cases, there are better solutions, and we should strive for better. Just because some sites were successful in doing it doesn't mean 'PHP sucks' isn't a valid argument.


I'm fairly happy as a PHP developer. It pay's the bills... there are times when I am presented with a mess which makes me want to shoot myself in the face. However I am sure such messes can easily be created in other languages. PHP has a history of Spaghetti code and when I was learning it mashing mysql, php and html into the same file was 'the way to do it'.

Today though PHP development revolves much more about OOP frameworks like Symfony and a good application structure.

The thing that bugs me most is inconsistency in core functions. Is it functionname or function_name. Is it ($needle, $haystack) or ($haystack, $needle). However, it is a minor annoyance negated by a decent IDE.


"building a compelling application is far more important than choice of language." Amen.


"If PHP sucks so profoundly, why is it powering so much of the internet?"

The same reason that Excel vba sucks so badly but is powering so much of internal company "applications."

A lot of these sites are first started by a small group of people, looking to get something working ASAP. They do what is easiest, setup LAMP and get hacking. At the time, it's the quickest way to getting something workable.

Inevitably, you end up with a similar situation as you do when your BA takes it upon himself to create an indespensible excel vba spreadsheet. The cost of redoing it in something better is hard to justify, because atleast the current application works. Even though you know it has reached a point where having it as a real application would probably be best since so much of your company relies on its information and analysis.

So here we are, stuck with a shitload of crap written in PHP and Excel VBA, but it doesn't matter. Because all that crap works, and that's the goal. Not maintainability, elegance, programming cred, etc.


I've always thought that php was the script equivalent of c, in as much as it'll run anywhere and any library that's ever been written will probably have a version that works in it.

Perhaps those two factors alone outweigh all the others?


It does matter when you have to work on an existing PHP project that makes throwing yourself off a bridge seem an attractive proposition.

Yeah, it's not entirely the language that is to blame - the language didn't design and code the project after all - but its own design makes it too easy to create stuff that will really punish more seasoned developers later on.

That it powers some popular products or websites isn't entirely relevant, unless we're saying that Wordpress, Wikipedia, Facebook, etc. are popular because they were written in PHP.


The TIOBE index shows PHP's popularity began declining two years ago.

http://www.tiobe.com/index.php/paperinfo/tpci/PHP.html


Apparently Ruby peaked 3 years ago: http://www.tiobe.com/index.php/paperinfo/tpci/Ruby.html

And I don't know what to make of Python: http://www.tiobe.com/index.php/paperinfo/tpci/Python.html


What surprises me is that "they" can find talented programmers who are willing to code PHP.


They don't. They find a lot of "programmers" who can hammer out PHP.

The talented programmers who end up writing PHP don't do it because it was their first choice. It was probably their tenth. Or twentieth.

PHP is one of those tools that you can find a lot of people who know how to use it. Certainly not all of them are actually talented or even competent. But there's a lot of them.

I think the article's conclusion is misguided.


When you say Wikipedia, Digg, Wordpress, Facebook, et all were all written in PHP, it doesn't mean a thing. All those use PHP simply because when they started PHP was the best thing available. Nowadays this is not a matter of "it gets the job done" anymore (e.g., Facebook paid $1b for a site that runs of Django).


The religious wars over the interpretation of languages needs some serious self-reflection.

There is so much confusion between a language and a framework. Blindingly.

The religions of one language compare their experience, due to a framework, with another language without using a framework.

How does this make sense?

As a non day to day PHP developer:

- The Web, as a platform is relatively a baby, compared to platforms like PCs, going back to mainframes.

- I feel for too many devs, the relationship to production code that is more than a few years old seems foreign, especially to those who have joined the Web in the past 5 to 7 years.

- Most languages used on the web, were not designed for the Web, first. Instead, most languages have a framework to extend a language to the Web.

On Languages:

- Having seen sites built without a framework in many languages leads me to wonder: Why do we act horrified at old code? It seems reasonable that our old ways of thinking would improve, maybe even be expected for the level of intelligence on hn.

- Most languages now a days have capable Web frameworks. Instead of focusing on advocating for the use of a framework, we keep the discussion at a much more surface level, like which language.

- Language is merely syntax. Granted some languages are interpreted to be more eloquent/elegant/efficient than others. Yet the language we all speak, English is the most universal and in a way quite hacked up. Yet we don't take any upfront to bash fellow developers instead of supporting the use of frameworks today so in 5 years, the next batch of people who know lots don't look back and find less fault in todays perfection.

- I'm at a loss to try and argue one language is the way. It isn't. Nor is one framework. But if your language of choice is not natively made for the Web, make sure you use a framework. Add a beginner it might be one kind, advanced developers can likely pick something else.

- A mess can be made in every language. What's our point, really, when we can't see the forest while so obsessed with the trees?

On Code:

- All code older than a year starts to become legacy.

- I'm not sure if we really understand old code was often written with less foresight than we have today. It didn't make the tools obsolete, as much as old thinking obsolete.

- There will be new things coming out all the time, few last. As much as it's fun to go on a language witch hunt, we have our own skeletons waiting for us as our projects live on longer and longer.

- with the Web in it's infancy, is be surprised if 30% of developers have a relationship with 10 year old code at all let alone with code that still is in use on the Web. It's great that we can do things the new way, but we'll always have a growing history of code to maintain a relationship with.

- PHP might suck along with a lot of other languages, but I hope we consider whether the lens we live we see ourselves thought couldn't use some improvement.

On Frameworks:

- Every problem someone had with a language is more likely a problem with not having used a framework, instead of the language itself.

- For those learning coding, learn it from someone who had good habits and thought processes, those are the things that are the most important to have as the language de jour makes it's rounds. Having the transferable skills of decently evolving application design between languages and frameworks will forever leaving.

From where I see it, most languages now have capable frameworks, and all languages have capable developers. Please stop the witch hunts. The amount of vile filth spread about others preferences compared to your preferences based on 10 year old experience and hearsay of a particular language to this developer, is akin to believing and propagating a nasty stereotype about a particular culture or nationality without learning for yourself. It's not that much different than being that ignant.

Developers, let's continue discussing, but more importantly educating and spreading the wisdom of good practices in all the communities we participate in so there's more of us.

Let's spend less time talking trash about others based in hearsay, interpretation and preferences in language, and instead build stuff people want, because we really can make the world a better place with software.

0.05


If you think about it, there are two noticeable motives that put PHP where it is:

- The language has been made and (poorly?) designed around the web. While PHP is a language itself, it usually has no purpose outside the web, while Python and Ruby do not address the same problems the same way.

- Deployment is easy.

And yet, it seems all these articles fail at noticing these two simple things.


Too much comp-sci attitude, too little coder attitude.


If you showed me things like this in Ruby or Java I would go just as crazy.

Yes, PHP has its issues (so do all languages). But, if you are a good developer, you can write good code.

Many people writing PHP apps aren't good developers.


YouTube is actually written mostly in Python.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: