The Purp Programming Language - A clean, readable programming language
Project description
Purp 🟣
A programming language designed for humans.
Purp combines the best of Python, Java, and C into one beautifully simple language that anyone can learn in a day but use for a lifetime.
File Extension
All Purp source files use the .purp extension.
Installation
Method 1: Install from PyPI (Recommended)
pip install purp-lang
After installation, you can use the purp command directly:
# Run a Purp program
purp hello.purp
# Start interactive REPL
purp
# Show version
purp --version
Method 2: Install from Source
# Clone the repository
git clone https://github.com/PurpleTrex/purp-lang.git
cd purp-lang
# Install in development mode
pip install -e .
# Now you can use 'purp' command
purp examples/hello.purp
Method 3: Run Directly with Python (No Installation)
# Download purp.py and run directly
python purp.py examples/hello.purp
# Start interactive REPL
python purp.py
Quick Start
Create a file called hello.purp:
say "Hello, World!"
Run it:
purp hello.purp
Hello World
say "Hello, World!"
Features at a Glance
-- Variables (no type declarations needed)
name is "Alice"
age is 25
is_active is true
-- Constants
PI always is 3.14159
-- Functions
define greet(person)
say "Hello, " + person + "!"
end
define add(a, b)
return a + b
end
-- Classes
class Dog
has name
has breed
does bark()
say this.name + " says Woof!"
end
end
my_dog is new Dog()
my_dog.name is "Rex"
my_dog.bark()
-- Control flow
if age >= 18
say "Adult"
else
say "Minor"
end
-- Loops
for i in range(1, 6)
say i
end
for item in items
say item
end
while running
process()
end
-- Lists
numbers is [1, 2, 3, 4, 5]
push(numbers, 6)
first is numbers[0]
-- Maps/Dictionaries
person is {name: "Alice", age: 25}
say person.name
Built-in Functions
| Function | Description |
|---|---|
say(...) |
Print values with newline |
write(...) |
Print values without newline |
ask(prompt) |
Read input from user |
type(value) |
Get type name as string |
length(value) |
Get length of string/list/map |
number(value) |
Convert to number |
text(value) |
Convert to string |
range(start, end) |
Create list of numbers |
push(list, item) |
Add item to list |
pop(list) |
Remove and return last item |
abs(n) |
Absolute value |
round(n) |
Round to nearest integer |
floor(n) |
Round down |
sqrt(n) |
Square root |
Examples
Check out the examples/ directory:
hello.purp- Hello Worldvariables.purp- Variables and typesfunctions.purp- Function definitionscontrol_flow.purp- If/else and loopsclasses.purp- Object-oriented programmingfizzbuzz.purp- Classic FizzBuzzcalculator.purp- Simple calculator
Documentation
See docs/SPECIFICATION.md for the complete language specification.
Project Structure
purp/
├── purp.py # Python-based interpreter (main entry point)
├── build.ps1 # Windows build script
├── src/
│ ├── purp.h # C header file
│ ├── lexer.c # Tokenizer
│ ├── parser.c # Parser
│ ├── interpreter.c # Tree-walking interpreter
│ ├── builtins.c # Built-in functions
│ ├── values.c # Value operations
│ ├── compiler.c # Bytecode compiler
│ ├── vm.c # Virtual machine
│ └── main.c # CLI entry point
├── examples/ # Example .purp programs
└── docs/ # Documentation
└── SPECIFICATION.md # Complete language spec
Requirements
For Python interpreter:
- Python 3.8 or higher
For native compiler (optional):
- GCC, Clang, or MSVC C compiler
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file purp_lang-1.0.0.tar.gz.
File metadata
- Download URL: purp_lang-1.0.0.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5104fd2d1bfb8de628045a35151480205005c641de163caae939329111a992ba
|
|
| MD5 |
e0403dbeac706b73f4beb25847ab6ea4
|
|
| BLAKE2b-256 |
02e3dd320ccfe4247ddb3909e663860b3c0b2605e9b5b4b4e6d5ae7bfdee1048
|
File details
Details for the file purp_lang-1.0.0-py3-none-any.whl.
File metadata
- Download URL: purp_lang-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6c9cb1a526fec2eb9e79e942764bb5d720966a077bf7e99be17f0cbe4d5d822
|
|
| MD5 |
7ccdb56315ad470273e013d772f9ca30
|
|
| BLAKE2b-256 |
0a782fe509b3550736b4696955ba5ae10d357b81e7cd1c8a4e92f4583bef5e46
|