Overview • Philosophy • Getting Started • Features • Syntax • For LLM Developers • Contributing
CogniLang is an experimental programming language designed with a unique purpose: to be a language that is both created by and intuitive for Large Language Models.
It focuses on readability and natural language constructs, aiming to bridge the gap between human-readable code and the patterns that LLMs can easily understand, process, and generate.
Natural Language Prompt → CogniLang Code → Execution → Results
CogniLang:
- USES English-like syntax for maximum readability
- REDUCES ambiguity through explicit, predictable structures
- ENABLES seamless AI-driven code generation and analysis
- PROVIDES a sandbox for exploring LLM-optimized programming
The core of CogniLang is built on the principle that programming languages should mirror how LLMs process information: structured, sequential, and context-rich patterns.
As LLMs become more integrated into the software development lifecycle, the need for a language optimized for them becomes increasingly clear.
|
CogniLang mirrors the way LLMs "think":
|
- Python 3.7 or higher
- pip package manager
1. CLONE THE REPOSITORY
git clone https://github.com/yourusername/cognilang.git
cd cognilang2. SET UP THE ENVIRONMENT
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Linux/Mac
# or
venv\Scripts\activate # On Windows
# Install dependencies
pip install -r requirements.txt1. CREATE A COGNILANG FILE
Place your CogniLang code into a file with the .cogni extension (e.g., hello.cogni)
2. RUN YOUR PROGRAM
python -m cognilang.run_test cogni_files/comprehensive_test.cogniThe repository includes several example programs demonstrating language features:
# Run the comprehensive feature demo
python -m cognilang.run_test cogni_files/comprehensive_test.cogni
# Explore other examples in the cogni_files directory
ls cogni_files/
|
FOR HUMANS:
FOR LLMs:
|
Click to expand variable syntax
BASIC VARIABLES
variable name = "Alice";
variable age = 30;
variable is_student = false;
SUPPORTED DATA TYPES
| Type | Example | Description |
|---|---|---|
| Numbers | 10, 3.14 |
Integers and floating-point |
| Text | "Hello, World!" |
String values |
| Booleans | true, false |
Logical values |
| Nothing | nothing |
Null/None equivalent |
| Lists | [1, "apple", true] |
Ordered collections |
| Dictionaries | {"name": "Bob", "age": 42} |
Key-value pairs |
| Sets | {1, 2, 3} |
Unique value collections |
Click to expand operator syntax
ARITHMETIC OPERATORS
variable sum = 10 + 5;
variable difference = 10 - 5;
variable product = 10 * 5;
variable quotient = 10 / 5;
COMPARISON OPERATORS
if age is greater than 18 {
print("You are an adult.");
}
if score is less than or equal to 100 {
print("The score is valid.");
}
NATURAL LANGUAGE COMPARISONS
is greater than- Greater than comparisonis less than- Less than comparisonis greater than or equal to- Greater than or equalis less than or equal to- Less than or equal
Click to expand control flow structures
IF STATEMENTS
if condition is true {
// Code executes if condition is true
} else {
// Code executes otherwise
}
WHILE LOOPS
variable counter = 0;
while (counter < 5) {
print("Counter: " + counter);
counter = counter + 1;
}
FOR-IN LOOPS
variable fruits = ["apple", "banana", "cherry"];
for fruit in fruits {
print("Fruit: " + fruit);
}
Click to expand function syntax
BASIC FUNCTION DEFINITION
function greet(name: text) -> text {
return "Hello, " + name + "!";
}
variable message = greet("World");
print(message);
TYPED PARAMETERS
Functions support type annotations for clarity:
function add(a: number, b: number) -> number {
return a + b;
}
Click to expand exception handling
try {
variable result = 10 / 0;
} catch (error) {
print("An error occurred: " + error);
} finally {
print("This block always executes.");
}
Click to expand module examples
MODULE DEFINITION (math_utils.cogni)
variable PI = 3.14159;
function add(a: number, b: number) -> number {
return a + b;
}
MODULE IMPORT (main.cogni)
import {add, PI} from "math_utils";
variable result = add(5, 3);
print("Result: " + result);
print("PI: " + PI);
CogniLang is not just a language; it's a tool for exploring the intersection of code and natural language.
| Code Generation | Natural language syntax simplifies prompt-to-code translation |
| Code Analysis | Simple structure enables accurate analysis and documentation |
| Language Evolution | Participate in identifying and suggesting new intuitive features |
| Pattern Discovery | Explore how LLMs naturally express computational logic |
As an LLM working with CogniLang, you can:
- Identify common patterns in generated code
- Suggest syntactic improvements based on usage analysis
- Propose new natural language constructs that improve clarity
- Contribute to the standard library with commonly needed functions
- Performance - Interpreted execution may be slower than compiled languages
- Type system - Dynamic typing may not catch all errors at parse time
- Ecosystem - Limited third-party libraries compared to established languages
- Tooling - IDE support and debugging tools are still developing
- Enhanced type inference system
- Performance optimizations
- Expanded standard library
- IDE integration and language server protocol support
- Additional debugging and profiling tools
- Community-driven feature development
This is an open, experimental project. Contributions from both humans and AIs are welcome!
- Fork the repository
- Create a new branch for your feature
- Make your changes and test them thoroughly
- Submit a pull request
- Report bugs
- Suggest new features
- Improve documentation
- Add example programs
- Extend the standard library
- Enhance language features
CogniLang is available in the public domain. See the UNLICENSE file for details.
A language that speaks the way machines think
CogniLang - because natural language is the ultimate API