Live data from Hacker News

Facebook PHP Source Code from August 2007

gist.github.com

61–70 of 99 posts

Re: Facebook PHP Source Code from August 2007

#61
post #52

From the article linked in the gist: > This leak is not good news for Facebook, as it raises the question of how secure a Facebook users private data really is. I don't even think I need to comment on how poorly this has aged.

Could you elaborate? I thought it was an amazing foreboding of exactly how poor Facebook turned out to be with handling user privacy

Re: Facebook PHP Source Code from August 2007

#62
post #45

Can someone explain to a newbie why this code is so bad? Reading through it it seemed to generally make sense and not be too complicated.

It's decent as far as 2000s era PHP goes. If you want to poke your eyes out, look at the source of some of the PHP web forum software out there. The leaked code ignores pretty much all design patterns and software architecture norms. But not having to deal with that, and being able to cobble something together in a hurry, was the appeal of PHP. You can always rewrite later. Nowadays Facebook's landing page is served…

It seems to me (with absolutely no experience) that architecture and design patterns are more trouble than they're worth for code in the low thousands of LoC, which this appears to be.

Re: Facebook PHP Source Code from August 2007

#65
post #40

Earlier quoted context omitted.

This sounds very counter-intuitive! Did you hear this from someone working at Facebook or did you read it online? If it's the latter it'd be great if you could share a link!

What is counterintuitive about this? That best dynamic programmers are the absolute best programmers? I mean come on man..

Seems like pretty clearly GP isn't familiar with the definition of dynamic programming in this context: https://en.wikipedia.org/wiki/Dynamic_programming

Re: Facebook PHP Source Code from August 2007

#67

Earlier quoted context omitted.

I didn't read it carefully and I don't know much PHP, but is the code really that bad? There's all kinds of worse code out there running everything. As long as it's relatively well organized, you can worry about refactoring as you scale up.

"relatively well organized" is the problem. It's written in a fairly unstructured imperative style that's perfectly suitable for short scripts, but even these relatively small pieces of code are outgrowing it. The extensive use of global variables is an obvious thing that I would expect to become a problem soon. It's much less of a problem in php than in most other web frameworks due to the design of handling each HT…

> By the standards of 2007 PHP this is good code

By the standards of early 2004 (when Facebook was originally written) this is still mediocre PHP. People who cared about writing good PHP were reading magazines like this (2003):

https://www.phparch.com/magazine/2003-2/june/

and having discussions like this (2004):

https://www.sitepoint.com/community/t/to-hopefully-clear-up-...

They knew global variables and hundreds of lines of top-level code were bad PHP, they just didn't know yet that trying to ape Java wasn't good PHP. If I remember correctly, DHH came out of this period: he got so sick of enterprisey PHP that he jumped ship to Ruby and wrote Rails. That was 2005.

Fair enough that Facebook hadn't done a major rewrite by 2007, but still: not good code.

Re: Facebook PHP Source Code from August 2007

#68
post #51

One way to look at this is to say "Hah, how shameful." The other way to look at this is to say "Hah, clearly business success isn't a function of code quality"

>"Hah, clearly business success isn't a function of code quality" They aren't nearly as strongly correlated as many developers might like to believe.

I prefer to think of it as "perfectly coded" projects have 0 commercial value until someone figures out a customer for it.

Re: Facebook PHP Source Code from August 2007

#69
post #52

From the article linked in the gist: > This leak is not good news for Facebook, as it raises the question of how secure a Facebook users private data really is. I don't even think I need to comment on how poorly this has aged.

Could you elaborate? I thought it was an amazing foreboding of exactly how poor Facebook turned out to be with handling user privacy

That's basically what I meant, sorry. It's an insight into what could have been a problem back then, and clearly became a serious problem.

Re: Facebook PHP Source Code from August 2007

#70
post #40
post #15

Earlier quoted context omitted.

Dynamic programming questions are explicitly not used in current Facebook interviews. From time to time, Facebook and other companies study the effectiveness of their hiring process by comparing employee performance and interview performance. I believe dynamic programming questions were removed because there was not a strong link between success in this question and future performance.

This sounds very counter-intuitive! Did you hear this from someone working at Facebook or did you read it online? If it's the latter it'd be great if you could share a link!

I don't know of any online links to point to but I am an active interviewer at FB and I know we don't ask DP questions
Post reply on HN