You are here: Home Q&A Questions and Answers What is the similarity between a natural languages and programming languages?

Questions and Answers

Vragen en Antwoorden Nederlands Fragen und Antworten Deutsch

Is there something you have always wanted to know about language? We might have an answer! On this page we answer questions about various aspects of language asked by people outside of the language researcher community.

What is the similarity between a natural languages and programming languages?

Some programming languages certainly look a lot like natural languages.  For example, here’s some Python code that searches through a list of names and prints one out if it’s also in a list called invited_people.


for name in my_list:
  if name in invited_people:
    print name

However, some other programming languages are much less readable.  Here is some code in Scheme that does the same as the code above.


(map (lambda (name) (if (cond ((member name invited_people) name)) (display name) name)) my_list)

So, how similar or different are natural languages and programming languages really? To answer these questions, we need to understand some central terms that linguists use to describe the structure of languages, rather than just looking at the surface of what looks similar or not. 



Similar structures of semantics and syntax

Two of the most central concepts in linguistics are the concepts of semantics and syntax. In short, semantics is the linguistic term for meaning, but a more precise explanation is that semantics contains the information connected to concepts. For instance, a word form like “sleep” (spelled S-L-E-E-P, in either letters or pronounced as sounds) designates a certain action of a living organism and that’s the semantics of that word. The syntax on the other hand is the structure of how words of different kinds (e.g. nouns and verbs) can be combined and inflected. The sentence “My ideas sleep” is a well-formed English sentence from the point of view of syntax, but the semantics of this sentence is not well-formed since ideas are not alive and thus cannot sleep. So, semantics and syntax have rules, but semantics relates to meaning and syntax relates to how words can be combined.

Having explained the semantics and syntax of natural languages, let’s turn back to programming. In programming languages, the coder has an intention of what the code should do. That could be called the semantics or the meaning of the code. The syntax of the programming language links a certain snippet of code, including its “words” (that is variables, functions, indices, different kinds of parenthesis etc.) to the intended meaning. The examples of python and scheme above have the same semantics, while the syntax of the two programming languages differ. 

Different purposes

We have described many parallels between the basic structure of natural languages and programming languages, but how far does the analogy go? After all, natural languages are shaped by communicative needs and the functional constraints of human brains. Programming languages on the other hand are designed to have the capacities of a Turing machine, i.e. to do every computation that humans can do with pen and paper, again and again.


It is necessary for programming languages to be fixed and closed, while natural languages are open-ended and allow blends. Code allows long lists of input data to be read in, stored and rapidly parsed by shuffling around data in many steps, to finally arrive at some output data. The point is that this is done in a rigorous way. Natural languages on the other hand must allow their speakers to greet each other, make promises, give vague answers and tell lies. New meanings and syntax constantly appear in natural languages and there is a gradual change of e.g. word meanings. A sentence from a spoken language can have several possible meanings.  For example, the sentence “I saw the dog with the telescope”, has two possible meanings (seeing a dog through a telescope or seeing a dog that owns a telescope). People use context and their knowledge of the world to tell the difference between these meanings. Natural languages thus depend on an ever changing culture, creating nuances and blends of meanings, for different people in different cultures and contexts. Programming languages don’t exhibit this kind of flexibility in interpretation. In programming languages, a line of code has a single meaning, so that the output can be reproduced with high fidelity.

Answer by: Julia Udden, Harald Hammarström and Rick Jansen

About MPI

This is the MPI

The Max Planck Institute for Psycholinguistics is an institute of the German Max Planck Society. Our mission is to undertake basic research into the psychological,social and biological foundations of language. The goal is to understand how our minds and brains process language, how language interacts with other aspects of mind, and how we can learn languages of quite different types.

The institute is situated on the campus of the Radboud University. We participate in the Donders Institute for Brain, Cognition and Behaviour, and have particularly close ties to that institute's Centre for Cognitive Neuroimaging. We also participate in the Centre for Language Studies. A joint graduate school, the IMPRS in Language Sciences, links the Donders Institute, the CLS and the MPI.


Questions and Answers

whiet question mark on MPG green 124pt, stroke 2pt

This project was coordinated by:

Katrien Segaert 
Katerina Kucera
Judith Holler

Sean Roberts
Agnieszka Konopka
Gwilym Lockwood
Elma Hilbrink
Joost Rommers
Mark Dingemanse
Connie de Vos