About 500 BCE Panini, an Indian grammarian from Pushkalavati (Sanskrit: पुष्कलावती), an ancient site situated in the Peshawar valley in the Khyber Pakhtunkhwa province (formerly NWFP) of Pakistan (then Gandhara), composed his formulation of 3,959 rules of Sanskrit morphology known as Ashtadhyayi. This was the earliest known work on descriptive linguistics. It included the concepts of the phoneme, the morpheme, and the root, and metarules, transformation, and recursion.
"Sometime around 500 B.C., the ancient scholar Panini analyzed the Sanskrit language at a level of complexity that has never been matched since, for any language. His grammar, the Ashtadhyayi, comprises some 4,000 rules meant to generate all the possible sentences of Sanskrit from roots of sound and meaning — phonemes and morphemes. The rules include definitions; headings; operational rules, including “replacement, affixation, augmentation and compounding”; and “metarules,” which call other rules recursively. Sound familiar? Panini’s grammar of Sanskrit bears more than a family resemblance to a modern programming language. As Chandra says, the grammar is itself “an algorithm, a machine that consumes phonemes and morphemes and produces words and sentences.” This is not a coincidence. American syntactic theory, Chomsky channeling Panini, formed the soil in which the computer languages grew" (James Gleick, "A Unified Theory. [Review of] 'Geek Sublime' by Vikram Chandra," The New York Times, August 22, 2014, Accessed 08-21-2014).