In the Spring of the year 1985, a NASA scientist by the name of Rick Briggs, working at Roacs-NASA Ames Research Center(California), composed and presented an article by the name of "Sanskrit and Artificial Intelligence" for AI Magazine, published by NASA. Needless to say, C++ was still in its naive form by then, JAVA still hadn't arrived, and programmers were having a real tough time trying to deal with the machine-like computer languages in mnemonic codes.

In simpler terms, Mnemonic codes are part of Assembly Language, which comprise of operations like ADD(to add), SUB(to subtract), etc, which a computing machine can understand. Even to perform simplest of calculations in series, people were still feeding in scores of mnemonic codes, which they could neither comprehend nor understand properly. The Mnemonic codes formed a part of low level language and were completely different from the natural languages which humans speak or understand.

The search for a comprehensive programming language which would be compatible with natural languages was still on. C/C++ had provided glimpses of hope, albeit after years of research and money being pumped into it. Mr Briggs commented that the scientists have got beaten heavily by some 2,600 years in being able to develop semantics for such a programming language, when a certain Indian sage, by the name of Panini, belonging to 7 BC, had all the answers to the problems the scientists were facing. Now why would Rick Briggs, a NASA scientist, claim such a thing? Had he found certain elements in Panini's work which compelled him ascertain such a notion?

Namaste and welcome to the eighth post of this blog. This post, like all the previous ones is indeed very special, but more so, because I personally found it the toughest to compose till now. I really hope you guys like it much more than all of the previous posts.

Panini was the man who designed the entire grammar for Sanskrit. The semantics, which comprise of some 4000 rules in total, are so scientific and logical in nature, that it could very well be the baseline of structures used by various computer scientists. Panini composed a book by the name of Ashtadhyayi which comprise of exhaustive set of rules for Sanskrit Grammar. The grammar is based purely on mathematical and algebraic algorithms, and is powerful enough to be used to model a generator, which could churn out the rules for languages like Chinese or Thai.



Alright enough of the theory, time for some practicals. Lets take up certain concepts of modern day computer programming and see how well they match up with the rules of Panini's Sanskrit.

Database and Metadata: In layman terms, Database is a collection of data. Raw data is meaningless. Metadata, in programming terms, means data about data. In other words, raw data, which is meaningless as such, assumes meaningful patterns and collection when metadata is applied to it. Panini's Sanskrit, in the form of 4000 rules, form four compact databases. Aksharasam Amanaya, Sutrapatha, Datupatha and Ganpatha are the databases of Sanskrit, and the metadata are the rules contained within these databases.

Recursion: Those who are not aware, recursion is a process of repeating items in a self-similar way. In computer programming, whenever a method call is made from within the method itself, it is called recursion
The picture below would explain recursion better

It is interesting to note that Panini has extensively used recursion in Sanskrit grammar. Each of the 4000 rules are called Sutras, and each complete word to define those rules was called Pada. Panini did not use all the Padas in a Sutra to fully explain the Sutra. He, at times refers to previous Sutras where the Pada has already been defined or used (method invocation). There are instances when Panini has called a Sutra from within itself to refer to the Pada.

मार्जारः श्रावितृ मूषकम् अपश्यत् (The cat, who hears, saw the rat)

Here there is a recursion of मार्ज(The Cat). May sound easy now, but think of it as a semantic being composed 2600 years ago

Arrays and null values: Panini has defined a term called Lop, which would be equivalent to Null. A null can be assigned to a variable, or a pada in Sanskrit, and then used for simple Array operations in Sanskrit like Join(Sandhi in Sanskrit). A number of array joins can result in a complex term, which again can be broken down(disjoint). The below example shows A simple Sanskrit word as three distinct String arrays with Null
नमःस्तुते = न मः लोपः स् तु लोपः ते
S1[0] S1[1] Null S2[0] S2[1] Null S3[0]

Polymorphism: Literally, polymorphism simply means one word having more than one meanings. My software industry friends would understand better, but the below image can be of help for the others.


If "cut" is called, it maybe for a surgeon, hair stylist or an actor. A single action can mean different to different audience.
लम्बोदर: could mean A person with big Stomach, and could also mean Lord Ganesha. The user of the word has the freedom to define the meaning of the word in his context(run time polymorphism)

Distributive Law(Inheritance and Sets): Panini used Brevity extensively in his Sanskrit Grammar rules. Consider this:
सुरेश: विपणिं गच्छति : Suresh went to the market(Suresh(s)Market(b))
सुरेश: त्रिचक्रिका क्रयक्रीत Suresh bought a cycle(Suresh(s)Cycle(b))
Suresh went to the market, brought a cycle(s(a+b))



Conditional Prgramming(If-Then-Else): Panini had made strict rules when two words were being joint or disjoint. At times, it would happen, that these rules may conflict. He again had a set of conditional statements, as per which every time there was a conflict, some rules can "block" other rules based on certain conditions

If X then Y(माथरा कौनदिन्य: न्याय: )
If X then Y else Z(तक्र कौनदिन्य: न्याय: )
If(not X) then Y(निसेधा)
If X then(Y and Z) (विभास: )

And the similarities, rather derivations dont end there. Sanskrit grammar has full support of multiple inheritance, function overloading, data abstraction, transformations...the list is endless. If certain scientists at NASA, and in India are to be believed, Sanskrit could very well be the language for all future communications, including interstellar communication. With hopes that one day this may be true, I would like to bring my post to an end. At some later time, I would wish to pick up the remaining of the software programming paradigms and their Sanskrit origins. But, as of now, I would love to know what you felt about this post.