A general-purpose programming language with English-like syntax that matches or exceeds the power of ASM, C/C#/C++.
NLPL is designed to make programming more accessible by using natural English-like syntax while maintaining the power and performance of traditional programming languages like C++. It combines readability with powerful features including:
- Low-level memory management
- Object-oriented programming
- Concurrency and parallel processing
- Natural error handling
- Strong typing with clear semantics
NLPL uses verb-based commands and contextual keywords to create code that reads like English sentences:
Create an integer called counter and set it to 0
instead of:
int counter = 0;Create a <type> called <name> [and set it to <value>]
Define a function called <name> that takes <parameters> and returns <type>
<function body>
End
If <condition> [then]
<statements>
Otherwise
<statements>
End
While <condition>
<statements>
End
Repeat for each <item> in <collection>
<statements>
End
Allocate a new <type> in memory [with value <expression>] and name it <identifier>
Free the memory at <identifier>
Define a class called <name>
It has a <type> property called <name>
Define a method called <name> that takes <parameters> and returns <type>
<method body>
End
End
Create a <class> called <object>
Run these tasks at the same time:
<task 1>
<task 2>
...
End
Try to
<statement>
But if it fails
<error handling>
End
NLPL is implemented in Python and consists of several components:
- Lexer: Tokenizes the natural language input
- Parser: Converts tokens into an Abstract Syntax Tree (AST)
- Interpreter: Executes the AST
- Runtime: Provides the execution environment
- Python 3.8+
- Required packages (install via
pip install -r requirements.txt)
git clone https://github.com/yourusername/nlpl.git
cd nlpl
pip install -r requirements.txtExecute a file:
python -m nlpl.main path/to/your/program.nlplStart interactive REPL:
python -m nlpl.main
# or
python nlpl_repl.pyWith options:
python -m nlpl.main --debug # Enable debug mode
python -m nlpl.main --no-type-check # Disable type checking
python -m nlpl.main program.nlpl --repl # Run file then enter REPLNLPL includes a powerful interactive REPL (Read-Eval-Print Loop) with:
- Multi-line input: Automatic detection of incomplete statements
- Command history: Navigate previous commands with arrow keys (persistent)
- Auto-completion: Tab completion for keywords, variables, functions
- Error recovery: Catch exceptions and continue running
- Special commands:
:help,:vars,:funcs,:debug,:reset, etc.
Example REPL session:
>>> set x to 42
=> 42
>>> function greet with name as String returns String
... return "Hello, " plus name
... end
=> greet
>>> greet with "World"
=> Hello, World
>>> :vars
Variables:
x = 42
greet = <function>
See docs/7_development/repl.md for full REPL documentation.
# Define a calculator class
Define a class called Calculator
It has a float property called result
Define a method called add that takes float a and float b and returns float
Create a float called sum and set it to a plus b
Return sum
End
End
# Use the calculator
Create a Calculator called calc
Call calc.add with 5, 3
Print calc.result # Outputs: 8
See the src/examples directory for more comprehensive examples.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by natural language processing and traditional programming languages
- Designed to bridge the gap between human language and computer code