Getting Started with Sanskrit

Table of Contents

  1. Prerequisites
  2. Installation
  3. Your First Sanskrit Program
  4. Basic Concepts
    1. 1. Functions
    2. 2. Strings
    3. 3. Numbers
  5. Command Line Interface
  6. Next Steps
  7. Common Issues
    1. Installation Problems
    2. Running Programs
  8. 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

  1. Create a new file called नमस्ते.sns with the following content:
कार्य नमस्ते() {
    मुद्रण("नमस्ते विश्व!");
}

नमस्ते();
  1. 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

  1. Check out the Language Guide for detailed syntax
  2. Try the Examples
  3. Join our GitHub community

Common Issues

Installation Problems

If you encounter installation issues:

  1. Make sure Node.js is properly installed:
    node --version
    
  2. Try updating npm:
    npm update -g npm
    
  3. 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


Copyright © 2024 Sanskrit Programming Language. Distributed under an MIT license.