A FACEBOOK.com engineer said:
How do Google and Facebook keep their source code secure when hundreds of staff members have access to it?
Used to be an engineer at Facebook.
Pretty much nothing physically stops you from copying and pasting the code, and sending it to yourself.
The legal & career repercussions for doing this would be severe.
Also, most of the code isn't really that cool on its own. It's not like you can just copy paste FB's code and have Facebook. You need all of the data that the algorithms use, infrastructure, and much more.
And as others said, some of the security measures are more locked down, and a lot of the employees (including many engineers) never need to interact with them (i.e. encryption)
Also, you only code on FB's codebase on your work computer. There's pretty much no reason for the code to ever leave your work computer - so code doesn't really just "leak" over time.
Edit: If you searched hard, you probably could find snippets of FB code on Stackoverflow when employees ask questions. But after the first few weeks on the job, any engineer would realize they should anonymize the code.
I think I might have pasted 1 or 2 raw snippets of PHP on the first few days I was learning code at FB, and actually got some people to reply on StackOverflow saying "what the hell kind of PHP is that"... turns out I was pasting snippets of "Hack", our at the time very secret language.
A GOOGLE.com Engineer also revealed:
The Google code base is huge, like super-huge, like your-head-will-explode huge. Additionally, the code base is geared for running large distributed systems on the production infrastructure Borg and on Google’s uber-network infrastructure.
Basically even if a Google employee took some code it’d be worthless without the rest of the codebase that Google runs on. There are so many dependencies that you couldn’t just take one thing without needing a whole bunch of other things, and then by that point someone would notice the copying attempt.
Not to mention that you would have nowhere to run it on because it’s likely you wouldn’t have access to a world-scale distributed system that would benefit from the code.
The whole effort is even made more pointless given that Google open-sources many of its valuable tools and projects (ie. one example out of many - The Chromium Projects).
Heck if you really wanted Google infrastructure you might as well save yourself the trouble and just make an account on Google Cloud Platform. Then you’ll have vast swaths of the Google infrastructure at your fingertips, and vast amount of Googlers working on improving your infrastructure and making sure it stays up.
So, now you know it isn't possible to copy or duplicate codes used in creating Facebook and Google.
Have a nice day programmers.