How Sanskrit provides programming concepts similar to classes, objects and pointers

From a response by “kannu” on December 11, 2012 to a thread “sanskrit-as-a-computer-language” at

In this article, we are going to see how Sanskrit uses programming concepts similar to classes, objects and pointers to shorten the language. To do this, we will try to translate a sample Sanskrit sentence to English and dwell into the nitty-gritties of it. Along the way, you will get introduced to a very innovative sentence structure, totally different from the structure of the language you currently speak.

Given below is our sample sentence. It appears in the text राजनीतिसमुच्चय authored by आचार्य चाणक्य |

मूर्खः परिहर्तव्यः प्रत्यक्षः द्विपदः पशुः । which means..

A stupid person must be avoided. He is like a two-legged animal in-front of the eyes.

Now, let’s get back to our good old Q & A format.

Q) Are you sure, the English translation you have provided is correct ? Else, why are there only 5 words in the Sanskrit version but so many words in the English version ?
A) Of course, the translation I provided is absolutely correct. But your doubt is also genuine. To know why the Sanskrit version is so economic in the usage of words, we need to first understand it’s structure.

Q) Umm hmm, go on..
A) As mentioned in the first article of the series, the words in Sanskrit represent properties. So the 5 words used in this sentence also represent properties.
मूर्ख = (the property of being) stupid
परिहर्तव्य = (the property that makes one) avoidable (by others)
प्रत्यक्ष = (the property of being) in front of the eyes
द्विपद = (the property of) having two legs
पशु = (the property of usually being) tethered

But, in spoken language, we always refer to objects and not properties. (The object being referred to need not exist in the real world. It is sufficient if it exists in the speaker’s imagination.) So we need a way to force the above words to represent objects rather than properties. That way of forcing a word(which represents a property) to represent an object is called vibhakti.

So, मूर्ख represents the property of being stupid, but मूर्खः (which is a vibhakti of the word मूर्ख) represents an object/person who is stupid. Here, मूर्खः is called the first vibhakti of the word मूर्ख | Similarly, परिहर्तव्यः is the first vibhakti of the word परिहर्तव्य | So, we have
परिहर्तव्यः = an object/person who must be avoided
प्रत्यक्षः = an object/person located in front of the eyes
द्विपदः = a object/creature having two legs
पशुः = an object/creature who is tethered = a beast or cattle (because usually beast or cattle is tethered)

Q) Hmm, cool. So this sentence has five words which represent 5 properties. But we converted the 5 words into their first vibhaktis. So the 5 new converted words represent 5 objects having those 5 properties. Am I right ?
A) Yes, absolutely.

Q) So far we have 5 different (vibhaktified) words representing 5 different objects having 5 different properties. How does this help in making a meaningful sentence. ?
A) Here comes the climax. There is a rule of Sanskrit Grammar which states that words having the same vibhakti represent the same object and not different objects! So the 5 different (vibhaktified) words actually do not represent 5 different objects, rather they are like pointers that point to the same object because they all have the same vibhakti viz. first vibhakti!
Hence, our sentence actually has one object/person (in the imagination of the speaker) who has all the 5 properties viz. he is stupid, he must be avoided, he is located in front of the eyes, he has two legs and he is an animal(beast or cattle) . In other words, a stupid person must be avoided and he (that same person) is like a two-legged animal in front of the eyes. Hence, we have effectively translated our sentence into English!

Q) Wow! So a typical word in Sanskrit is like class in Java(without methods) and the vibhaktified form of that word is like a pointer to an object of that class. Right ?
A) Yes! You got it. And not just that. There are actually 8 kinds of vibhaktis in all. In this article, we have considered only the first of those 8 kinds of vibhaktis.

The aStAdhyAyI composed by maharSi pANini is considered by many to be the first formal program in the world and he himself is considered the first programmer.

Q) Never thought that concepts similar to the modern programming constructs like classes, objects and pointers have been used in a spoken language by our ancestors for millenia. Awesome revelation, this was! I am impressed.
A) If this was awesome, then listen to this. maharSI pANini, considered to be the greatest Sanskrit Grammarian, used those same techniques to describe Sanskrit Grammar atleast 2500 years ago, which are today used to design the grammar of modern programming languages. If you do not believe, then check this wiki-page (search for computer programming languages on it).

Q) Awesome! Now a reminder for you. In the last article, you explained that सूर्य means sun, कोटि means crore, सम means equivalent and प्रभ means effulgence. By pronouncing these words one after the other, one can generate a new word viz. सूर्यकोटिसमप्रभ which means “one whose effulgence is equivalent to that of a crore suns”. Similarly, in English, why Sun, Crore, Equivalent and Effulgence, pronounced one after the other, do not generate a new word ? Why is SunCroreEquivalentEffulgence not a new word in English ? You promised, you will explain.
A) Yes, I do remember the promise. The reason for this speciality of Sanskrit also lies in the concept of vibhakti. How ? Its very simple. In Sanskrit, if I would ever want to refer to the Sun, I would say सूर्यः and not सूर्य. This is because, सूर्य would represent a property and the Sun is not a property, rather it is an object. So to refer to the Sun, I would use सूर्यः (which is the first vibhakti of सूर्य). Similarly, to refer to someone whose effulgence is equivalent to that of a crore suns, I would use सूर्यकोटिसमप्रभः (which represents an object) and not सूर्यकोटिसमप्रभ (which represents a collection of properties), because that someone is an object and not a property. Hence, there is a difference in the pronunciations of the सूर्य (in सूर्यकोटिसमप्रभ) and सूर्यः (which is the object Sun). The difference arises because of the 2 dots at the end of सूर्यः | But in English, there is no such difference in the pronunciations of Sun in SunCroreEquivalentEffulgence and the (object) Sun. Hence, it would be confusing in English. It is not possible in English to form such compound words, in turn, strongly limiting the vocabulary in English.