There are two forms of Sanskrit, the Vedic or Pre-Classical Sanskrit, and the Paninian or Classical Sanskrit.
Vedic Sanskrit is the language used in the Vedas, the huge compilation of Hindu sacred and philosophical texts. The Vedas were composed around 1500 BCE, so the language dates before that. In this period, Sanskrit did not have a written script. The Vedas were memorized and transmitted orally from Guru to Shishya (student). In order to study and understand the Vedas, people had to know the six Vedangas – Vyakaran (grammar), Jyotish (astronomy/astrology), Nirukt (etymology), Shiksha (phonetics), Chandas (meter) and Kalpa (ritual).
Paninian Sanskrit followed grammar rules set down by the famous ancient Indian grammarian Panini. He wrote a grammar treatise called Astadhyayi (Eight Sections), containing 3990 sutras, in the 5th Century BCE. Later, two other ancient grammarians Katyayana and Patajali composed commentaries on the Astadhyayi, the Vartikas and the Mahabhasya respectively. These three grammar works, taken together, are known as Trimuni Vyakarana.