Tuesday, February 8, 2011

The Social Network: (In)accuracies regarding the Computer Science

Typically, movies that have any relevance with computing or technology tend to irritate me, regarding technological accuracy as well as the overall atmosphere and attitude of characters. One may think that movies involving technology would be my passion, but I've spent so much time with actual technical people that I always find their portrayal in film a bit off.

I recently got a chance to watch 'The Social Network', and I found that overall it was a great film. I expected this much, as it had a great cast, an excellent director (Fincher), and a score produced by Trent Reznor, of all people. I had been apprehensive about seeing it because I knew there would find fault with the way it represented technology in some way. I also felt that Facebook was still too young to warrant its accolades in film, and that this was a cheap way to cash in on its popularity. A movie about a web site that I barely care about didn't seem to have it's appeal to me.

I wound up loving the atmosphere it created, and I mostly liked the portrayal of the characters and the programmer mindset. In many ways I was taken back to my recent CS education, I saw many parallels between Mark's character and my own as a student. The time spent in labs, the endless barrage of projects.

However my initial hesitations remained correct, there were things that did bother me. Much attention has been paid to how the movie has it's inaccuracies in terms of the people and company being portrayed, and I don't want to rehash that. (Though, for all the talk about this movie NOT being a documentary, I was surprised when Mark Zuckerburg's character was actually called 'Mark Zuckerburg'. Similarly, the company was actually Facebook, etc. I incorrectly assumed that the names had all been changed to protect the innocent.) The things that get to me are technical. They're mostly pedantic in nature, and I understand that. Still, in much the way a medical professional cringes when they may watch anything involving medicine, or the way how the screen portrayal of crime & justice is at best a parody of reality, as a programmer it's hard not to focus on what is off in a movie like this instead of just enjoying it.

There was a lot that I did feel they got right, though. I think in a sense they managed to capture the feel of a tech start-up, to the best of my knowledge. That shift between a personal project into a commercial endeavor. They used a (modified) version of Mark's real LiveJournal posting of that day to describe his little Facemash activity. The content of the message felt authentic (because it was), but the delivery perhaps not so. I've never heard anyone talk like that, but I've seen people write like that. Hard to describe to a non-programmer, but the dramatic inflections were just.. off. Overall I liked that it showed how the youngest billionaire started out with that hacker ethic, but they perhaps got his motivation wrong. As Mark Zuckerburg has pointed out, it's hard for people who are not programmers to understand the desire to build something for the sake of creating it, and Hollywood went out of the way to imply that his creations were for the sake of women and money. Never mind that the real Facemash featured both men and women, but I digress.

I paused the screen to see the software that Mark was using, and we got nice KDE desktops on a presumably Linux-based system. Appropriate versions for the era, too. No one set background images, though, odd. Mark does mention that he was using Mozilla as a browser, while we see the default KDE's Konquerer on his screen. Producers probably too lazy to find the appropriate antiquated version and have it installed. Plus this flashes by the screen for only a few frames.

Mark uses Emacs (yay!) and we see that throughout. We see a bash session where it looks like he installs a 'php-elisp' package (appropriate) and tries to run Emacs twice. I can't recall the errors but I think they were just console warning messages that would display on run. Now, he does say he's writing Perl, but we can assume he was well versed in such, and only installed Emac's PHP package as part of his struggle to understand one of the dorm's face-book's that he complains about.

Most technical things in the film were correct, but again I mention that the delivery of these technical subjects just felt odd to me. "Give me the algorithm!!" isn't really something that I've heard myself, although yes, algorithms are an integral part of Computer Science and it's neat that we saw some emphasis. Mark probably would have just looked it up in his text, or asked a friend politely. The Hollywood way to do it was to write it on a dorm window in wax pencil, it reminded me of the over-the-top depictions of NORAD in film, where everything is written on upright sheets of glowing glass.

There was the scene where mark asks for an additional LAMP server, which in reality I don't think he would have enumerated the acronym in the way he did. The line there seemed like a forced attempt at authenticity, but the dramatic reading of "Linux, Apache, MySQL" was off.

Those "He's plugged in!" lines were ridiculous too. It's not the Matrix, I've never heard of software engineers at a system being referred to as being "plugged in". Although it's true - don't interrupt someone when they're writing code - they're on a roll.

I realize I'm being pedantic here, and so I don't really fault the movie for it. They have to make the topic exciting, after all. I just find it personally distracting to see my field portrayed the way it is, and that is why I have a hard time watching movies like this. The Net, Antitrust, Swordfish, it's always a similar story for me. The Social Network is the best so far, but they were still off.

The scene that went over the top was the Hacking competition scene. Now, I've been involved in ACM programming competitions, and I've seen a few hacking competitions. I don't know how they do things at Harvard but that was ridiculous. Real hacking competitions are lengthy, and while they may involve a few beers they are not drinking games. The audiences are also a few notches toned down, or nonexistent. It makes for a poor spectator sport. Milestone results are generally posted onto some bulletin, where people can check in periodically. Programming is an intense intellectual discipline, and few people have the tolerance to maintain enough composure after two shots to get any real work done. Let alone 8 shots. The programming competitions I've been involved in had zero spectators, lasted a few hours, and almost no one spoke. You would have thought this scene was a wrestling match.

The scene that really got to me was the OS lecture scene. The professor asks the course a question, to which no one can reply. Mark leaves the course, is insulted for doing so, and then casually gives the correct response. This is a trope I've seen a number of times before, we get to see a nice contrast between Mark's intellect and his attitude. Of course, when I hear a question being asked in this film, my mind will scramble to come up to an answer. When I could not follow the discussion, this was frustrating. I rewound that scene three times, trying to understand what the actual question being asked was, and how the answer relates. Confused, I turned to the internet to find any technical discussion on this scene and turned up in failure. I did not find any (hence the inspiration for this blog post), but I did find the original film's script for the scene. Continued searching revealed the actual Harvard CS161 lecture notes to a 2007 course. Let's compare:

Script:
MARK is in his Operating Systems class. This is considered the
hardest class at Harvard and MARK is one of the 50 students
with their laptops open as the professor takes them through an
impossibly difficult lesson.
PROFESSOR
Okay, let’s look at a sample problem:
Suppose we’re given a computer with a 16-
bit virtual address and a page size of
256 bytes.
A GIRL scribbles something on a piece of paper. Then hands it
to the student next to her and nods that it should be passed
over to MARK. While that’s happening--
PROFESSOR (CONT’D)
The system uses one-level page tables,
that start at address 0x0400. Maybe you
want to have DMA on your 16-bit system,
who knows? The first few pages are
reserved for hardware flags, etc.
MARK opens the note. It reads “U dick”.
He looks over and sees a couple of GIRLS looking at him with
contempt.
PROFESSOR (CONT’D)
Assume page table entries have eight
status bits.
MARK closes his laptop, gets up and starts to head out of the
hall.
PROFESSOR (CONT’D)
The eight status bits would be--
(re: MARK)
And I see we have our first surrender.
PROFESSOR (CONT’D)
Don’t worry, Mr. Zuckerberg, brighter men
than you have tried and failed at this
class.
MARK
(calling back)
1 valid bit, 1 modify bit, 1 reference
bit and 5 permission bits.
PROFESSOR
That is correct. Does everybody see how
he got there?

Lecture Notes:
Computer Science 161: Operating Systems
Processes, Scheduling, VM, Writing a Design Doc
CS161 Course Staff
...
March 8, 2007
...
3 VM
VM is one of the most useful things you learn in this course, since probably for the first time you no longer need to be surprised by the “magic” the operating system provides. It’s also one of Matt’s favorite topics, and so will appear on the midterm. This wouldn’t necessarily be a great reason to really learn it, but you also have to implement it so understanding what’s happening sooner rather then later will save us all a lot of trouble.
Key terms: page table, MMU, TLB, TLB miss, page fault, page frame,
internal fragmentation, external fragmentation
A sample problem: Suppose we are given a computer with a 16-bit virtual
addresses, and a page size of 256 bytes. The system uses one-level page tables, which start at address 0x0400. (The first few pages are reserved for hardware flags, etc. Maybe you wanted to have DMA on your 16-bit system, who knows?) Assume page table entries have eight status bits: 1 valid bit, 1 modify bit, 1 reference bit, and 5 permissions bits (this is a very secure system).

*How many pages are there? How much memory do the page tables require?

---
One of these is clearly derived from the other, obviously the former was lifted strait off of the latter. In a way this is cool, to have dialog in a movie taken from the actual course it's supposed to represent, but the delivery was botched. I mostly liked what the scene was supposed to be, there was a slide with an MMU on it, and what appeared to be the mapping of virtual memory pages to real memory. This would have been a very relevant slide for the topic under discussion (Virtual Memory). Now, having seen the original source to the dialog in this scene, the question makes sense. Or rather, it makes sense to me why the question makes no sense at all.

In the lecture notes, the professor is describing a hypothetical system, while providing additional irrelevant commentary in describing it. (Everything in parenthesis.) In the film, the entire question is delivered with an inquisitive tone, including the bits that are not inquisitive. Then the killer is that the actual question about paging is never asked in the film, but rather the professor asks about the assumptions in the page table entry. The problem is that the fact that this hypothetical system used one valid, one modify, one reference, and five permission bits is made up, just as a demonstration. There is no way to infer this knowledge from the question being asked. Unless the students had read the mind of the professor, or had notes printed out, no one could know.

Mark is not giving an answer to a question, and the professor hasn't even asked one. Mark isn't even giving critical details to the question, but rather just the embellishment part of the question. The actual question that would have been asked, is never asked in the film. ("How many pages are there? How much memory do the page tables require?") This is the question I was anticipating, recalling the sorts of problems faced in my own system arch and OS courses regarding paging.

I may as well go ahead and answer it. To the best of my knowledge, this means that we have a system capable of addressing 65536 bytes (2^16) of memory. Divided into 256 byte chunks, that means we have 256 pages on the system. (8 + 8 bits, in other words) Since each of these 256 pages requires a one byte page table entry (As mentioned, the 1/1/1/5 being irrelevant), that means our page table is an even 256 bytes, fitting nicely into the first page (of the four reserved for system, 0x0400 being the first 1K of memory). The breakdown of the 8 bytes is inconsequential for our example, it is extraneous information. It is mentioned just as a hypothetical. (More so to keep things at a simple one byte entry.)

So long as I'm not overlooking something, this question is actually pretty tame, I suspect it to be a feeler question used to introduce the topic to students in CS161. Even if I'm missing something in my answer, that's outside of the point that this dialog was seriously botched.

What's truly frustrating about this scene - and why I don't feel that I'm being pedantic in saying so - is that the entire purpose of this scene is to illustrate Mark's brilliance, by having him giving a correct answer to a difficult question. But they got it so wrong, he's uttering nonsense in the context of a non-question. To anyone familiar with the material, no, we *don't* see how he got there. They seem to have worked very hard at creating some level of accuracy, I'm surprised that no one pointed this out. They certainly had some technical reviewers.

It is acceptable and forgivable when a film has technical inaccuracies hidden in the background that are displayed for a single frame, the fact that they happen makes sense. But gaping holes like this just gut this scene. It hurts personally, because it ruins what could have been the first, best, and last scene in a major motion picture that takes place in a computer science OS lecture room. I appreciate it when a movie features characters outside of those that are familiar to Hollywood, (Usually menial service industry tasks and the movie industry itself.) and it's an opportunity for people to peer into the lives of others. I and most other programmers feel that the discipline is not well understood outside of the field ("You like, know how to fix computers and use Photoshop, right??") and here was the shot to get a glimpse of reality. Perhaps some of the character of the lecture was accurate, but the material was insulted in a way, by not checking its accuracy.

Imagine a professor asking a question in a math course,

Professor -- "One train is leaving City A at 100km/hr, towards City B. A second train leaves City B at.. anybody?"

Student -- "160km/hr!"

Professor -- "That is correct. Does everyone see how he got there?"

"???"

Lastly, the OS lecture had way too many girls in class. It's a well discussed issue among CS educators that for some reason the field is dominated by men, it is a profession that is 95% male. No one really knows why this is so, and why the related field of mathematics has women outnumbering men in many places. If only my classes had that many women in them. (Not for personal reasons, of course, but for egalitarian reasons.) Discussion online has corroborated this, students that have taken CS161 at Harvard agree, mostly dudes.

20 comments:

  1. Lol, thanks for the insight! I was just watching the movie and had to google this "problem". It seemed a little fishy. You can tell they put a lot of effort into authenticity, but I guess this one fell through the cracks.

    ReplyDelete
  2. Wow, lifted straight from the course outline. Yeah, i thought there was a major disconnect.

    Doesn't the lecturer say 'Hex' 400 in the film? What does this mean?

    ReplyDelete
  3. Sorry for the "thread hijacking", but I left you a (desperate) comment in your previous post. I really need some info about your EeePC. You have the same model as I do, so your info would be preceless to me...

    Please read my other commennt in previous post.. or contact me directly:

    Email: rodrigosilva@rodrigosilva.com
    IM (MSN): mestrelion@hotmail.com
    Skype: mestrelion

    Please, youre my only hope!

    ReplyDelete
  4. As a fellow programmer I had a very different reaction to many of these inaccuracies. To me they felt like easter eggs; the film winks at those with the *insider knowledge* to catch them. I don't think it's fair to use the "train leaving at n km/h" analogy, because the error is only going to be visible to a minute percentage of the audience.

    In other ways I am right with you. In particular, the various techniques used to amp-up the excitement of watching people write code were artificial and will probably look worse as the film ages. It has a certain effectiveness in creating a pulpy, fantastical mythology surrounding Facebook as this enterprise where only self-destructive supergeniuses capable of penetrating the most intellectually rigorously programming challenges while utterly inebriated may abide.

    In that, I think it also betrays the fact that Mr. Sorkin really views this whole phenomenon with some degree of contempt. Facebook is more Zuckerberg's vanity project in the film, which therefore doesn't treat with any serious cultural ramifications of social networking. Possibly it doesn't believe they exist.

    Thanks for the very interesting and informative article.

    ReplyDelete
  5. Hex 400 means 400 in hexadecimal numeric System where 16 is the base. We are used to decimal numbers where each digit represents a power of ten. Sample: dec 400 means 4 * 10^2 + 0 * 10^1 + 0 * 10^0
    In hex the base is 16 so hex 400 is 4*16^2 + 0 * 16^1 + 0 * 16^0 = 4*256 = 1024 which is also know as 1 kb (kilobyte)

    ReplyDelete
  6. The answer to the "real" question doesn't matter very much, as you point out, but you don't need PTEs for the system area below x0400 (4 pages), or for the space taken up by the PTEs themselves (less than a page). Note that it says that the page table starts at 0x0400 - it's not placed in the system area. So you need 251 PTEs.

    ReplyDelete
  7. I agree there were a few too many girls, but especially what was unrealistic was the lack of Asian girls. The class should have been like 25% female and 80% of those should have been Asian. For some reason to most white guys this translates into the class being 95% male :)

    ReplyDelete
  8. I'm a bit older than the average here, no doubt, but I thought it was generally a simplistic, bubble-gum, lame ass movie.
    Your finding here about authenticity and attention to detail further my disgust.
    How about the unanswered question of whether the girlfriends might actually be call girls, due to the over reaction of the one actress in the 'napster founder dinner' scene?
    I gave up on the movie after the initial coding scenes in the dorm room. It started out with a lot of potential and just became a movie that operated solely on the surface.
    The director's audio track was the worst i have ever listened to. It was an edited narrative between four different players in the movie. They even bleeped out whatever was originally going to be used in the 'u dick' message scene. I will have to see what studio released this movie, as to avoid their product in the future.
    Further, if any of you are from a cold clime, how sad was the outdoor scene where the actors' 'breath' was portrayed. How technology has not improved since this special effect was introduced last century in "Titanic".
    Only remarkable feature, apparently while the twins were played by actual twins, one twin's face was the primary one used and mapped on the second twin's body, i'll give a little credit there, but it's not enough to redeem this idle time waster.

    ReplyDelete
  9. Thanks for clearing this up. The CS161 information was just what I was looking for. I thought that "question" was askew.

    ReplyDelete
  10. Haha this is great. Thanks for pointing out the ridiculousness of that scene. I was googling trying to remember what question Mark was asked in the movie and came upon your blog.

    ReplyDelete
  11. I wanted some article exactly like this on the movie "The social network". Thank You author.
    "Typically, movies that have any relevance with computing or technology tend to irritate me", well, same here too. Would you suggest me some more movies which are relevant to computers and technology?

    ReplyDelete
  12. Hey, you are totally right. I just was shocked at the portrayal of my field (our field ) c.s this way in a hollywood movie. That was really not a question at all, for he just guessed the bits and not at all derived those from any hint!!!! retarded show :P

    ReplyDelete
  13. Thank you. I enjoyed reading every line of this blog post.

    "To anyone familiar with the material, no, we *don't* see how he got there"

    Haha!

    "he's uttering nonsense in the context of a non-question."

    Made my day

    ReplyDelete
  14. Great read. BTW, it's Zuckerberg not Zuckerburg.

    ReplyDelete
  15. It's called: " A Movie"

    Get over it.

    ReplyDelete
  16. Whoa! Good read here, haha I can tell you were on a good one when you wrote this!

    It IS Hollywood and I can guarantee if a coder wrote the script it would be written in c+ and would not be as entertaining. They should of hired some better consultants though, but on the other hand how else are you going to make a person staring at a text editor, going "tap tap tap tap tap" on a keyboard exciting?

    BTW It WAS annoying that they didn't just say "LAMP", BUT it would of been more ridic if they said:

    "Linux, Apache, MySQL, Hypertext Preprocessor"

    Than I would official face palmed

    ReplyDelete
  17. Hey there! Just figured you would like a little inaccuracy lifted :D As somebody who has taken 161 within the last 2 years, a few notes:

    1) The question made no sense, yeah
    2) There actually is a high percentage of girls in CS at Harvard; something like 40% of people who take the intro class, and maybe 30-40% of all CS majors; in CS161, there are probably 20% girls.
    3) The classrooms are not designed like in the movie; while we have a few large lecture halls for our biggest classes, 161 has a flat room where students sit at tables of 4 in order to interact with each other on difficult problems, with each table having a white board next to it.
    4) At first I thought they got the gender of the professor wrong, but it turns out the wonderful Margo Seltzer has not been teaching as long as I expected

    In any case, most of these only apply to the last 5 years (since CS50 boom of Harvard), not to when Zuck was here, so who knows if all of it was the same!!

    ReplyDelete
  18. It may not have been from your personal experience, but that's why he's the youngest billionaire in the world. He doesn't exactly walk the same line that the rest of us do. I'm not lifting him up at all, because I really don't admire the guy at all, but there is something undeniably different about the guy. I wouldn't doubt at all some of the "I'm plugged in" lines and the hack-a-thon drinking games. True programmers don't just create on a computer. They create everything around them. Look at every big name and you'll start to see it. The mediocre programmers are the ones who think inside a box and tell everyone how good they are, when in reality, they know that they can never achieve anything really great. It's just how it is.

    ReplyDelete