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.

37 Responses to Similarities between Sanskrit and Programming Languages

  1. Narayanan says:

    Hari Om,

    More than the subject, the way you have planned the article by asking questions and answering them enthuses the readers. Looking forward to your future posts.

    With Love,

    • Aditya says:

      Are you from the Chinmaya mission?
      I studied in chinmaya from LKG to 12th and they teach very good Sanskrit.

  2. Sandesha.ts says:

    संस्कृते संस्कृतः शिष्यः। संस्कृते संस्कृतो गुरुः।।
    संस्कृते संस्कूतः पाठः।
    संस्कृते किं नसंस्कृतम्।।??!

    यश्बद्धशास्त्रं भुवनेद्वितीयं।
    व्याकरणशास्त्रं नितरां सुबद्दं।।
    लिपिश्च वैज्ञानिकरीति पूर्णा।
    सा देववाणी खलुसेवनीया।।

    • Small says:

      Hello friend,
      I have learned a little bit of Sanskrit, but please do translate this in hindi or English, whichever is possible for you.
      Thank You

      • gshah says:

        A student of Sanskrit is refined. A teacher in Sanskrit is refined.
        A piece of literature in Sanskrit is refined.
        What is not refined in Sanskrit ?

        The etymology of which is second to none,
        The Grammar of which is firmly well-defined,
        The script too of which is completely scientific,
        That divine speech is definitely worth learning.

      • gshah says:

        Here is a Sanskrit dictionary for you to help learn. It contains 1.5 crore words! (Compare this with Oxford English Dictionary, only 5 lakh words)
        http://www.sanskrit-lexicon.uni-koeln.de/monier/

      • Small says:

        Thanks You friend for your amazing reply.
        But, I have one confusion about the online dictionarylink you have posted….
        I chose th Input as:’Harvard-Kyoto’ and output as:’Devnagiri Unicode’
        i could not decipher/decode the two words I tried: ‘Mother’ and ‘Friend’
        Please help me to use it also.
        Thanking You in Advance,
        Looking for your reply….

      • gshah says:

        It is a Sanskrit to English Dictionary. So you have to put Sanskrit words in the field. Eg) If you wish to know the meaning of the word मातृ, then you need to type mAtR in the box. If you want to know the meaning of the word मित्र, then you need to type mitra in the box. To know what to type for a word refer to this link http://www.sanskrit-lexicon.uni-koeln.de/monier/help.html. On this page the notation is given. I have pasted the notation below for you reference.
        a A i I u U R RR lR lRR e ai o au M H
        k kh g gh G
        c ch j jh J
        T Th D Dh N
        t th d dh n
        p ph b bh m
        y r l v z S s h

        So for अ, you need to type ‘a’. For आ you need to type A, for ष् you need to type S. Hence for मातृ = म्+आ+त्+ऋ, you need to type m+A+t+R = mAtR. SImilarly for मित्र = म्+इ+त्+र्+अ you need to type m+i+t+r+a=mitra.

  3. Vishwas says:

    Very informative article.
    It would be excellent if you posted more frequently. :)
    Great work

  4. Venkat says:

    Awesome post!! Felt like learnt something important and interesting.
    Cheers to the way you presented.

  5. Nyk says:

    brilliantly explained

  6. Srikanth K says:

    Wonderful article. Amazing. Please do continue.

  7. Gaurav Agarwal says:

    I have a doubt .
    The sentence मूर्खः परिहर्तव्यः प्रत्यक्षः द्विपदः पशुः points to a single object who has properties of 5 different objects.
    But how is this uniquely represents a sentence ? how does order of words influence the meaning ?
    Without order I can interpret it like ” The one who is in front of eyes having two legs is animal , stupid and avoidable ” or ” One having two legs in front of eyes is stupid animal and should be avoided” .

    • gshah says:

      You are having this doubt because you are trying to see Sanskrit through the grammatical framework of English. Sanskrit is very different from English and comparing the 2 would unnecessarily confuse you.(Here I had to compare both, since I could not have written this blog in Sanskrit itself.) As for your doubt, it is not possible to clear it at this stage. The sentence taken here is a very elementary one. This is only a special case of the General Sentence Structure in Sanskrit. If you learn Sanskrit in detail then this doubt will automatically vanish.

      BTW, just mentioning for your info, the word order in Sanskrit is very flexible. Word order in all indian langueges is flexible. Take Hindi. For example,
      mai dopahar me dilli se hyderabad gaya tha
      mai dilli se hyderabad dopahar me gaya tha
      mai gaya tha dilli se hyderabad dopahar me
      mai hyderabad gaya tha dilli se dopahar me
      and so on…

      In Sanskrit, word order is much more flexible than hindi!

      But in English word order is vary rigid, but Sanskrit has almost zero-rigidity.

      You can verify this fact by searching “word order” on the wiki page of Sanskrit. http://en.wikipedia.org/wiki/Sanskrit#Syntax

  8. Seshadri Rajagopalan says:

    संयक् कृतं = संस्कृतम्
    This is what is said about Samskritham
    Meaning as samskritham is the language which is complete in all respects

  9. Srikanth says:

    Dear GShah, Just thought you may not have noticed it. In Windows 7, unicode text has problems, especially if you combine two different languages it loads only one font correctly. I am using windows 7 and your sanskrit text looks to me like: सू र्य को टि स म प्र भः.

    See the discussion here: http://groups.google.com/group/grantha-lipi/browse_thread/thread/44702be5532ae7b7

    In my website I combine both tamil and Sanskrit so I had this problem, I had to use two different fonts for devanagari and tamil text. Its a known issue with Windows 7.

    BTW, when is the next part in this series coming?

    • gshah says:

      Dear Srikanth, I use Windiws XP as my old computer has not got much RAM. BTW, I ll be upgrading to Windows 7 in a few days. Anyways thanks to bring it to my notice.
      I ll put the next article within a week.

  10. Reading and dwellng on the subject and the way the language has evolved is a sort of AMRUTA DHARA for my otherwise routine life style and please dont ever stop it. I want to drnk this AMRUTA as much as possble wthin the short time I live

  11. Pingback: What makes Sanskrit the shortest language | uttiSTha bhArata

  12. Haresh Gala says:

    when u convert Properties to object Vibhakti get applied to last Property ( Dhatu ) , this is why we can create words combining many properties to form word/name

  13. Nemi says:

    fundoooooo….
    nice article,
    So, now how can we use this information to reduce the dependency on English. And make ppl use Sanskrit as daily usable language. I hope you must have worked on further roadmap regarding same.

    Nem

    • gshah says:

      That is possible only by some initiative of the govt., which our current anti-indian govt will never do. The Only way to get Sanskrit back it’s lost glory is first to uproot the current anti-indian govt. The best way to do that is by supporting the rising movements of Anna and Baba.

      • Prashant says:

        लेकिन उन भारतीय अंग्रेजों का क्या जो अंग्रेजी को ही पल्लवित और पुष्पित करने में लगे हैं और हिन्दी तथा संस्कृत को हेय दृष्टि से देखते हैं। इसका एक प्रमुख कारण यह भी है कि संस्कृत या हिन्दी में वैज्ञानिक एवं तकनीकी साहित्य की उपलब्धता नहीं है और न ही इन भाषाओं के जानकारों के लिए रोजगार के अवसर उपलब्ध हैं। सरकार तो इसमें दोषी है ही लेकिन हम सभी इसके लिए जिम्मेदार है।

  14. Satyabodhanand says:

    Satyameva jayte!
    Truly said this “Anti-Bharat” government are arrogant self sufficient fools. Better called मूर्खः परिहर्तव्यः प्रत्यक्षः द्विपदः पशुः| An ignorant can come to know the efficacy of the ancient Bhartiya wisdom only by the grace of LORD. Till then prey for them. It is hard for these so called intellectuals leading the country with western philosophy based on glorifying human weaknesses of lust and greed in the name of being practical and truthful to understand the delicacies and benefits of contentment and renunciation of Bhartiya philosphy.

    No matter how dark is darkness when light will come it will have to go. It will come through the efforts of like one done by Sh. G Shah. I enjoyed and appreciate every bit of these three articles. The method of presenting is very lucid. Did full justice to the subject. Keep it up sir. Waiting for new articles.

  15. siddhartha bhandari says:

    a very well done work to enlighten those who spoke english and thought themselves to be on top of the world. kudos to gshah. i always had the sense of samskrit being the superior most lenguage but you proved it and i cant explain my joy now. i admit i am not well versed in samskrit but being an indian and a hindu i always knew that this lenguage was some thing else was thorough scientific. here you proved it. cant thank you enough. god bless you. one more thing, i always was a bit irritated why the hindu names when pronounced in english contained an unnecessary ‘a’ after them,e.i. rama, ravana, krishna, ramayana. while they could be pronounced ram, ravan, krishn, ramayan. i always thought it was a british conspiracy to degrade indian names. now i know its due to vibhakti. they tried to mention object in sun and made it surya. the last ‘a’ = : in samskrit. or call it sury(ah). it was a very intersting reading which answered my many question. moreover it inspired me to learn this divine lenguage, which i am going to do with the help of the books you provided. thanks again.
    siddhartha bhandari

  16. Pappu says:

    Sir, The articles written by you are excellent. I heard that there is an ancient language of symbols by name “Senzar” mentioned by Madam Blavatsky in her work “The Secret Doctrine”. It is considered to be the mother of Sanskrit language. Do you know anything about it ?

  17. sachin says:

    I only have to second all the great feedbacks posted on the blog. My wife is a sanskrith student through out her life. But when i used to ask her question, her answers were very complicated for me. But you said it the way I can understand using concepts of classes and objects. this is a language I understand. I am very thankful for your effort. I hope you can continue to put more information. For my part i am going to spread this blog to all my fellow ignoratti..

  18. vasya10 says:

    uttamam vivaraNam asti |

    But I cannot agree that government should do something about sanskrit upliftment. We cannot expect the government to do this. Each and everyone of us must consider our duty to study sanskritam with passion, then the results wil happen. If we just appreciate the language, clap at its marvels, wonder at its structure it is clearly not enough. We need to resolve to speak in Sanskritam, think in Sanskritam. That will make a difference.

    programming language viShaye atraapi kinchit mayaa likhitam (vagartham.blogspot.com).

    • gshah says:

      1) Most of the people will not speak in sanskrit because they do not know that it is such an awesome language. govt can introduce courses in school showing the true nature of Sanskrit to the people so that people get inspired to speak in it.
      2) British have created an anti-sanskrit atmosphere in India by calling it a language of invading aryans and calling the non-brahmins as their slaves. dalits and tamils will not accept sanskrit unless this anti-sanskrit prejudice generated by British is destroyed by introducing the correct history in schools
      3) Muslims will not accept sanskrit because they associate Sanskrit with hinduism and not with their ancestors. So govt also has to spread awareness that Sanskirt is a language of our ancestors and not only related to some religion but was also a language of Science, Mathematics, Astronomy., Ayurveda, Philosophy etc

      Unless govt does not take some steps I think it impossible to revive Sanskrit because people have lost pride over it and people will themselves never start using Sanskrit unless this pride is generated in them.

      And what’s wrong in the demand of govt promoting Sanskrit. it is govt’s responsibility which it does not fulfill. Any nation’s govt is responsible for promoting that nation’s culture.

  19. vasya10 says:

    @gaurav-varya: yes i do agree with all things you say, they are facts – what govts, historians have done previously. But we are talking about what we are expecting our govt. to do. There is nothing wrong in demanding, but if a govt. cannot budge for corruption, its hardly going to budge for sanskritam. In an ideal world yes. I’m not talking about people who don’t know or hate Sanskritam – Im talking about the people who say Sanskritam is great, but give excuses to learn – they have to start learning. There are plenty of them. Blogs like yours is helping to appreciate Sanskritam more, but there is a bridge one has to jump from appreciating to actually learning. That change should come from within.

  20. C.S.Rajan says:

    I am an oldie. Don`t know anything about computer languages. But now after reading your article , I fully beleive that Sanskrit is the most computer friendly language. Thanks for enlightening me. C.S.Rajan.

  21. Sudhir says:

    Dear Guru,
    I have no words in which I can express except saying ” I am Thrilled !!! ” to say the least.
    You might be aware that NASA has published an article “Knowledge Representation in Sanskrit
    and Artificial Intelligence” http://www.aaai.org/ojs/index.php/aimagazine/article/viewArticle/466 .
    When I read that article in conjunction with the current Lesson ( on programming language ) I got some
    clarity. Wish you great success in your mission.
    Regards
    Sudhir

  22. Gnanaboomi says:

    Amazing clarity and simplicity. Thanks again for this noble task. I would request you to come up with an online course in Sanskrit in this same simplicity. This language is ignored by people even if they want to learn it because they think it is too complicated. The Saha Tau Te, Saa Te Taha and Tat Te Taani confuses them. It is high time to come up with a simplistic lesson like this article. If you are willing, then I am very happy to provide you an access to my site as well, where you can post the articles on Sanskrit course. Please let me know.

    Kind regards,
    Admin
    GnanaBoomi.com

    • gshah says:

      I am willing but busy with other commitments. As you can see I write very infrequently even on my blog. Running very busy now-a-days. If ever I find some free time in future, I ll contact you.

      Thanks.

  23. Gnanaboomi says:

    Oh! one may ask, why in another space additionally. It is simply to wide-spread as we have our own visitors and I sincerely believe that a back-link alone may not be sufficient.

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 )

Connecting to %s