
PHP Sucks, But It Doesn't Matter - tony_le_montana
http://www.codinghorror.com/blog/2008/05/php-sucks-but-it-doesnt-matter.html
======
polemic
Note that this is a response to:

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

[http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-
de...](http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/)

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.

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

~~~
ErrantX
_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.

~~~
cageface
_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.

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

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

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

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

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

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

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

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

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

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

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

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

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

~~~
sandwitch
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 ?

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

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

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

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

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

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

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

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

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

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

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

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

------
dageshi
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?

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

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

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

~~~
kdizza
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>

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

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

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

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

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

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

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

------
robwgibbons
YouTube is actually written mostly in Python.

