Live data from Hacker News

Facebook PHP Source Code from August 2007

gist.github.com

81–90 of 99 posts

Re: Facebook PHP Source Code from August 2007

#81

Amazing that they initially wrote this code and now to join FB you need to answer questions based on backtracking and dynamic programming. :) I wonder if they could do the questions themselves back then.

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.

It is 12 years old - these were just before the first versions that had any kind of serious OO capability, however most apps were already built in the "Imperative" style that this is.

The hate for PHP on that gist is strong - admittedly back in the early noughties it wasn't fantastic but it was the shortest route to getting a functional website put up. PHP was simple and had a very low barrier to entry.

Latest versions are much better - The speed is one of its biggest draws, since version 7 it has taken the crown as fastest interpreted language, I believe version 8 will improve on this even more

Re: Facebook PHP Source Code from August 2007

#82

Earlier quoted context omitted.

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

Key takeaway:

> It also has a very interesting property as an adjective, and that is it's impossible to use the word dynamic in a pejorative sense. Try thinking of some combination that will possibly give it a pejorative meaning. It's impossible.

How times have changed!

Re: Facebook PHP Source Code from August 2007

#83
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 work as a programmer in the games industry and I’ve noticed that frequently as well. Commercially successful games aren’t always a strong indicator of code quality and often it tends to be that the bad code “luckily didn’t matter” in cases of success.

Re: Facebook PHP Source Code from August 2007

#84
post #2

It wasn't actually stolen as it says in the README. It was a misconfigured Apache server which leaked raw, unprocessed PHP code. I received the code to home.php and profile.php but I didn't save it at the time (I was very very new to learning PHP and didn't realize the significance of what I was looking at). Still really cool to see.

Same happened to me.

I knew the significance the moment I saw the `<?php` but force of habit, I had already pressed shift + F5 by the time my brain registered. Somehow never got the code again, maybe some sort of load balancer was leaking something that was cached but just barely.

Re: Facebook PHP Source Code from August 2007

#85
post #79

> is line 89 of search.php valid?? "$user 0 && ..." ? aren't we missing an comparison operator? Good job. And perhaps that's the culprit. Everybody assumed it was a plain syntax error, but I don't think it's possible. Rather, it seems me that: if ($user 0 && ...

not sure what the reason was, but it's simply a missing >. other files were leaked, and you can see the same pattern elsewhere: if ($user > 0 && is_unregistered($user)) searching the web for this comment might be helpful if you'd like more source code: $user can be

This might be due to the code pasted in some markdown editor at a point. This often strips the characters.

Re: Facebook PHP Source Code from August 2007

#86

> is line 89 of search.php valid?? "$user 0 && ..." ? aren't we missing an comparison operator? Good job. And perhaps that's the culprit. Everybody assumed it was a plain syntax error, but I don't think it's possible. Rather, it seems me that: if ($user 0 && ...

Maybe. I think that's less likely than syntax error, for two reasons. #1, if you look in index.php, there's a on line 258, correctly rendered. Granted, the #2, if you look at the surrounding code, $user > 0 makes logical sense given what the code is doing (and assuming 0 represents an invalid/nonexistent userid, which I believe it does given that facebook userids increase monotonically).

Except that a syntax error isn't likely at all - this was production code.

BTW just running "php -l" would have nailed this error - PHP refuses to run a script that cannot pass the tokenization step, resulting in a blank page (and the error being logged), so such a macroscopic error would probably be short-lived even in their test environment.

Re: Facebook PHP Source Code from August 2007

#87

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"

Business success isn't a function of technical/artistic quality in any field. There's a loose correlation sure, but there are hundreds or thousands of examples where poorly written/made books, TV shows, music, films, games etc also did really well commercially as well as the opposite. Many would say something like Firefly is better than something like Twilight, but one made millions of dollars and the other got cancelled in two seasons.

Knowing what to make and who to market it to will usually matter a lot more than how you build it.

Re: Facebook PHP Source Code from August 2007

#88
post #41

Earlier quoted context omitted.

are you?

Does it matter? How is a random person on the internet sufficiently qualified to define theft in a complex domain like digital copyright and intellectual property? You don't have to be a lawyer to be skeptical of what someone says online.

My point is if they replied “yes” where would you be? It’s not inappropriate to be skeptical but asking a person for credentials online is next to useless.

Re: Facebook PHP Source Code from August 2007

#89
post #88

Earlier quoted context omitted.

Does it matter? How is a random person on the internet sufficiently qualified to define theft in a complex domain like digital copyright and intellectual property? You don't have to be a lawyer to be skeptical of what someone says online.

My point is if they replied “yes” where would you be? It’s not inappropriate to be skeptical but asking a person for credentials online is next to useless.

Even if they were a lawyer, lawyers are frequently wrong in their interpretation of law, which is why they argue the relevant points in court, and a judge gets to decide which of them is right.

Re: Facebook PHP Source Code from August 2007

#90
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 exactly understand why this is getting downvoted, I'm genuinely curious if companies have published anything on that.

Also for me, it _is_ counter-intuitive, since DP was one of the hardest things for me when I started with programming, and I'd at least expect a non-trivial correlation between being good at DP and job performance, that's why I was asking about where I can read more about this.

Post reply on HN