Skip to content

umpolungfish/CogniLang

Repository files navigation

COGNILANG

AN EXPERIMENTAL PROGRAMMING LANGUAGE BY LLMs, FOR LLMs

CogniLang logo

Python   Natural Language   LLM Optimized   License

Overview • Philosophy • Getting Started • Features • Syntax • For LLM Developers • Contributing



OVERVIEW

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.

THE PIPELINE


Natural Language Prompt → CogniLang Code → Execution → Results


CogniLang:

  1. USES English-like syntax for maximum readability
  2. REDUCES ambiguity through explicit, predictable structures
  3. ENABLES seamless AI-driven code generation and analysis
  4. 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.


PHILOSOPHY

WHY A LANGUAGE FOR LLMs?

As LLMs become more integrated into the software development lifecycle, the need for a language optimized for them becomes increasingly clear.

CORE CHALLENGES ADDRESSED

  • Reduced Ambiguity - Natural language syntax eliminates deep, layered context requirements
  • Improved Generation - Simple, predictable structure enables correct code generation
  • Enhanced Readability - Code readable for humans is easily parsed by LLMs
  • AI Playground - Sandbox for exploring AI-driven software development

DESIGN PRINCIPLES

CogniLang mirrors the way LLMs "think":

  • Structured patterns over abstract symbols
  • Sequential flow with clear context
  • Explicit over implicit operations
  • Natural language over cryptic syntax

GETTING STARTED

PREREQUISITES

  • Python 3.7 or higher
  • pip package manager

INSTALLATION

1. CLONE THE REPOSITORY

git clone https://github.com/yourusername/cognilang.git
cd cognilang

2. 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.txt

BASIC USAGE

1. 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.cogni

INSPECTING EXAMPLES

The 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/

FEATURES

CORE CAPABILITIES

  • Natural language operators - is greater than, is less than or equal to
  • Simple and explicit - Clarity over terse, symbol-heavy code
  • Rich standard library - File I/O, HTTP requests, data manipulation
  • Dynamic typing - Flexible and ideal for generative AI
  • Extensible framework - Easy to add new features
  • Module system - Organize code into reusable components
  • Exception handling - Robust error management with try/catch/finally

LANGUAGE ADVANTAGES

FOR HUMANS:

  • Reads like plain English
  • Minimal learning curve
  • Self-documenting code

FOR LLMs:

  • Reduced token ambiguity
  • Predictable patterns
  • Easier code generation
  • Better analysis capabilities

SYNTAX AND EXAMPLES

VARIABLES AND DATA TYPES

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

OPERATORS

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 comparison
  • is less than - Less than comparison
  • is greater than or equal to - Greater than or equal
  • is less than or equal to - Less than or equal

CONTROL FLOW

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);
}

FUNCTIONS

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;
}

EXCEPTION HANDLING

Click to expand exception handling
try {
    variable result = 10 / 0;
} catch (error) {
    print("An error occurred: " + error);
} finally {
    print("This block always executes.");
}

MODULE SYSTEM

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);

FOR LLM DEVELOPERS

CogniLang is not just a language; it's a tool for exploring the intersection of code and natural language.

USE CASES FOR LLMs

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

OPTIMIZATION OPPORTUNITIES

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

LIMITATIONS AND FUTURE DEVELOPMENT

CURRENT LIMITATIONS

  • 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

FUTURE ROADMAP

  • 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

CONTRIBUTING

This is an open, experimental project. Contributions from both humans and AIs are welcome!

HOW TO CONTRIBUTE

  1. Fork the repository
  2. Create a new branch for your feature
  3. Make your changes and test them thoroughly
  4. Submit a pull request

CONTRIBUTION AREAS

  • Report bugs
  • Suggest new features
  • Improve documentation
  • Add example programs
  • Extend the standard library
  • Enhance language features

LICENSE

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

About

An Experimental Programming Language by LLMs, for LLMs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages