A general-purpose programming language that reads like English
NLPL is a production-ready programming language designed to be:
- Natural: Reads like English prose (
set x to 10,if age is greater than 18) - Powerful: Full OOP, generics, pattern matching, inline assembly
- Universal: One language for OS kernels, web apps, system tools, and everything between
- Low-level capable: Direct memory access, FFI, inline x86_64 assembly
- Type-safe: Optional strong typing with inference and generics
# Hello, World in NLPL
print text "Hello, world!"
# Natural language syntax
function greet with name as String
if name is not empty
print text "Hello, " plus name plus "!"
else
print text "Hello, stranger!"
end
end
call greet with "Alice"
- Rc Smart Pointers - Reference counting with automatic cleanup (NEW!)
- LLVM Compiler - Native code generation, 1.80-2.52x C performance (NEW!)
- Pattern Matching - Rust-style match expressions with guards
- Structs & Unions - C-compatible memory layout
- Inline Assembly - x86_64 assembly for system programming
- FFI - Call any C library (with variadic function support!)
- Generics - Full generic types with constraints
- Type Inference - Automatic type deduction
- 62 stdlib modules - Comprehensive standard library
- Classes & Interfaces - Full OOP support
- Memory Management - Direct memory control (malloc/free/pointers)
- Error Handling - Try/catch with custom exceptions
- Module System - Import/export with namespaces
- ✨ Generic types fully working - Parameterless method calls fixed (Feb 8)
- ✨ Rc smart pointers - Reference counting with automatic memory management (Feb 6)
- ✨ LLVM compiler backend - Native code generation, 1.80-2.52x C performance (Feb 6)
- ✨ Pattern matching interpreter - Full match/case/guard support (Feb 2-3)
- ✨ Inline assembly - Direct x86_64 instruction embedding (Feb 2-3)
- ✨ FFI variadic functions - Call printf, fprintf, scanf (Feb 2-3)
- ✨ Comprehensive documentation - 8,000+ lines of guides
git clone https://github.com/Zajfan/NLPL.git
cd NLPL
python src/main.py --versionRequirements: Python 3.8+
Create hello.nlpl:
print text "Hello, NLPL!"
Run it:
python src/main.py hello.nlplSee the Quick Start Guide for a 5-minute tutorial!
# Variables with natural syntax
set name to "Alice"
set age to 25
set scores to [95, 87, 92]
# Functions with type annotations
function calculate_average with numbers as List of Float returns Float
if numbers is empty
return 0.0
end
set total to 0.0
for each num in numbers
set total to total plus num
end
return total divided by (length of numbers)
end
set avg to calculate_average with [95.0, 87.0, 92.0]
print text "Average: " plus (avg to_string)
function classify with value as Integer returns String
match value with
case 0 then return "zero"
case n if n is less than 0 then return "negative"
case n if n is less than 10 then return "small positive"
case n then return "large positive"
end
end
print text classify with -5 # "negative"
print text classify with 3 # "small positive"
print text classify with 100 # "large positive"
# Generic container with type parameters
class Box<T>
property value as T
method get_value returns T
return this.value
end method
method set_value with v as T
set this.value to v
end method
end class
# Create specialized instances
set int_box to new Box<Integer>
set int_box.value to 42
print text call int_box.get_value # 42
call int_box.set_value with 100
print text call int_box.get_value # 100
# Generic pair class
class Pair<K, V>
property key as K
property val as V
method get_key returns K
return this.key
end method
method get_value returns V
return this.val
end method
end class
set coord to new Pair<Integer, Integer>
set coord.key to 10
set coord.val to 20
print text call coord.get_key # 10
print text call coord.get_value # 20
class BankAccount
private balance as Float
function init with self, initial_balance as Float
if initial_balance is less than 0
raise error "Initial balance cannot be negative"
end
set self.balance to initial_balance
end
function deposit with self, amount as Float
if amount is greater than 0
set self.balance to self.balance plus amount
end
end
function withdraw with self, amount as Float returns Boolean
if amount is greater than self.balance
return false
end
set self.balance to self.balance minus amount
return true
end
function get_balance with self returns Float
return self.balance
end
end
set account to new BankAccount with 1000.0
call account.deposit with 500.0
if account.withdraw with 200.0
print text "Withdrawal successful"
end
print text "Balance: " plus (account.get_balance to_string)
# C-compatible struct
struct Point
x as Integer
y as Integer
end
set p to new Point
set p.x to 10
set p.y to 20
# Use with FFI
extern function print_point with pt as Pointer to Point
call print_point with (address of p)
function fast_multiply with a as Integer, b as Integer returns Integer
asm "
mov rax, rdi ; First argument
imul rax, rsi ; Multiply
ret
"
end
set result to fast_multiply with 6, 7 # 42
# Call printf from C standard library
extern function printf with format as String, ... returns Integer
call printf with "Hello from C!\n"
call printf with "Number: %d, Float: %.2f\n", 42, 3.14
# Reference-counted smart pointers
function create_shared_data returns Integer
set x to Rc of Integer with 42
set y to Arc of Integer with 100 # Thread-safe variant
print text "Rc value: " plus (dereference x to_string)
print text "Arc value: " plus (dereference y to_string)
# Automatic cleanup when function returns
return 0
end
Complete documentation available in docs/:
- Quick Start - 5-minute tutorial
- Syntax Overview - Complete syntax reference
- Project Status - Current implementation state (95% v1.0!)
- Pattern Matching - Match expressions guide
- Inline Assembly - x86_64 assembly reference
- Structs & Unions - Memory layout control
- FFI Guide - Foreign function interface
- Stdlib API Reference - All 62 stdlib modules
- Type System - Generics, inference, type checking
- Module System - Imports and exports
- 24+ Tutorial Programs - Numbered by complexity
62 production-ready modules:
math- Mathematical operations (sin, cos, sqrt, pow, ...)string- String manipulation (upper, split, trim, ...)io- File I/O and console operationscollections- Vec, HashMap, Set data structuressystem- OS interactions and process managementnetwork- HTTP, sockets, URLs
vulkan- Vulkan API for GPU programminggraphics- 2D/3D primitivesrendering- Rendering pipelineshaders- Shader compilation
json_utils,csv_utils,xml_utils- Data parsingcompression- gzip, zip, bzip2serialization- Object serialization
asm- Inline assembly utilitiesffi- Foreign function interfacefilesystem- File operationssubprocess_utils- Process spawningthreading_utils- Multithreading
datetime_utils,uuid_utils,validationlogging_utils,testing,regexoption_result- Rust-style Option/Result<T,E>
See full stdlib documentation →
# Basic concepts
python src/main.py examples/01_basic_concepts.nlpl
# Functions and scope
python src/main.py examples/02_functions.nlpl
# Object-oriented programming
python src/main.py examples/04_classes.nlpl
# Pattern matching (NEW!)
python src/main.py examples/15_pattern_matching.nlpl
# Structs and unions (LOW-LEVEL)
python src/main.py examples/24_struct_and_union.nlplAll examples include comments and explanations!
Current Status: 95% Complete
✅ Completed:
- Lexer, parser, AST (15,000+ lines)
- Full interpreter with type checking
- LLVM compiler backend (10,171 lines, Feb 6 2026)
- Rc smart pointers with automatic memory management (Feb 6 2026)
- Pattern matching (Feb 2-3 2026)
- Inline assembly (Feb 2-3 2026)
- FFI with variadic functions (Feb 2-3 2026)
- Struct/Union types (verified complete)
- 62 stdlib modules
- Comprehensive documentation (8,000+ lines)
⏳ Remaining:
- LSP server testing and documentation
- Performance optimizations
- Package manager (post-1.0)
# Run with interpreter (default)
python src/main.py program.nlpl
# Compile to native code with LLVM (1.80-2.52x faster)
python dev_tools/scripts/compile.py program.nlpl
./build/program
# Debug mode (show tokens and AST)
python src/main.py program.nlpl --debug
# Disable type checking
python src/main.py program.nlpl --no-type-check
# Benchmark performance
python benchmarks/benchmark_performance.py ┌─ Interpreter → Runtime (Direct execution)
│
Source (.nlpl) → Lexer → Parser → AST ─┤
│ │
↓ └─ LLVM IR Generator → Native Code (1.80-2.52x faster)
Type Checker (optional)
Components:
- Lexer (1,060 lines) - Tokenizes natural language syntax
- Parser (7,469 lines) - Recursive descent parser
- AST (1,030 lines) - 80+ node types
- Interpreter (2,658 lines) - Direct execution engine
- LLVM Backend (10,171 lines) - Native code generation
- Type Checker (1,541 lines) - Optional type validation
- Runtime (400+ lines) - Memory management, concurrency
- Rc Runtime (430 lines C) - Reference counting library
Total Core: ~25,000 lines of production code
NLPL welcomes contributions! See CONTRIBUTING.md for guidelines.
High-impact areas:
- Performance benchmarking
- LSP server testing
- Example programs
- Bug reports and fixes
NLPL is a full programming language, not a prototype:
- Complete implementations - No placeholders or TODOs
- Production-ready code - Robust error handling
- Real features - No simplified versions
- Proper architecture - No workarounds or hacks
Every feature is built to compete with established languages like C++, Python, and Rust.
| Feature | NLPL | Python | C++ | Rust |
|---|---|---|---|---|
| Natural syntax | ✅ | ❌ | ❌ | ❌ |
| Smart pointers (Rc) | ✅ | ❌ | ✅ | ✅ |
| Native compilation | ✅ | ❌ | ✅ | ✅ |
| Inline assembly | ✅ | ❌ | ✅ | ✅ |
| Pattern matching | ✅ | ✅ (3.10+) | ❌ | ✅ |
| Memory control | ✅ | ❌ | ✅ | ✅ |
| Generics | ✅ | ❌ (runtime only) | ✅ | ✅ |
| FFI | ✅ | ✅ | ✅ | ✅ |
| Easy to read | ✅ | ✅ | ❌ | ❌ |
| Type safety | ✅ | ✅ | ||
| OS development | ✅ | ❌ | ✅ | ✅ |
| Performance | 1.8-2.5x C | ~50x slower | 1.0x (baseline) | 0.9-1.1x C |
NLPL combines:
- Python's readability
- C++'s low-level power
- Rust's safety features
- Its own natural language syntax
- ✅ Core language features (COMPLETE)
- ✅ Pattern matching (COMPLETE - Feb 2026)
- ✅ Inline assembly (COMPLETE - Feb 2026)
- ✅ FFI with variadic functions (COMPLETE - Feb 2026)
- ✅ Comprehensive documentation (COMPLETE - Feb 2026)
- ⏳ LSP testing and docs
- ⏳ Performance optimization
- Package manager (install, publish, dependencies)
- Enhanced debugger (breakpoints, step-through)
- JIT compilation
- LLVM compiler backend optimization
- Self-hosting (NLPL compiler written in NLPL)
- Web compilation (WASM target)
- GitHub: https://github.com/Zajfan/NLPL
- Issues: https://github.com/Zajfan/NLPL/issues
- Discussions: https://github.com/Zajfan/NLPL/discussions
MIT License - See LICENSE for details.
Created by: Zajfan
Contributors: See CONTRIBUTORS.md
Special Thanks:
- Everyone who provided feedback and suggestions
- The open-source community
- Quick Start Guide - Get started in 5 minutes
- Documentation - Complete guides and references
- Examples - 24+ tutorial programs
- Stdlib Reference - 62 modules
- Project Status - Current state (95% v1.0!)
- Roadmap - Future plans
NLPL is a production-ready programming language that combines:
✅ Natural language syntax for readability
✅ Low-level power (assembly, FFI, memory control)
✅ Modern features (pattern matching, generics, type inference)
✅ Comprehensive stdlib (62 modules)
✅ Full OOP support
✅ System programming capabilities
Start coding today! See QUICKSTART.md to get started in 5 minutes.
Version 1.0 coming Q2 2026 - Join us in building the future of programming languages!
Last Updated: February 9, 2026