Getting Started with Sanskrit
Table of Contents
- Prerequisites
- Installation
- Your First Sanskrit Program
- Basic Concepts
- Command Line Interface
- Next Steps
- Common Issues
- Getting Help
Prerequisites
Before you begin, ensure you have the following installed:
- Node.js (version 14 or higher)
- npm (usually comes with Node.js)
Installation
Install the Sanskrit programming language using npm:
npm install -g sanskrit-lang
Your First Sanskrit Program
- Create a new file called
नमस्ते.sns
with the following content:
कार्य नमस्ते() {
मुद्रण("नमस्ते विश्व!");
}
नमस्ते();
- Run the program:
sanskrit run नमस्ते.sns
You should see the output: नमस्ते विश्व!
Basic Concepts
1. Functions
Functions are declared using the कार्य
keyword:
कार्य योग(क, ख) {
मुद्रण(क + ख);
}
योग(१०, २०); // Outputs: ३०
2. Strings
Strings can be written in both Devanagari and Latin scripts:
मुद्रण("संस्कृत भाषा"); // Sanskrit text
मुद्रण("Sanskrit Language"); // Latin text
3. Numbers
Use either Devanagari or Arabic numerals:
मुद्रण(१ + २); // Using Devanagari numerals
मुद्रण(1 + 2); // Using Arabic numerals
Command Line Interface
The Sanskrit CLI provides several commands:
# Run a Sanskrit program
sanskrit run program.sns
# Start the REPL (Coming Soon)
sanskrit repl
Next Steps
- Check out the Language Guide for detailed syntax
- Try the Examples
- Join our GitHub community
Common Issues
Installation Problems
If you encounter installation issues:
- Make sure Node.js is properly installed:
node --version
- Try updating npm:
npm update -g npm
- If permission errors occur, try:
sudo npm install -g sanskrit-lang
Running Programs
- Make sure your file has the
.sns
extension - Check that the file is saved with UTF-8 encoding
- Verify that all Sanskrit keywords are correctly typed in Devanagari
Getting Help
- Check the documentation
- Open an issue on GitHub
- Join our community discussions