facebook : php (but I think a while back they announced that they use a custom version of php that they created in-house) twitter: ruby on rails
also note that knowing the language they use is only scratching the surface - there are whole fields of other things eg infrastructure, scaling, security, spam, etc
Facebook and Twitter use PHP, though Facebook compiles the PHP in a different fashion, it is done by converting it to C i believe that reportedly is 80% more efficient. Most are done nowadays in PHP as it is a very broad language with a solid developer base. ( at least that is my opinion ).