views:

231

answers:

6

Much has changed since 2003/2004 when Wordpress and Facebook were started. If you were starting Facebook today, knowing in hindsight the functionality and scale required, would you choose PHP (today)? Why or why not? If not, what would you choose as the basis for a massive, interactive, multi-facetted application like Facebook?

I know this is somewhat of a subjective question and would rightly require more details about requirements, etc., but I think it's a suitable question - is PHP as viable today as it was six years ago and in hindsight, would you have built Facebook with PHP then and now?

+7  A: 

is PHP as viable today as it was six years ago

It is even better and stronger today.

would you have built Facebook with PHP then and now?

Definitely, it is more robust now than before.

Have a look at this video to know why facebook chose PHP and still loving it and contributing stuff like HipHop:

Sarfraz
+1  A: 

PHP is still a viable choice, it's just a mater of using it in the right way to do what you need to do.

There is no wrong language to build big application. You would be surprised to learn that GMail is entirely coded in Javascript.

HoLyVieR
Gmail is not entirely coded in Javascript. The user interface front end is in javascript.
corydoras
I really, really doubt that GMail is javascript server-side.
Karel Bílek
@corydoras @Karel "Google engineer Adam de Boor raised an eyebrow or two in the audience when he pointed out that Google's Gmail service (443,000 lines of code) is written **entirely** in JavaScript." Quoted from the blog post linked in my answer.
HoLyVieR
+1  A: 

is PHP as viable today as it was six years ago -- I think you phrased that as if PHP got worse over time, which isn't true.

PHP has got better, with performance boosts (HipHop being released by Facebook helped), new libraries for things like MongoDB, namespaces (despite the idiotic \), and nice frameworks like Symfony.

So yes, PHP is viable and always was.

That doesn't mean it is best of course. Java might be better for some websites, PHP for others. And the language isn't always the most crucial issue, because you can always throw more servers to counter PHP's slowness compared to Java. Also consider how easy it is to hire good developers in the area who know that language well, etc.

Coronatus
+1 for the "The language isn't always the most crucial issue". But nice back-handed statement about PHP's slowness compared to Java... I'm not sure I agree with this (especially in my experience with Java websites)... But the overall sentiment otherwise is good...
ircmaxell
I would upvote it were it not for the never-ending \ bike-shedding. Jesus people, get over it. \, `::`, `/`; it's completely arbitrary.
Artefacto
+1  A: 

Is it viable? Yes it is. Obviously there are some quite large sites that use it.

Is it the best option? It depends on a large number of factors. The two things that steer me away from php are:

  • In my experience, people write harder to read and maintain PHP code, than in some other languages.
  • In my opinion, languages that use the JVM (Java, JRuby, Scala, etc...) make it easier/simpler scale easier with less effort and less code complexity.
corydoras
These are generalisations, of course some people write fairly easy to read and maintain PHP code, and some people people write pretty crappy Java code as well.
corydoras
Don't confuse that PHP lends itself to having junior developers being productive versus that PHP itself is flawed. A competent developer is a competent developer regardless of the language. All languages can have spaghetti code... PHP is just given a bad wrap because the low learning curve tends to let lesser developers still appear to get work done...
ircmaxell
I don't like what you're saying, but I must admit the best (as in, most readable, extendible and debuggable) PHP code is written by people trying to emulate a stricter language in PHP syntax...
Michael Clerx
@ircmaxell, I agree that a junior developer can get something up and running in PHP very quickly, the issue is more with maintainability of these types of solutions. Try working at a company where you have to maintain a large amount of old legacy system, all I am saying is in reality, I have personally found that PHP apps tend to be more difficult to understand and fix.
corydoras
+2  A: 

To be honest, PHP is a mess. There are million reasons for it and I take it that most people who use PHP will agree with me. If you look under the hood (ie: PHP's source code) you will shake your head and facepalm quite frequently.

In my opinion the language is too newbie-friendly (was built with this purpose) and too forgiving.

  • Can PHP be used to build large scale websites? Maybe.
    Facebook uses PHP, but a modified version of it.

  • Will it be taken as seriously as Java and .NET by enterprises? Time will tell.

NullUserException
Really? I've never facepalmed reading PHP's source. The quality of the extensions are a bit variable and some parts got some cruft over the years (some functions got too big, there are a few ugly hacks), but that's normal with a codebase that old. I've seen **much** worse C code.
Artefacto
@Arte PHP sure got a lot better over the years, but IMO its biggest problem is the need to maintain backwards compatibility. That's what makes a lot of things ugly.
NullUserException
You don't get taken serious by enterprises by looking good "under the hood". That requires marketing, business deals, etc.
Michael Clerx
I faceplant when you say .NET. Then I also vomit loudly all over the office. Please don't mention it again. And Java, well, yes I'm very excited about it when an app is written properly in it.
sims
So you'd rather them nuke compatibility every version (Like Python)? I'd rather have 1 version back compatibility than have to go through and change everything each and every time I want to use a new feature of the new version...
ircmaxell
@sims What's wrong with .NET?
NullUserException
@irc *I* would have. See http://code.google.com/p/phpreboot/
NullUserException
@Null: I saw `less $, less ';' like in javascript` and nearly puked... I'll refrain from commenting on the rest of it (As the rest of the comments will likely be less clean than that)...
ircmaxell
To everyone leaving downvotes: Explain. Don't just do it because I criticized your favorite language.
NullUserException
@NullUserException, Sorry man, I'm just trolling. One thing I think PHP has going for it is that it doesn't hide http from the developer. I've had some Java devs completely not understand the inherent nature of http, thinking in very desktop development terms.BTW, no down votes from me.
sims
A: 

Facebook does very little more than update and read from a database so php is still a valid choice. But if you're building something that needs to build some kind of complex custom data structure and keep it in memory, I think you'd be better off using something like scala or another language that doesn't have to reprocess everything with every page refresh.

My biggest problem with php (5.3 at least...) is not the ugly syntax, nor the unwieldly, inconsistent giant function list. I'm just getting really fed up with the statelessness and rebuilding everything with every click.

Michael Clerx
There are compilers and caching tools for PHP available. Statelessness? What about session variables.
doc
Say you select a 1000 rows from a database to build a menu, then next time the user clicks a menu item you have to reselect them and build it all over again. Yes you can avoid this overhead with session variables caches etc, but it's not the default way of doing things.PHP is based on the idea of a templating engine, you request a document and before you see it it gets parsed into something nicer. Compare this to a normal, non-web application where everything is just kept in memory while you decide where to click next.There's languages that bridge this gap.
Michael Clerx
Selecting 1K rows from the db and then just doing it again on the next page load is just poor programing
Swish
Sigh. Fine so it's a bad example. There's many reasons you'd like to keep some data in memory (some user specific data, or some shared data like a search index) and while PHP allows it, it doesn't make it easy or straightforward.
Michael Clerx