Summer Study: Ken Lambert Summer Project: “A Gentle Introduction to Functional Programming in Haskell.”
“Learning how to code is more like an exercise in design, engineering and detective work than an exercise in learning a foreign language.”
Ken Lambert, professor of computer science at Washington and Lee, is spending the summer completing a book on computer programming called “A Gentle Introduction to Functional Programming in Haskell.” The book is the result of a directed individual study that Lambert sponsored last fall for two students, Lydia Barit ’16 and Maria Jose Herrera Quesada ’16.
Lambert, who has been a professor at W&L since 1985, has served three terms as chair of the Computer Science Department. He has previously published 26 books on introductory computer programming in three different programming languages.
We asked Professor Lambert to discuss the importance of introducing students to computer programming language, and to compare and contrast the study of programming languages with the study of foreign languages. Here is what he had to say:
I’m very fortunate to teach at a college whose dean (Suzanne Keen, the Thomas Broadus Professor of English and Dean of the College) believes that everyone should learn how to code.
Coding, a synonym for computer programming, is definitely hot. Over the last couple of years, computer science departments in colleges across the country have been reeling from a tidal wave of students interested in learning computer programming. Students recognize the obvious importance of this skill in the current job market. They also want to learn more about how computer software structures much of everyday life, from the more obvious devices we use on a daily basis to the more or less hidden roles that software plays in commerce, finance, government, entertainment and the “internet of things.”
I am occasionally asked if learning to code is like learning a foreign language, and if one might substitute a programming requirement for a foreign language requirement in the college curriculum. I think that the answer to both of these questions is no. Explaining why offers a great opportunity to clarify the nature of coding and its place in a liberal arts education.
One learns to code in a programming language, so learning a programming language is a big part of learning how to code. One hears about many such languages. Some of these are named for mathematicians, like Pascal, Ada and Haskell, and others for popular beverages, like Java. Some are named for gems, like Ruby, and others for a comedy group, like Python (after Monty Python). Still others use simple letters or acronyms, like LISP and C. In my three decades of teaching programming at Washington and Lee, we have used four languages in our introductory programming course: Pascal, C++, Java and now Python.
Like Spanish, German, Russian or Arabic, programming languages have a vocabulary and a grammar that specify how to construct correct sentences, and a set of semantic rules and guidelines for idiomatic usage that allow the programmer to use these sentences in a meaningful way. So, learning to code does involve learning a language that is somewhat different in structure from one’s native tongue.
However, unless you don’t know English, learning to code is not like learning a foreign language. Although the grammar and semantic rules of a programming language are more restrictive than those of English, the vocabularies are not very different. When I tell my students that a well-written program should read very much like a well-written essay in English and will be graded as such, I am reassuring them that they are simply applying their rhetorical skills in English to a new domain, that of coding. Therefore, learning how to code is more like an exercise in English composition than an exercise in learning a foreign language.
Of course, the real point of coding is to build information structures that not only are expressive and beautiful, but also can direct machines to perform complex tasks automatically. The code that lies in your cellphone notifies you when you have a message, and the code that lies in a thermostat triggers the air conditioning when the room temperature reaches a certain threshold, or the clock reaches a certain time of day. The code that composes the iPhone’s Siri app allows your phone to understand your spoken requests and to respond accordingly.
Information structures are like a pure “thought stuff” that can be expressed in English or in computer code. But only computer code can express thought stuff with automatic behavior of its own. After my students write their code, they must test it to see if it behaves correctly. Few learning experiences rival the hunt for errors in program code and the rush of joy one receives when a complex program finally runs correctly. Therefore, learning how to code is more like an exercise in design, engineering and detective work than an exercise in learning a foreign language.
Finally, part of good design in coding is to develop mechanisms to control or hide complexity. Modern software includes the most complex artifacts ever built by human beings. Coding is like model building in science and mathematics, where complex ideas are reduced to simpler ideas by developing and applying appropriate abstractions. Although programming languages share a common English-like vocabulary, they typically differ in the abstraction mechanisms that they make available to the coder. For example, functional languages like Haskell focus on the function as the basic unit of abstraction, whereas in object-oriented languages like Java and Ruby, the basic units of abstraction are the object and the class.
By contrast, learning a foreign language opens a window on a culture and way of life different from your own, and allows you to view your own language and culture from a fresh perspective. And as you pursue further study of a foreign language, a window also opens on its literature, whose focus is on expressing the concrete experiences specific to a culture or shared by all cultures. By learning to stand and walk in the shoes of another language and culture, you learn more about your own language and about yourself. This kind of learning experience is not interchangeable with the experience you have in coding.
Learning to code and learning a foreign language are thus very different, but quite complimentary, parts of a liberal arts education.