Similarities between Sanskrit and Programming Languages

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!

The same mechanism is explained below graphically.

word1 is mUrkha, word2 is parihartavya and so on..

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.

That’s it for this article. In the next one, we will dwell into the remaining 7 vibhaktis and examine how they shorten the language.

This entry was posted in Sanskrit and tagged , , , . Bookmark the permalink.

100 Responses to Similarities between Sanskrit and Programming Languages

  1. Rajesh says:

    I do not think – कोटि means crore in this context. First of all, कोटी means crore (10 million) and
    कोटि means type.
    E.g. Hindus believe that there are 33 कोटि gods (& not 33 कोटी gods). Which means, there are 33 types of gods (& not 330 million gods) OR the word पराकोटि means extreme type or extreme level.

    सूर्यकोटिसमप्रभ means “one, whose effulgence is of the type of a sun!!!

  2. Paul Howard says:

    Here is more info on a closely related subject: https://www.ashishdalela.com/2017/01/15/problem-meaning-artificial-intelligence/

    I also recommend reading the whole blog from the beginning. It’s not my blog, but the depth of knowledge I find there is thrilling.

  3. Pingback: Quora

  4. Pingback: Quora

  5. western says:

    Making a correction to Karl’s point. Sanskrit is NOT the remnant of any language; it has been completely engineered. Panini created the entire structure of this language more than 2500 yrs ago. Also, there is nothing that belonged to the so-called Aryans, because, there was no such race at all (since the topic is not about any race, I will not delve deep into this aspect).

    And I say this to the tutor – you have given a very nice tutorial. I was able to grasp each and every bit of it because I have studied this language in great detail.

  6. Karl says:

    Sanskrit is a remnant of the ancient Aryan language. It is indeed an amazing language. But for people of white European heritage such as myself, I feel a very close affinity to this ancient Aryan language by way of Lithuanian and Latvian. In my case, I am studying Latvian. When I hear sings singing in Latvian, it occurs to me that this language is a very pure language for human beings, without the ugliness or harshness of so many other languages.

    • You seem to be misinformed. Aryan isn’t a race but a category of north Indian languages derived from the Vedic language and Sanskrit later Prakrit. Indo Aryan is nothing more than a family of north Indian languages, and its ethnic speakers. Indo Aryan is related to Iranian languages which together form the Indo Iranian family. Indo Iranian is related to Indo European languages, and is possibly descended of PIE. Sanskrit properly called Samskruta Vak which means refined speech, was the refinement of the Vedic language.Sanskrit was designed by scholars for scholars as it was meant to be an ideal language of learning and knowledge. Thus Sanskrit and all its derivatives are INDIAN/Aryan languages not part of any European family such as Germanic, Slavic, Romantic, Celtic,etc. Although the Indo Iranian peoples were related to a set of people today called Europeans, they don’t descent from them or vice versa. Latvian only preserves archaic words form the theoretical PIE language, while proto Indo Iranian directly descends from PIE. Sanskrit is far more refined, purer, and poetic than Latvian despite possessing many similarities. Overall Sanskrit is an Indian/Aryan language, not a European one.

  7. tharashri says:

    super. i want to learn this wonderful language

  8. Roshani says:

    very nice tutorial…
    can u provide some more information in this please??

Express yourself..