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.

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

85 Responses to Similarities between Sanskrit and Programming Languages

  1. Tanmay says:

    Amazing!

  2. Satish says:

    Amazing explanation. I learnt Sanskrit and also am a Java programmer. But never in my dream I saw this relation between a programming language and Sanskrit. WOW…. kudos to you. It makes me think now in a whole new direction. “Rama” a word. “Ramah” in the prathama vibhakti a property… “Ramat” again another one… WOW. Thanks man have a good health and prosperity and live for 100+ years.

    • Satish says:

      Sorry I mean Ramaha and Ramat etc. are objects… Rama is property (or a word)

      • gshah says:

        rAma literally means something that pleases. and is derived from the dhAtu “ram”. Other words derived from “ram” are ramaN (as in ramaN singh), ArAma (which means rest), rata (as in karyarata).

        • Satish says:

          Thank you. I will open my old Dhaturupa Manjari which I bought a long time back. Your articles aroused my Sanskrit interest again.

  3. This is really a great article i came across.
    I had been reading this from years that sanskrit is the most suitable language for programming but never checked why?
    This article has been written very precisely and in a very simple way for the understanding of even of a layman.
    Hats off to you Mr. Author.

  4. guide says:

    i like to learn programming in sanskrit as all do in c, and many other. from where to start. I am very much interested the way u explained.

    • gshah says:

      There is no programming language in Sanskrit. This article only shows similarities between Sanskrit and programming languages. If you want to learn, learn Sanskrit. Then a vast trove of knowledge will be available to you in the form of Sanskrit literature, that will change your life.

  5. Pingback: Quora

  6. Krishnananda Prabhu says:

    Nice if sum more topics LINKED to ANCIENT LANGUAGE SANSKRITH r published like dese

  7. piyush says:

    A super computer may have 10 processors & 100 association links, which is drastically difficult to manage, & yet not implemented in so called developed days. Human Brain has the fastest computation abilities,with billions of processors & trillions of association links, out of which we use only 2-3% of it.Y to make this idiot box learn Sanskrit.Human can do far better jobs with efficiency than computer.I post my views, please don’t argue here say can human brain book me a show online.

  8. himanshu says:

    One of the best article i have ever read

  9. Deepa Gupta says:

    Hello,

    Your article is remarkable in its explanation and stands out from other articles since it’s more precise and describes the concept very well.

    Could you please let me know how may a student from computer field could proceed in order to pursue programming language research in sanskrit as described by you in this article. Where is this research going on, who is leading it and how can one follow it? How can one become a part of it?

    I’ll be really grateful if you could please shed some light on this.

    Many thanks
    Deepa

    • gshah says:

      I am not associated with any such research. I am an alumnus of IIT Bombay. We have such research going on in natural language processing using Sanskrit in the Humanities department of IIT Bombay. You may contact Prof. Malhar Kulkarni, Humanities department, IIT Bombay for further info.
      http://www.hss.iitb.ac.in/faculty.php#malhar

      • gshah says:

        But note that Sanskrit is at the end of the day a spoken language, though it has many features common with programming languages. I do not know how much this feature of Sanskrit will be helpful in using it as a real programming language for machines.

        • Vj says:

          Nice. So if Sanskrit is so modular, why is there no reliable Sanskrit to English translators?

          • gshah says:

            Well, I am not sure about that.

          • vasya10 says:

            Because English is not modular? :-)

            Translations are not simple because there is no point in doing word-to-word translations. This is not just from Samskritam to English, but any language in general. Context, idioms, prevailing customs and cultural quotient all are factored for a quality translation. The farther away the translator is from the cultural impact, the poorer the translation will be. Even using the above example, how can you really translate kotisUryasamaprabhaH ? An armchair translator would just say CroreSunEqualEffulgence while one who knows the culture would probably tranlsate to “epithet of Ganesha”.

            • Vj says:

              I concur only to some extent. The technology has developed much farther to guess the context, than do a word to word translation. If 1-to-many mapping is a problem, why not do a many-to-1 mapping?

    • Shekhar Yadav says:

      Deepa Gupta
      Click on the link Below then you will get the answer that where is this research going on.
      http://post.jagran.com/NASA-to-use-Sanskrit-as-computer-language-1332758613

  10. Basu says:

    Thrilled to read your article. I am not very well versed in Sanskrit. Please clarify my query. I am afraid the questions might be wrong altogether, but still I am looking ahead to you for an explanation.

    You have mentioned that
    suryokotisamaprabha: = kootisuryasamaprabha

    So is
    samakotisuryaprabha = suryokotisamaprabha = samasuryokotiprabha??

    I mean to ask that these four different words you have combined to get the end result, can we do any possible combination of them and the final meaning shall remain the same?

    Please explain if its a negative answer.

    (I have typed in English as I am not very well versed in writing down in Hindi.)

    • gshah says:

      You have mentioned that
      suryokotisamaprabha: = kootisuryasamaprabha

      I did not mention that. I am not sure whether it is correct or not.

      • सामान्य नियम यह है कि शब्दों का क्रम कुछ भी हो सकता है| कुछ विशेष परिस्थितियो में यह नियम लागू नहीं होता: मुख्य रूप से जहाँ पर अर्थ बदल जा रहा हो

  11. Tushar Roy says:

    “rAmah ch mohanah Amrafalam khAdatah”
    Considering this sentence, how does the 2 words of the first vibhakti “rAmah” & “mohanah” represent the same object? Please clarify.

    • gshah says:

      The sentence is not correct. It should be “rAmah ch mohanah ch” or “rAmah mohanah ch” but not “rAmah ch mohanah”. ch is not used like ‘and’.

      It is the ch that tells us that ram and mohan are different objects. Moreover, if it is clear from the context that they are different persons, then even the ch is not required.

  12. Prav says:

    Awesome artilcle!!!!

  13. Sagar says:

    In saunskrut, if a new word can be formed by combining multiple properties then is the new word legal regardless of the order of combination of the properties?
    i.e. Is सूर्यकोटीसमप्रभ: = कोटीसूर्यसमप्रभ: ?
    or सूर्यकोटीसमप्रभ = कोटीसूर्यसमप्रभ ?

  14. Vivek says:

    Please post some more tutorials about Sanskrit & try to post in Hindi. It will be helpful to understand

    Thanks

  15. Arvind Kumar Sethuraman says:

    Excellent Article. Many thanks for this. Dhanyasmi.

  16. android1928 says:

    very nice …………… looking for some more links between sanskrit and current programming language.

  17. jag says:

    Excellent tutorial, please post more and also guide me to learning samskrit. I have some knowledge of Samskrita but not proper. Please post books, articles and tutorials.

  18. Arjun says:

    Amazing Tutorial.

    Thanks for this

Express yourself..

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s