Showing posts with label sutram. Show all posts
Showing posts with label sutram. Show all posts

Monday, November 19, 2012

The linguistic creamed milk

There are sweets and there are sweets. It is the envy of every NRI, whose friend returns from India after attending sumptuous weddings or festivities, and enumerates the different sweets that were devoured. How many different milk-based sweets and flavors! So much so that, the states are known based on the milk-sweet based identity - whether it is doodh-peda from gujarat or rasagolla from bengal or a simple paayasam from the south.

Amongst all, I would say the poor-man's-king-of-sweet is the "thiratti-paal", literally "condensed milk". Usually it is called "khoa", but the process of preparing them are different. Probably every Indian mom has made this at home. With just 2 to 3 ingredients (milk, curd and sugar or ghee), but a relatively elaborate process of making it, thiratti-paal was sometimes more sought after in our family, matched only by Venky's laddu. Even though all it requires is just to boil the milk and carefully adding curd, getting the right amount of sweetness is an art form. Hasty adding of the curd or letting the cream stick to the bottom of the vessel can quickly spoil the taste. And the best sweets are those that can be savored for a long time without feeling the excessiveness of sugar.
image credit www.mammoos.com

Human mind is remarkably capable of remembering information in summaries and at the same time processing and expounding a piece of information into elaborate details. Honestly speaking, we really do not know how the mind does it. Many of you may remember such exercises from your high school literature classes: analyze and write a detailed essay on the character of Macbeth OR write a short summary of what you learnt from the "crow took the vada from the daadi-ma" story.

The fact that mind can zip information to remember and also unzip information by "filling-in" the gaps, is by itself quite a remarkable talent. No better it is seen than in children, especially toddlers, when they light up to summarize what they learnt, capturing the most interesting and vocal sound-bits. What you also notice is that the larger the information, the less-juicy details tend to quickly get lost and only the meaty and essential stuff reflect in the brains.

Lets take an example: If I mention the words - crow, vada and fox, you can pretty much make up a whole story based on that. Obviously you know the story already, but even if you dont, you can make up a story based on related information that you already know. Another example: "West side story". You might not immediately know the story, but if I just throw in the words "like Romeo and Juliet", a story unfolds in your mind pretty much immediately.

So how small can the information be, in order to not lose its purpose, yet be meaningful enough to expound ?

This was the question that likely tormented our ancient rishis, who were at ease versifying the known and the unknown into musical chandas. Thus came into existence - the "sutram" format that carried the smallest possible information, without losing its context and meaning. It is one of the most remarkable linguistic inventions ever to assist humans remember and retain information with the highest fidelity, that has shaped hinduism and the culture of India. This format has been thoroughly analyzed, distilled, nurtured and turned into an art form by its exponents. It is like several gallons of milk boiled to a handful of cream, carefully adding words only when its imperative. Just like the thiratti-paal, condensing the material unto itself, to extract the sweetness out of it.

For some reason, we are suckers for who those end up in the top. Top 5 songs of the week, top 10 beaches, top 10 smartphones, top 10 poisonous animals, top 20 most powerful people - the list of "tops" are endlessly written and forgotten. Even Samskrita Literature is not spared of this - we do have a "Top 5" in the Sanskrit literature - the pancha-mahA-kAvya: abhijnaana-sakuntalam, raghu-vamsa, kiraataarjuniyam, naishadhiya-caritam and shishupala-vadham. Well, it has been in top 5 for the last 1500 years.

But why stop with just the kavya-literature? I'm partially pained that no one has come up with the "Top 5 sutrams". But whats stopping us, lets come up with our own list!

#5: इको यण् अचि | iko yaN aci | 

This sutram is in our 5th place in the list for two reasons: a) the amount of specific information conveyed in about 5 syllables is equivalent to creating an 8x13 sandhi matrix b) the sutram consists entirely of pratyAhAra-s - which in turn is an encoding of about 25 aksharas.

Panini has come up with several such sutrams, but due to the massive popularity amongst vayyakaraNa-s for quoting this sutram at the drop of the hat, this is our 5th best sutram of the .. err.. last three thousand years.

#4: वृद्धिरादैच् | vriddhiraadaic | 

Yet another gem from Panini, who attempts a technical sutram and managala-sutram at the same time, keeping his promise to be as short as possible. vriddhiH-aat-aic, though technically defining the word "vriddhiH" to be equivalent to aa, ai and au, also conveys that "let there be a vriddhi of this work".

A rare clever pun on both technical and business purposes at the same time, Panini's first sutram of aShTAdhyAyI gets our 4th best.

#3: अथातो ब्रह्म जिज्ञासा | athāto brahma jijñāsā | 

Coming in at number 3, is "the time to enquire about truth". So starts bAdarAyaNa vyAsa in his weaving of formidably cryptic brahma-sutram. The sutrams that have at least given rise to three widely different "matha-s" - from "all is brahman" to "jiva and brahman are fundamentally different", it occupies the foremost place in the "prasthAna-trayI" triplet of intellectual expositions. Similar to the technology world, where no one is an architect unless he/she has a few white papers to his/her credit, no one is a philosopher unless he has written a bhAShyam on brahma-sutram, upanishad-s and bhagavad-gita. The brahma-sutram has fundamentally shaped the philosophy of the Hindus in a very subtle, yet deep way.

#2: योगश्चित्त वृत्ति निरोध: | yogashchitta-vritti-nirodhaH | 

The West have taken over Yoga. Or so it seems. Though yoga is not "owned" by the East, there is a disconcerting wave of misinterpretation about yoga. Fancily-named or self-named yoga techniques have flooded the markets in the last few decades. In the United States alone, yoga is conservatively estimated to be a $6 billion dollar industry. The only ever prop I ever had, when I learnt yoga in India, was an old blanket. Compared to the props available in the modern market, it is very clear that yoga has been stretched for its popularity. I wonder why no one has yet come up with the pricing model of "pay-per-pranayama" - you know, just like the cloud-based models, where you pay per GB or CPU cycle. I'm sure the pricing models like "25 prANAyAma-s per dollar", "two free breath-ins for every breath-out" or "early bird sign ups will get an extra arm twist" will be a run-away hit.

So much ignorance is perpetuated that the original definition of yoga is completely sidelined. Yoga is translated into "union", which is probably the farthest explanation from being anything meaningful.

For giving a mind-blowingly precise definition of yoga, which is the exact opposite of yoga-marketing, namely "Yoga is the cessation of mind-activity" - the patanjali's yoga-sutram occupies the second best sutram in our list. Patanjali has given precise definitions of several other psychological terms, which the modern academia is quietly accumulating into their own curriculum, but we will take his first as the best.

#1: धर्मार्थकामेभ्यो नमः | dharma-artha-kamebhyo namaH | 

Our top most sutram is not from diwali-sounding grammar rules or nuclear-fission like brahma-sutram. It is from a sage who condensed the human feelings of love into sutram format - by far the most innovative application of sutrams and challenging the traditions of his times. No kick-off mangala-sutram or slokam for this guy, and yet he dares to miss a leg of one of the "four pillars" of sanAtana dharma. He could have included the word "mokSha" in his sutram, no one would have cared, but his work is about human emotions and mokSha does not have a definite place.

For being practical, realistic, brazenly bold, innovative and perhaps a path-breaker of his times, Vatsyayana's sutram is the top most in our list of sutrams of the last 3 millenia.

Things may change soon in the next 3000 years, keep watching this space, and until then, dhanyavaadaH !

Tuesday, August 9, 2011

Six degrees of Sutras

One of the memorable humour tracks of Tamil movies is from arivAli (The Intelligent) made in early 1960s. A black white film, with simple clean humour. Very likely such movies were made in other Indian languages too. The husband asks his wife to make puri. Wife does not know how to make it, so husband gives instructions to her:

Husband: Take a vessel and put some wheat flour in it
Wife: Yeah, I know that!
Husband: Pour some water and salt and mix with flour
Wife: Yeah, I know that!
Husband: Make it into small round balls
Wife: Yeah, I know that!
Husband: Flatten it and make it round like appalam
Wife: Yeah, I know that!
Husband: Then what?
Wife: Aah, I dont know that...


In an earlier post we saw how a sutram's definition can be applied to naming convention of variables in modern programming context. A natural question arises - what are the types of sutram-s? As I have mentioned before, classification is ancient Indians' forte. There are six types of sutram-s which is defined, yeah you guessed it, in a shloka:

संज्ञा च परिभाषा च विधि: नियम एव च ।
अतिदेशो अधिकारश्च षड्विधम् सूत्र-लक्षणम् ॥


A lot has been described about this classification in wiki articles and elsewhere. Here we will just look at the parallels between this classification and programming concepts.
संज्ञा - definition; परिभाषा - interpretation; विधि- rules; नियम - restriction; अतिदेश- extension; अधिकार - header/domain.

संज्ञा is a definition sutram. It gives a meaningful name for one or more symbols. Do you remember your early programming days where you are told that a good practice is to give a name for constants? (Do you still follow that?)
 

वृद्धिरादैच् |  [1.1.1]  {a, e, o} are called vRuddhi |
 

In programming terms, this is like the classic C #define statement or final static/const statements in Java/C# world. 

#define PI 3.14

#define IK_PRATYAHARA {i, u, Ru, Lu}


परिभाषा sutram is an interpretation or meta-rules sutram. Its function is to tell how to interpret other sutram-s.
      
तस्मात् इति उत्तरस्य | [1.1.67] When a sutra has a word in panchamI vibhakti, then the word next to it will undergo some modification. 


A very good equivalent to interpretation rules is Annotations. This example will make it clear:


@WebMethod(POST)
public void updateUser() {
}


The annotation says that the method updateUser() must respond to only a http post call. It helps the runtime interpret the method in a certain way.

विधि sutram: What is the fundamental difference between a calculator and a computer? The calculator (a regular) deals with numbers only, while the computer can make logical decisions.

विधि sutram is the classic if-else-condition. In fact, the way पाणिनि has applied it - its closer to aspect-based rules than just a vanilla if-else condition. There is a slight difference between "if do this" and "when apply this". While the if-condition has to be encountered during the execution process thread, a when-rule applies anytime during the happening of a certain condition. "if" is thread-execution based, while "when" is time based, a trigger with an "if".पाणिनि defines several rules in his अष्टाध्यायी. For example there is a famous sandhi rule with just three words, that covers a matrix of sandhi-s.
       
इको यण् अचि | [6.1.78]
When a vowel follows, the letters i, u, Ru, Lu change to y v r l.

Obviously any if-else condition would be a vidhi sutram. If we were to follow paaNini's technique, we would not write it as a simple if condition. Instead we would define all "when rules" in a separate section of the code, and provide aspects of applying. When code executes, the aspects will monitor the code and "apply" a rule when those conditions are satisfied. For eg the (now) Oracle's Haley is one of the very popular Rules Engine products, in which Rules can be defined in simple English.

नियम sutram
If programming was based on socialistic ideologies, rules would apply uniformly to all cases (except the political class, of course). But reality is somewhat capitalistic, so there is always some case which disagrees to agree. Remember the business requirements like "should apply to all but one or two cases" and the complex if-conditions you would have to write to handle just the boundaries?

Restriction is not Exception. Exception is an alternative flow, but restriction is about applying a rule to a lesser number of or rarer cases. In general, it is achieved by if-else conditions, but doesn't always have to be so.

अतिदेश sutram-s are extensions. They qualify a pre-existing rule with another property, not originally possessed.
   
Using pratyaya-s vat and mat, paaNini extends the behaviour of one rule and applies to another rule.
       
लोट: लङ्वत् | [] would mean "लोट् vibhakti-s are to be conjugated just like लङ्"
       
Imagine that
लोट्, लङ् etc implement an interface called "ल". Panini's technique essentially casts लोट् as लङ्.
       
Class extensions are very common in OO languages. Using the Extension mechanism offered by Ruby, C# etc, one can improve the functionality of an existing class. For eg, String class does not have intrinsic methods to check if the value is null or empty . One could add a IsNullOrEmpty(this String) method and operate directly on a string instead of a new helper class.
       
It does not end there. Imagine two objects User and LockedUser:
       
User user; //normal user behaviour
LockedUser lockedUser; //a locked user behaviour, imagine a Trait (see Scala which allows partially implemented interfaces)
if (user.failedAttempts(3)) { user.setBehaviour(lockedUser)); } //user now behaves like a lockedUser

       
Instead of changing the state of the object (commonly via isLocked() or status = LOCKED), the behaviour of the object itself is changed. Upon certain conditions, the regular user adapts the behaviour of a locked user. We do not directly deal with properties and state changes, instead work with behaviour changes. For eg, Scala offers Traits, with partially implementable methods, which are much more than interfaces. In a way you are describing or coding to the behaviour of an object rather than the states.
       
अधिकार sutram: If you have done database modeling, you know Subject Areas. In programming terms, think of package, namespace etc. They all define a domain underwhich certain rules/classes/tables are grouped. Thats exactly what adhikara sutram is. More information on adhikara sutram can be found in this post.
   
संहितायाम् | []  "During the closeness of words"
प्रत्यय: | [3.1.1] "Affix"
       
package com.microsoft.office;
namespace Com.Sun.Oracle.Java;
//ok, I was being facetious :-)


Apart from these core sutram-s there are a few more.

निषेध sutram-s are negation rules of other rules. While niyama sutram-s are positive restrictions, nishedha can be seen as negative orientation.
   
हलन्त्यम् | (consonant endings are it-markers)
न विभक्तौ तुस्माः | (but
letters t, th, d, dh, s, m are not it-markers if it is used for conjugations)
       
In programming, we can come up with a validation rules engine like this:
       
1. All Address Fields Required
2. Not if Address Line 2
       
Imagine the simplicity of a program using such a validation engine!
       
विभाषा sutram is an optional rule. For eg think of the sentence "I would like to goto a movie". You can also say it as "I'd like to goto a movie". The shortening of "I would" to I'd does not change the meaning, and is optional to use. पाणिनि uses this technique to provide alternative usages of words and grammar by using the shabda-s vaa, vibhaaShaa, anyatarasyaam. Optional rules are very common and are done using if conditions.

Besides these, some of the paaNini's techniques also strike a chord with modern techniques. For eg, there is an interpretation sutra विप्रतिषेधे परम् कार्यम्, which means "In case of rule-conflicts, the latter rule prevails". Virtual override feature?

Another unique technique is called स्थानी भाव where a substituting suffix can retain the characteristics of a substituted suffix. Heard of Liskov Substitution Principle? Yeah, something like that.

Panini also uses recursive techniques for some of the rule operations. We will see that in a subsequent post.


Yet another ingenious technique is seen in the last 3 pada-s of अष्टाध्यायी where every previous rule is oblivious to all the latter rule. The rules are arranged in such a way that every rule "thinks" that it is the last rule of the book.


So what is the benefit of comparing modern programming with a 2500+ old text book of grammar? Let it be पाणिनि:, Capellini or Linguini founded algorithms. As a software engineer, what do I care? I do not have an answer. After all, a programmer consultant in US writes a for-loop for $75 an hour, while the same for loop is written by some one in China for a few Yen. Can you judge which for-loop is better?

If several of modern programming concepts have indeed parallels in अष्टाध्यायी, how about some concepts in अष्टाध्यायी not yet formulated into modern programming theories? What if they could create a fundamental change in theory of programming?

What would पाणिनि: think about modern programming concepts? To find out, we shall send Donald Knuth back in time as our representative.

Knuth: Programming is about definitions, rules and algorithms.
पाणिनि: आम्, जानाम्येव !
Knuth: Using algorithms we derive and solve various equations.
पाणिनि: आम्, जानाम्येव !
Knuth: In object oriented programming, we do abstraction, polymorphism and other cool things.
पाणिनि: आम्, जानाम्येव !

Knuth: With functional programming, we define functions, recursions and closures.
पाणिनि: आम्, जानाम्येव !
Knuth: Then we create programs to play games like Grand Theft Auto all day long.
पाणिनि: अहो ! तदहम् न जानामि !!

Sunday, July 10, 2011

Paninian Blues



The brevity of Panini's अष्टाध्यायी has been widely read, wondered, appreciated, criticized, discussed, commented and treatised over the past couple of thousand years. On one end of the Sanskritam literature spectrum are such extremely, almost ridiculously, laser-like focused and concise treatment of subjects in sutram format. On other end stand the lengthy and wordy mega-serial type works from kaadambarI, kathaasaritsaagara, yogavasiShTha (32,000 verses), raamaayaNa (24,000 verses) upto the granpa and granny of all - the mahaabhaarata (100,000) and bhaagavatam. In between are the short-stories focusing as much as possible to the main theme.

Interestingly while raamaayana contains 24000 verses, it has been retold in different variations in a wide variety of formats in different languages, since vaalmIki. In fact the very first 100 slokas contain an abridged version of raamaayaNa by vaalmIki himself. There is a Swati Tirunal's kriti "bhaavayaami raghuraamam" - the story of raama in few stanzas set in different ragas. Very recently was released a visually stunning retell of the story by Sanjay Patel. There is even a eka-shlokI-raamaayaNa which tells raamaayaNa in just one shloka!

आदौ राम तपोवनादि गमनम् हत्वा मृगम् काञ्चनम् ।
वैदही हरणम् जटायु मरणम् सुग्रीव सम्भाषणम्  ।
वाली निग्रहणम् समुद्रतरणम् लङ्कापुरि दहनम् ।
पश्चात् रावण कुम्भकर्ण निधनम् तु एतत् हि रामायणम् ॥

The transformation of a few verses to a delightful and an exquisite kaavya (eg. shaakuntalaa by kaalidaasa) or crunching a big story to a few lines like the above seems to have fascinated Sanskritam poets.

One of the most fascinating पञ्चतन्त्र story is The Blue Jackal. Hunger, sympathy, cunningness, fear, imposture, divine invocation, regality, anger, violence - so much characteristics are packed in a few verses. One can quote several movies on this pose-as-somebody-else-and-take-others-for-a-ride theme and variations. While movies of every language seem to have this kind of comedic setup, the evergreen classic Golmal (Amol Palekar) comes to my mind immediately.

But what if, instead of विष्णु शर्म, पाणिनि had written the पञ्चतन्त्र ? May be he would have reduced the pancha-tantra to pancha-paragraphs.

Lets imagine the blue jackal story, Panini-style. Let paNDita-s forgive me for such a blasphemy.

अरण्ये ।
शृगाल: ।
  - वने कश्चन शृगाल: वसति स्म ।
प्रत्याहारम् भुभुक्षाया: ।
  - स्वस्य भुभुक्षा-कारणत: आहारम् प्रति स: अन्वेषणम् अकरोत् ।
तत्र । (2.1.56)
श्वपदानुसारणात् नीलभाण्डपतितोऽपिसन् ।
    - शुनकै: खेतित: धावित: श्रुगाल: नीलभाण्डे अपतत् ।
परश्च । (3.1.2)
प्रतिपथमेति । (4.4.42)
    - तत्परम् स: वनम् प्रत्यागच्छत् ।
अज्ञाते । (5.3.30)
आत्मने चण्डरव: इति ।
दूतस्य भाग-ब्रह्मणि । (4.4.120)
    - मृगा: तम् न ज्ञातवन्त: । स: शृगाल: "अहम् चण्डरव:, ब्रह्मण: दूत:" इति कथितवान् ।
राजा च । (6.2.59)
वृन्दारक नाग-सिंह-कुन्जरै: पूज्यमान: । (2.2.62)
प्रसंशावचनैश्च । (2.2.66)
    - स्वयम् राजानम् मत्वा सर्वेषु मृगेषु भीति: उत्पादितवान् । मृगा: तं शृगालं प्रशंसवचनै: पूजितवन्त: ।
वृष्टिरादैच् ।
    - एकदा वृष्टि: आकाशात् आगता ।
अन्यैश्च टंकार: ।
    - अन्यै: शृगालै: टंकार: कृत: ।
स्वं रूपम् शब्दस्य (1.1.68)
    - तं शब्दं श्रुत्वा शृगाल: स्वस्य रूपं विस्मृतवान् ।
स्वयं तेन । (2.1.25)
    - तेन शब्देन स्वयं पुर्व-रूपं स्मृत: नीलशृगालेन अपि टंकार: कृत: ।  मृगा: तस्य शब्दस्य अभिज्ञातम् कृतवन्त: ।
हनस्च वध: । (3.3.76)
     - मृगा: चण्डरवम् मरितवन्त: । 
तस्य लोप: । (1.3.9)
    - शृगालस्य लोप: स्यात् ।
तदर्हम् । (5.1.117)
    - स: तद् अर्हति एव ।
The sutram-s with indicated numbers are either a direct lift or lousy modifications of the अष्टाध्यायी sutram-s. The वृत्ति is in blue.

Thursday, November 19, 2009

Sutra based Programming

Haven't software engineers had enough of programming languages? C and C++ were there for a while unchallenged. Then Java took over C/C++ pretty quickly. Even though you could create complex applications using Java and run on any platform, there is no dearth of new languages. Scala, Groovy, Ruby and very recently Go from Google.

All high-level programming languages do 4 basic things:

  1. Assignment
  2. Condition
  3. Loop
  4. Function/Procedure.
Loop and Function/Procedure/Subroutine are essentially glorified Goto.

Everything else is syntactic sugar.

Galileo has influenced us heavily to think math in terms of symbols. A mathematical symbol expresses an idea very concisely and effectively. Much more than a language could do.

So

x = 1
is more concise than saying "let x equal to 1".

Let me rephrase the above bereft of assumptions --


The mathematical expression "x = 1" is more concise than saying it in English "let x equal to 1".

But what if we could express "x = 1" much more concise in a natural language?

For e.g., let me just say

x 1
I just dropped the symbol "=". One symbol less! Whohoo! I also established a convention that whatever on left side is receiver and on the right side is provider. In a language like Sanskrit, for e.g., the "is/happens" is implicit (asti/bhavati). So no other verb is required. (There are other languages that exhibit this property too).

People think that just because ancient Sanskrit mathematicians did not use symbols, the works are not scientific. Symbol is just a convenience; if language could be more powerful than symbols, who needs them? As a side note, Sanskrita almost does not use punctuations (except for end of sentence - the pipeline character |). In contrast, English just can't be "communicated" without appropriate punctuations' usage.

To demonstrate the power of the language, let us look at a simple program using a pseudo-language.

//Pseudo-code to produce a random number and determine if its odd or even
s = 100;
r = (int) rand(s);
if (r % 2 == 0)
return "even";
else
return "odd";
The question is, can this program be expressed using natural language? Of course, we can write the whole program in plain English, but it wont be concise. (COBOL anyone, hello?)

Now lets apply the Sanskrit grammarian Paninian rules. I am going to keep the function names as is (in bold), but conjugate the variable names per Sanskrit rules (taking them to be consonant ending variables).


1: aSeSha: SUnyam  // No remainder 0 (No remainder equals 0)
2: s Satam         // s Satam asti (s is 100)
3: sa: rand r      // of s random is r (r is random of s)
4: int ca          // int also (r is also int of random of s)
5: even ra: aSeshe dvibhAjane  // "even" is of r during division of 2 when no reminder happens (on division by 2 of r has no reminder, it is even)
6: odd SeShe       // "odd" when there is a reminder

Here are the sutras in proper Sanskrit:

अशेष: शून्यम् |
स् शतम् |
स: वृथा र् |
अभिन्न: च |
समं र: अशेषे द्विभाजने |
विषमं शेषे ||

As you can see there are absolutely no mathematical symbols! A program is written purely by the expressive power of language. So what happened? How are they equal?

Using nominative case and the implicit "is", Panini eliminated the need for equals sign. Functions are defined via genetive case. Using the locative case, Panini provides the if-else condition. In effect, mathematical expressions are substituted by simply conjugating the variables.

That is the genius contribution of Panini to Sanskrita! Now a skilled poet could come and rearrange the above 6 sutras into a sloka format, and lo! there is sloka that tells us how to determine an even/odd number!

Let me attempt a half-baked sloka (May Sanskrita enthusiasts forgive me for such a blasphemy).

अशेषो शून्यं भूयात् सेकशतं वृथा रेफ: स: ।
अभिन्नश्च द्विभाजने विषमं समं शेषोऽशेषे ॥

Due to the occurrence of words like SeSha, SUnyam, aSeSha, dvibhAjane, abhinna the above can be mis-interpreted to refer Adisesha, SUnyavAda, Vishnu, Dvaita, Advaita etc. Now we have an example of a sloka referring to the gods and a mathematical algorithm encoded in it!

Tuesday, October 27, 2009

A Sutra for Naming Conventions

Many have heard of Patanjali's yoga sutra, Brahma sutra, Panini sutra etc. Literally it just means 'a thread'. But what is it really? What qualifies as a sutra? When does a sentence become a sutra?

It turns out, there is a definition of sutra. A sutra must exhibhit all 6 characterists to be called so. What are they? As usual the Sanskrit grammarians have come up with a verse that defines a sutra.

alpAkSharam asandigdham sAravat vishvato mukham |
astobham anavadyam cha sUtra: sUtravido vidu: ||

अल्पाक्षरम् असन्दिग्धम् सारवत् विश्वतो मुखम् ।
अस्तोभम् अनवद्यम् च सूत्र: सूत्रविदो विदु: ॥

Source: vaayu puraaNa (anytime before 500 BC)

alpAksharam - Concise
asandigdham - without any doubt ie unambiguous or should have a singular meaning that is conveyed
sAravat - meaningful, ie should not contain gibberish
vishvatomukham - Properly applicable
astobham - devoid of 'stobha' (kind of fillers in Vedic chanting) like hA hU
anavadyam - irrefutable (na avadyam - that which cannot be refuted)

people who know a sutra, know it so.

Now, how does this apply to a programming style?

One of the hardest thing to do in software development is to understand others' code. Every developer would have come across some body else code and claimed it as 'the ugliest piece of code ever seen in life'.

What is an ugly code actually? In general, a hard to understand, spaghetti type code can be considered an ugly code. Typically lot of confusion arises from what the developer is trying to convey by means of the names of variables, classes, methods etc. A novice developer names a variable based on what he or she thinks. An experienced developer names a variable as how a novice would understand it without effort. In general the Shakespearean quote "Whats in a name?" just does not apply to programming. A rose may smell the same even if its called dog-poop, but its definitely a code-smell if naming conventions are poor.

Lets see how each characteristic of this ancient definition sutra applies to naming convention.

alpAksharam: Must be concise.
For eg. age, firstName, addressLine1 etc.

asandigdham: Must be unambiguous.
Eg. temp: What does it denote? A temporary variable? temperature? template?
Eg. Either use 'login' or 'logon' everywhere, but do not mix.
Eg. getReg(): What does it return? Registration? Registry? Regular Expression?
Eg. code, date: What kind of code? What kind of date?

sAravat: Pithy; Meaningful; Should not contain gibberish
eg. clr; tmpk; fru; stp, lzp. Combining this with the alpAksharam and asandigdham rules - will give a proper meaningful name.

vishvatomukham: Properly applicable
For eg, a variable name must have a proper scope. Eg. avoid local method variables having same name as member variables.

astobham: Devoid of unnecessary characters.
Bad eg: intx, a_b_c; Believe me, there are programmers who do this just to confuse others.

anavadyam: Flawless; Irrefutable
A naming of a variable or a class must describe exactly what it says. Another developer should not be given a chance to say "Why didn't you name this differently such that it is understandable?"