Skip to main content

Learning to Program is Hard

·477 words·3 mins

Learning a new language is hard; learning a programming language, meant to be “understood” by a computer, doubly so.

Consider the following situation:

During a walk through your hometown you encounter a tourist who is trying her best to speak your native tongue. She asks you for directions. Despite the numerous grammatical errors, wrong use of idiom, and the wrong pronunciation of her destination, you understand her question. You describe the route, shying away from complex expressions. The tourist thanks you and proceeds in the direction you indicated.

What happened there is quite incredible: even though the tourist did not understand every word of your explanation, she was still able to follow your instructions. You too were able to look past any mistakes the tourist made. You both could communicate and extract the gist of what the other said.

What does this have to do with programming? Recent neuroscientific findings suggest that programming calls on the speech faculties of the human brain (Siegmund et al. 2014; Floyd, Santander, and Weimer 2017). Programming languages are languages. Languages that are meant to be read by both humans and computers—programming code is more often read than written. What sets these languages apart from their natural counterparts is that formal languages must account for the fact that the intended recipients include mechanical computers. Hence, formal languages leave no room for ambiguity.

Something similar is asked of our students. They need to learn how to articulate procedures unequivocally to a machine that lacks a theory of mind. A machine that is unable to look past any grammatical or semantical errors. A device that cannot decipher the intent of the messenger.

A computer will refuse outright to process anything that is not properly worded—or, even worse, do what was asked, not what was meant. Novice programmers are continously confronted with this mechanical stubbornness. Every syntax error is warded off by a compilation error. Mistakes result in crashes. The omission of an equals sign causes the program to run indefinitely. And even when, eventually, what they have painstakenly composed, runs and terminates, there is no guarantee that the result is correct.

Learning how to programming is like learning a foreign language by writing letters to a native speaker who does not tolerate even the smallest slip of the pen: an exercise in frustration.

References

Floyd, Benjamin, Tyler Santander, and Westley Weimer. 2017. “Decoding the Representation of Code in the Brain: An Fmri Study of Code Review and Expertise.” In Proceedings of the 39th International Conference on Software Engineering, 175–86. Icse ’17. Buenos Aires, Argentina: IEEE Press. https://doi.org/10.1109/ICSE.2017.24.
Siegmund, Janet, Christian Kästner, Sven Apel, Chris Parnin, Anja Bethmann, Thomas Leich, Gunter Saake, and André Brechmann. 2014. “Understanding Understanding Source Code with Functional Magnetic Resonance Imaging.” In Proceedings of the 36th International Conference on Software Engineering, 378–89. Icse 2014. Hyderabad, India: Association for Computing Machinery. https://doi.org/10.1145/2568225.2568252.