Sutra is a Sanskrit-style joke programming language inspired by Bhailang. It compiles to JavaScript using a lightweight regex-based compiler (no AST). The project includes a CLI tool published to npm, an interactive web playground built with Next.js and Chakra UI, and comprehensive documentation. Features include syntax highlighting, error handling with precise line/column reporting, and a responsive design with an ancient Indian aesthetic theme.
β¨ Key Features
#
π§ Core Compiler
-
Regex-based Compiler: Lightweight compiler without parser libraries or AST
-
JavaScript Output: Compiles Sanskrit-style code to standard JavaScript
-
Error Handling: Precise error reporting with line and column information
-
Clean Codebase: Maintainable implementation (~250 lines for compiler)
#
π Interactive Web Playground
-
Live Code Editor: Write and execute Sutra code in the browser
-
Syntax Highlighting: Enhanced code readability
-
Real-time Compilation: Instant JavaScript output
-
Copyable Examples: Documentation with copyable code snippets
-
Responsive Design: Works seamlessly on all devices
-
Ancient Indian Theme: Beautiful UI with cultural aesthetic
#
π¦ CLI Tool
-
npm Package: Published as @tarunjawla/sutra
-
Simple Commands: Easy-to-use CLI interface (sutra run file.skt)
-
File Execution: Run Sutra files directly from command line
-
Cross-platform: Works on Windows, macOS, and Linux
ποΈ Architecture
The project consists of three main components:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Web Playgroundβ β CLI Tool β β Core Compiler β
β (Next.js 14) β β (Node.js) β β (JavaScript) β
β React 18 β β npm package β β Regex-based β
β Chakra UI β β β β β
βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ βββββββββββ¬ββββββββ
β β β
ββββββββββββββββββββββββΌβββββββββββββββββββββββ
β
βββββββββββββββΌββββββββββββββ
β JavaScript Output β
βββββββββββββββββββββββββββββ
π Quick Start
#
Using the CLI
1.
Install the package bash
npm install -g @tarunjawla/sutra
2.
Create a Sutra file (file.skt)
sanskrit
// Your Sanskrit-style code here
3.
Run the file bash
sutra run file.skt
#
Using the Web Playground
Visit [sutra-lang.tarunjawla.com](https://sutra-lang.tarunjawla.com/) to use the interactive playground where you can write, compile, and execute Sutra code directly in your browser.
π οΈ Tech Stack
#
Core Compiler
-
Node.js: Runtime environment
-
JavaScript (ES6+): Modern JavaScript features
-
Regex-based Compilation: No external parser libraries
#
Website/Playground
-
Next.js 14: React framework with App Router
-
React 18: UI library
-
Chakra UI 2.8: Component library
-
Framer Motion: Animation library
-
Noto Sans Devanagari: Fonts for Sanskrit aesthetic
#
CLI
-
Node.js: Runtime environment
-
npm: Package distribution
π¦ Project Highlights
- β
Built a working compiler from scratch
- β
Published to npm as @tarunjawla/sutra
- β
Deployed Next.js app to production
- β
Clean, maintainable codebase (~250 lines for compiler)
- β
Full documentation and examples
- β
Comprehensive error handling
- β
Beautiful, responsive design