Why would Caleb write code with comments?

Why would Caleb write code with comments? - From above crop faceless male developer in black hoodie writing software code on netbook while working in light studio

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"?



Best Answer

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.




Pictures about "Why would Caleb write code with comments?"

Why would Caleb write code with comments? - Crop anonymous person with vision loss writing braille letter with slate and stylus
Why would Caleb write code with comments? - Woman Wearing Red and Black Checkered Blouse Using Macbook
Why would Caleb write code with comments? - Woman Writing On Notebook





Writing Code That Speaks by Caleb Porzio - Erie Day of Code




More answers regarding why would Caleb write code with comments?

Answer 2

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.

Answer 3

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.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Sora Shimazaki, Eren Li, Christina Morillo, Vlada Karpovich