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.
There was a point in time (roughly 2015-2016 timeframe when dynamic programming interview questions were really in vogue. Every interview loop from smallish startup to leviathan corporation felt like it had at least one.
Facebook PHP Source Code from August 2007
71–80 of 99 posts
Re: Facebook PHP Source Code from August 2007
#72> 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 && ...
#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).
Re: Facebook PHP Source Code from August 2007
#73Re: Facebook PHP Source Code from August 2007
#74Earlier quoted context omitted.
The lack of `chroot`[1] makes me sad off the bat - for some reason that function seems like a secret, everyone actually wants to use it (or wanted to before autoloading became as easy as it is) but nobody did. Additionally I'd love to see that file split up into smaller chunks simply to lower the scope of thought. It looks like nearly all of those function calls are modifying variables passed by reference instead of…
`chroot()` has no place in a web application. The system call requires the process to be running as root.
Re: Facebook PHP Source Code from August 2007
#75Can 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 not really bad for the time it was written, but today you wouldn't want to write PHP code like this. Lots of global variables that can clobber each other (if one bit of code, even in one of the includes, redefines $user, everything explodes), no classes, no code autoloader...
Re: Facebook PHP Source Code from August 2007
#76Earlier quoted context omitted.
I used to know PHP, and this code is very indicative of the imperative style that was popular during that era. I believe the PHP crowd has mostly gone deeply into OOP. With that said, Facebook mostly worked remarkably well. My bank, on the other hand has their web presence written in Java. And it works about 80% of the time. Sometimes one just has to try twice. So, "good code", "bad code" will always take a back seat…
So the bank would be better of with php?
But, no, that's not at all what I'm saying. I'm saying, one language is extremely well thought out, and offers great guard-rails for doing OOP very well. And yet, the code is broken enough that sometimes I just have to give up on getting my account balance. Yet, Facebook from that era typically "just worked"... except when it didn't, and everyone would lose their minds. My point was, code that works, even if ugly, is what the customer cares about.
I'm still on the fence if I'd recommend anyone use PHP... Swoole performs very well. Laravel has a great community. It's not my cup of tea but, I try to keep an eye on it.
Re: Facebook PHP Source Code from August 2007
#77Earlier quoted context omitted.
`chroot()` has no place in a web application. The system call requires the process to be running as root.
Can you call that and then drop permissions?
Re: Facebook PHP Source Code from August 2007
#78Is this Mark Z's code? Wonder why he didn't use a framework and went with pure PHP.
I was also writing some spaghetti PHP code around 2007 and remember making choices that were the benefit of reducing server stress while making my life harder. No framework was a big one.
Remember, Friendster died due to crashing and Facebook, for all its spaghetti code at the time, was remarkably solid and rarely crashed. It is easy to forget how hard the sysadmin side was for a growing startups before we could spin up infinite cloud servers and VC wasn't just an open spigot for anything with growth.
Remember the fail whale on Twitter?
Re: Facebook PHP Source Code from August 2007
#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 && ...
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 Re: Facebook PHP Source Code from August 2007
#80Earlier quoted context omitted.
You don't have to be a lawyer to understand that subtraction and multiplication are two completely different operations.
If you're a mathematician and not a lawyer you might think those are different operations. But lawyers, judges, and juries have a unique capacity to argue that you're guilty of subtraction even if you only multiplied. To a lawyer, bits have color: https://ansuz.sooke.bc.ca/entry/23 .