alantech/marsha
Marsha is a functional, higher-level, English-based programming language that gets compiled into tested Python software by an LLM
Marsha AI Language
Marsha is a programming language that uses a large language model (LLM) to turn a simple, human-readable description into working Python code. Instead of writing the code yourself, you describe what you want, give a few examples, and Marsha's compiler uses an AI to generate and test the code for you.
How It Works
- You write a
.mrshfile – a plain text file that contains:- Data types – definitions of the kinds of data you'll work with (like a table with columns).
- Functions – descriptions of what you want the code to do, plus example inputs and expected outputs.
- You run the Marsha compiler – it reads your file, checks that your description is consistent, and then uses an LLM to:
- Generate a test suite (a set of checks based on your examples and description).
- Generate the actual Python code that passes those tests.
- The compiler verifies – it runs the generated code against the test suite. If something fails, it diagnoses whether the code or the test is wrong, and fixes the appropriate one.
This approach makes the output more reliable than just asking an LLM directly, because the tests act as a safety net.
Syntax
The syntax looks like Markdown and is a mix of English and math notation. It's still in alpha, so it may change.
Data types are defined like CSV tables:
# type EmployeeSkills name, skill Bob, math Jake, spreadsheetsYou can also import a type from a CSV file.
Functions have three parts:
- Declaration – a heading that names the function, its input types, and output type.
- Description – a plain-English explanation of what the function should do.
- Examples – a list of example calls and expected results (these become the tests).
Example:
# func get_employee_skills(list of EmployeesByDepartment, list of DepartmentSkills): list of EmployeeSkills This function receives a list of EmployeesByDepartment and a list of DepartmentSkills. The function should be able to create a response of EmployeeSkills merging the 2 list by department. Use the pandas library. * get_employee_skills([], []) = [] * get_employee_skills([EmployeesByDepartment('Joe', 'Accounting')], [DepartmentSkills('Accounting', 'math')]) = [EmployeeSkills('Joe', 'math')]
Compiler Details
- Sanity check – before generating anything, the compiler checks that your definition is self-consistent and warns about ambiguities.
- Oracle-first – it creates the test suite first, then writes code to pass it. This avoids mismatches.
- Fake terminal – during generation, the LLM can “look up” information (like library docs or web pages) by issuing
$commands. This is optional (--no-toolsdisables it). - Optimization – with
--optimize <level>, the compiler runs extra review loops to improve test coverage, code quality, and correctness. - Personas – the review loops use named “personas” (like
sageor custom files) to critique the code and tests. - Language backends – the core logic is language-agnostic; only Python is currently implemented, but the system is ready for more.
Configuration
Marsha needs an LLM provider. By default it uses OpenAI, but you can also use Anthropic or any OpenAI-compatible API (like a local llama.cpp server).
- Set environment variables like
OPENAI_API_KEYorCLAUDE_API_KEY. - Or use a config file at a standard location (e.g.,
~/.config/marsha/config.jsonon Linux). - The
marsha configsubcommand helps manage this file.
Usage
Install via uv or from source, then run:
python -m marsha compile your_file.mrsh
Or, after installing the marsha command:
marsha compile your_file.mrsh
There are many options (see marsha compile --help) for controlling the target language version, debug output, optimization, personas, and more.
Current Status
Marsha is in alpha – the syntax may change. The compiler is best-effort; it aims for 80%+ accuracy on its examples. The more detailed your description and the more examples you provide, the better the results.
All information above is taken directly from the project's README.
Related
- Project
- Project
- Project
- Project
- Project