Is Learning a Programming Language like Learning a Foreign Language?
Every day you will use applications and websites which run code from a variety of programming languages. From the device you are reading this article on to the satellites orbiting us, code is everywhere, and its importance is growing.
As someone who studied German rather than computer or data science, I found the use of the word ‘language’ in combination with computers interesting. When I started learning Python, I asked myself whether learning a programming language would be like learning a foreign language. Six months into learning Python- and with much still to learn- here are some initial thoughts.
· Learning both types of languages changes how you think. A foreign language is like a unique toolbox. Whilst German and English are part of the same language family- and therefore have many similarities- they have different ways of expressing ideas and different sayings.
Programming languages are also like toolboxes and just like foreign languages they too can be grouped into families. Learning a programming language challenges you to think differently in another way as it forces you to work from first principles and think in decision trees. Faulty logic or assumptions inevitably result in dreaded error messages.
· The learning curve feels similar. When you start learning both types of languages you experience a surge in motivation. Yesterday you could not say ‘I live in England’ or code ‘Hello World!’ but today you can! The sense of progress is electrifying but inevitably you quickly run into difficulties. You think ‘how will I ever learn this language?’ and begin to despair. You look online and see people who are much better than you and you feel a growing temptation to quit. The key with learning both types of languages is to keep going, focus on the next step and trust you will get there in the end.
· Once you have learnt one language it is easier to learn other languages (especially those which are closely related). When you learn a foreign language, you are not just learning the language but also the underlying grammatical structures. These are often similar in other languages which makes learning further languages easier.
I have only learnt Python to date but I am reliably told once you have learnt one programming language it is much easier to learn others (even more so than with foreign languages). Even after six months of learning Python I can look at other programming languages and sometimes piece together what is going on.
· You can already speak a language. This may seem obvious, but it is important. When learning a foreign language, you are already fluent in your native language so you understand how you can use language to express yourself. If you are confronted with a situation abroad- such as wanting to order food-you will likely know what you want to say even if you do not know how to say it. The challenge to start with is generally one of translation.
When you learn your first programming language you do not have the same reference point which puts you a step further back. For instance, you might not even know what your code needs to do to solve a particular problem. As such a key part of the learning process is learning how to think your way around a problem before you even touch the keyboard; this often requires you to think algorithmically which many of us do not do on a regular basis (at least not consciously).
· You can test your code easily. When you learn a foreign language, it is often difficult to know if you have made a mistake unless it is amusing, and people laugh. People think they are being polite by not correcting you, but their politeness slows your improvement.
Programming IDEs and compilers do not care for your feelings and that lack of politeness is incredibly helpful. Getting instant feedback on your code allows you to quickly test ideas, which is both helpful and fun.
· When learning a programming language you need to know less off by heart, but your foundational knowledge needs to be better. To converse fluently in a foreign language you must know lots of vocabulary and different grammar structures off by heart. Coding is different as you have less time pressure. This means you can look things up in the documentation or see how other people have approached similar problems before.
When starting a foreign language, you can — and people frequently do- neglect grammar and focus on learning vocabulary and phrases. Whilst this is not an advisable approach- as it will haunt you later- it is understandable as minor grammatical errors rarely stop you from being understood. With a programming language the ‘grammar’ element is critical. For example, forgetting a semi-colon may result in hundreds of lines of code returning an error message. For this reason, it is vital you gain a firm grasp of the basics.
· Programming languages only have one tense, the simple present. Spoken languages have a variety of different past, present and future tenses whilst programming languages just have the simple present tense. Programming languages do, however, make heavier use of the conditional tense than spoken languages (e.g. if x condition is met do y).
There are many other notable differences between foreign languages and programming languages which have not been covered here. Let me know in the comments if you think there is value in comparing the two types of languages and, if so, what do you find the most interesting differences?
*Language families are groups of languages related through descent from a common ancestral language or parental language. Both English and German are members of the Germanic family. English has more in common with German than say a Sino-Tibetan language such as Chinese. Programming languages also have analogous language families.
**First principles thinking is breaking down complicated problems into their most basic elements before reassembling them from the ground up. Elon Musk is a famous proponent of first principle thinking.
***It is sometimes impossible to completely translate or interpret from one language to another. The example provided ignores this for the sake of simplicity and because, when you begin learning a language, the focus is on the literal meaning rather than the subtleties of the language.