A modern, high-performance programming language designed for scientific computing and data science workloads.
- Indentation-based syntax - Clean, Python-like syntax with proper block parsing
- Static type system - Type inference and type checking
- Functions and classes - Support for functions, classes, and methods
- Rich type system - Integers, floats, strings, booleans, lists, arrays, maps, and user-defined types
- Doc comments - Python-style doc comments with automatic documentation generation
- Lexer and Parser - Complete lexer and parser with indentation-based block parsing
- Type Checker - Full type checking with type inference
- IR Generation - Intermediate representation (IR) builder
- Code Generation - LLVM IR (stable) and MLIR (experimental IR dump) generation
- Optimizations - SSA transformation, constant folding, dead code elimination
- Interpreter - Runtime interpreter for testing and development
- JIT Compilation - Runtime code generation with LLVM ORC (optional, requires LLVM 21+)
- REPL - Interactive shell with command history and debug commands
- LSP Server - Language Server Protocol implementation with:
- Diagnostics and error reporting
- Code completion with context-aware suggestions
- Hover tooltips with doc comments
- Function location finding
- VS Code Extension - Full VS Code integration with syntax highlighting and LSP support
- Code Formatter - Automatic code formatting
- Documentation Generator - Generate documentation from source code
- painpkg - Package manager with:
- Dependency resolution (semver)
- Package installation from local sources (
file://) and experimental Git sources (git://,git+clones only) pain.tomldependency management- Local file-based registry with indexing
- Memory Management - Bump allocator and garbage collector
- Object Model - Runtime object representation for lists, arrays, and user-defined types
- Math functions:
abs,min,max,sqrt,pow,sin,cos,floor,ceil - String functions:
len,concat,substring,contains,starts_with,ends_with,trim,to_int,to_float,to_string - List/Array functions:
len(indexing and literals supported) - I/O functions:
print - PML (Pain Markup Language):
pml_load_file,pml_parse- Load and parse PML configuration files
- Rust toolchain (install from rustup.rs)
- LLVM (optional, for LLVM backend)
# Clone the repository
git clone --recursive https://github.com/pain-lng/pain.git
cd pain
# Build all components
cargo build --release
# Build specific components
cargo build --release --package pain-compiler
cargo build --release --package pain-lsp
cargo build --release --package painpkg# Run a Pain source file
cargo run --package pain-compiler -- run --input example.pain
# Or use the installed binary
pain run example.pain# Generate LLVM IR
pain build --input example.pain --output example.ll
# Build executable
pain build --input example.pain --executable
# Use MLIR backend (experimental IR dump)
pain build --input example.pain --backend mlir --output example.mlir- Check:
pain check --input path/to/file.pain— parse + type-check without running. - Format:
pain format --input src/main.pain --stdout— pretty-print to stdout or overwrite file. - Run via interpreter:
pain run --input examples/loop.pain. - REPL:
pain repl— interactive shell with history and debug commands (:vars,:funcs,:classes). - Build optimized binary:
pain build --input examples/app.pain --executable --backend llvm. - Generate docs:
pain doc --input src/lib.pain --output docs/lib.mdorpain doc --stdlib. - Package manager:
painpkg init demo && painpkg install && painpkg run.
fn main():
print("I love Pain!")
let x = 10
let y = 20
let sum = x + y
print(sum)
9B10 PML is a minimalistic declarative data format for configurations and UI structures:
config.pml:
app:
name: "My App"
version: "1.0.0"
debug: falsemain.pain:
fn main():
let config = pml_load_file("config.pml")
let app_name = config.app.name
print("Starting " + app_name)
See docs/PML_SPEC.md for complete PML documentation.
This is a workspace containing multiple crates:
- pain-compiler - Main compiler implementation
- pain-lsp - Language Server Protocol server
- pain-runtime - Runtime library (allocator, GC, object model)
- painpkg - Package manager
- High-level guides live in
docs/:docs/quickstart.md– installation, running programs,painpkg.docs/stdlib.md– summary of built-in APIs.docs/examples.md– ready-to-run snippets.docs/PML_SPEC.md– PML (Pain Markup Language) specification.docs/examples_pml.md– PML usage examples.docs/JIT_SETUP.md– JIT compilation setup guide.
- Generate fresh API docs from source:
cargo run -p pain-compiler -- doc --stdlib
cargo run -p pain-compiler -- doc --input source.painRun benchmarks to compare performance:
# Run all benchmarks
cargo bench
# Compare with Python/Rust/C++
cd benches
python compare.py allLicensed under the Apache License, Version 2.0. See LICENSE file for details.
Contributions are welcome! Please see the project structure and submit pull requests to the appropriate submodule repositories.
- Compiler: pain-compiler
- LSP Server: pain-lsp
- Runtime: pain-runtime
- Package Manager: painpkg
See docs/DEVELOPMENT.md for the branch/CI workflow (main/develop/feature).
- GitHub topics (add to
pain,pain-compiler,pain-runtime):
programming-language,compiler,llvm,mlir,rust,ai,hpc
Example using GitHub CLI:
gh repo edit pain-lng/pain --add-topic programming-language --add-topic compiler ... - Logo guidance
- Org avatar: square SVG/PNG at least 512×512 px (transparent background preferred).
- README hero image: reuse the same asset at ~200 px width near the top (store in
assets/logo.svgorassets/logo.png). - Keep a monochrome variant handy for dark/light backgrounds if we publish on other portals.