6

In Ex Machina, towards the end of the movie, we see Caleb hacking the system of the building to reverse the door mechanisim, and if you pause the movie at the right time, you could see that he is writing in a language not too different than C++ or Swift.

The code he writes is a function that finds prime numbers. Not sure what that has anything to do with hacking the system, but for the sake of argument, we will assume it is required by a complex function within the hacking procedure.

What really caught my attention was the comments he wrote before the function declaration. I know the comments are supposed to describe what the next bit of code is intendded for, and I know that the written comments have nothing to do with finding prime numbers, as expected because they are meant for the movie audience to let them know that he is writing some hacking code.

However, a hacker would never leave evidence of his "crime". Meaning: he would not write any comments that would give away his intentions, and second: he does not have time to write comments. The only reason someone might want to leave comments in code, is if they are expecting someone else to read the code later and be able to modify the code (enhance, update, etc). Neither of which is the case in Caleb's situation.

So why did Caleb leave comments in his "hacking code"?

  • 3
    I think the producer of the movie thought: hey commented code looks fancy and more complex! Use it in the movie. – Charmin May 25 '15 at 16:21
  • 7
    You explained it in your question: because they are meant for the movie audience to let them know that he is writing some hacking code.! – Möoz May 26 '15 at 1:44
  • I don't know how many people looked carefully at what he was writing (I didn't) I just assumed he's messing with the system and that I will see the effects future on. There are not a lot of people who have at least some general knowledge of programming. My guess is that those comments are like a caption for I'm hacking into the system so people think it's cool instead of boring nerdy stuff. – Alexandru Cimpanu May 26 '15 at 10:21
  • 3
    Oh come on.. it is a given that 99.99% of any code you see in a movie doesn't remotely do anything that it is supposed to. Why are you even surprised at this? – bobbyalex Jun 5 '15 at 9:25
  • 1
    Disregard my last comment, here is the answer very cool actually, it is a secret Easter egg: reddit.com/r/movies/comments/365f9b/secret_code_in_ex_machina – user31351 Feb 19 '16 at 0:45
9

In the film Nathan says to Caleb "you're pretty good [at coding]".

"Pretty good" coders comment their code.

As for leaving evidence of a crime, that was going to happen outside of the code anyways. The fact that she'd escape would prove that she was true AI. Any 'crime' was going to be rather irrelevant at that point.

  • Considerate coders comment their code. I hate looking at someone else's code and wonder what the hell they are up to and spending the best part of the time unravelling it – Cearon O'Flynn Jan 21 '16 at 15:23
  • I'd also imagine that there would be a 'production' version of the code that has been minified and obsfuscated - which would remove the commenting anyway... – Pat Dobson Jul 4 '16 at 11:22
4

Well, this might not be the most "plot-coherent" answer, but it sure is the most obvious one and the one you have already given in your question: Because it looks good and nobody cares about the specific code he writes anyway.

You already reasoned how the specific code we writes, something that just enumerates prime numbers, has absolutely nothing to do with what he wants to achieve and was simply chosen to just show him write some code the audience neither cares about, nor understands at all to a great majority. So it then stands to reason why one would care what or if he writes any comments in that code. It's just that comments generally belong to code and make it look visually coherent.

As much as the actual code he would write, the elaborate thoughts if he would take the time and effort to write comments were way beyond the filmmakers at this point, since the code itself is not accurate in the first place and noone in the audience would ever care about it to that level.

4

you could see that he is writing in a language not too different than C++ or Swift.

It's Python, and it annoyed me at first that they were just showing some irrelevant "Hello world" code on the screen, when all the other technical details in the script were pretty plausible.

But it turns out there's more to it than just being irrelevant to the plot; it's actually an intentional easter egg. When run, it prints ISBN = 9780199226559, which is the number of a book about consciousness/AI that the director wants you to read:

Embodiment and the inner life: Cognition and Consciousness in the Space of Possible Minds 1st Edition

So the superfluous comments are kind of a moot point.

  • You might still want to adress the actual question about why he writes code with comments, though. Wow does this interesting tidbit make the superflous comments a moot point? – Napoleon Wilson Jul 4 '16 at 9:25
  • 1
    @NapoleonWilson Because the code has nothing to do with the actual scene – endolith Jul 4 '16 at 12:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .