Installation
Prerequisites
| Requirement | Details |
| C++17 compiler | g++ 7+ or clang++ 5+ |
| Make | make (GNU Make) |
| Git | To clone the repository |
macOS
Option A: One-line install (recommended)
curl -sSL https://raw.githubusercontent.com/phyothant-dev/PT-Programming-Language/main/install.sh | sh
Option B: Install with make
# 1. Install Xcode Command Line Tools (if not installed)
xcode-select --install
# 2. Clone and build
git clone https://github.com/phyothant-dev/PT-Programming-Language.git
cd PT-Programming-Language
make
# 3. Install to /usr/local/bin (optional, so you can run 'pt' from anywhere)
make install
Linux (Ubuntu / Debian)
# 1. Install build tools
sudo apt update
sudo apt install -y git g++
# 2. One-line install
curl -sSL https://raw.githubusercontent.com/phyothant-dev/PT-Programming-Language/main/install.sh | sh
Linux (Fedora / RHEL / CentOS)
# 1. Install build tools
sudo dnf install -y git gcc-c++
# 2. One-line install
curl -sSL https://raw.githubusercontent.com/phyothant-dev/PT-Programming-Language/main/install.sh | sh
Linux (Arch / Manjaro)
# 1. Install build tools
sudo pacman -S git gcc
# 2. One-line install
curl -sSL https://raw.githubusercontent.com/phyothant-dev/PT-Programming-Language/main/install.sh | sh
Windows
1. Download PT-Windows.zip from Releases
2. Extract the zip anywhere
3. Right-click setup.bat → Run as administrator
4. Done!
After that, you can double-click any .pt file to run it, or open Command Prompt and type pt your_program.pt.
To uninstall: run uninstall.bat as administrator.
Hello World
show("Hello, World!");
print("No newline here");
Variables
let name = "PT";
let version = 12;
const PI = 3.14;
show(name); // PT
show(version); // 1
Types
| Type | Example |
| Number | 42, 3.14 |
| String | "hello", `multiline` |
| Boolean | true, false |
| Array | [1, 2, 3] |
| Map | {name: "PT", ver: 9} |
| Function | fn add(a, b) { return a + b; } |
| Class | class Dog { ... } |
| Nil | nil |
Operators
| Operator | Meaning |
is | Equal to |
isnt | Not equal to |
and | Logical AND |
or | Logical OR |
not | Logical NOT |
in | Contains (array/string/map) |
+= -= *= /= | Compound assignment |
i++ i-- | Postfix increment/decrement |
* (string) | Repeat: "ha" * 3 → "hahaha" |
Control Flow
let score = 85;
if (score >= 90) {
show("A");
} elif (score >= 80) {
show("B");
} else {
show("C");
}
unless (score < 50) {
show("You passed!");
}
repeat 3 {
show("Hello!");
}
match (score) {
100 => show("Perfect!")
90 => show("Great!")
_ => show("Keep going!")
}
Functions
fn add(a, b) {
return a + b;
}
show(add(2, 3)); // 5
Lambdas
let double = (x) => x * 2;
let add = (a, b) => { return a + b; };
show(double(5)); // 10
show(add(3, 4)); // 7
Closures
fn counter() {
let n = 0;
return () => {
n += 1;
return n;
};
}
let count = counter();
show(count()); // 1
show(count()); // 2
show(count()); // 3
Arrays
let nums = [3, 1, 4, 1, 5];
push(nums, 9);
show(len(nums)); // 6
show(sort(nums)); // [1, 1, 3, 4, 5, 9]
let doubled = map(nums, (x) => x * 2);
let evens = filter(nums, (x) => x % 2 == 0);
let sum = reduce(nums, (a, b) => a + b, 0);
let squares = [x * x for x in nums];
let big = [x for x in nums if x > 3];
Maps
let user = {name: "Alice", age: 30};
show(user.name); // Alice
show(user["age"]); // 30
user.email = "a@b.com";
show(has(user, "email")); // true
show(keys(user)); // [name, age, email]
Strings
let s = "Hello, World!";
show(len(s)); // 13
show(upper(s)); // HELLO, WORLD!
show(replace(s, "World", "PT")); // Hello, PT!
show(split("a,b,c", ",")); // [a, b, c]
show("ha" * 3); // hahaha
let name = "PT";
show(`Hello, ${name}!`); // Hello, PT!
Classes
class Animal {
name = "";
sound = "";
fn init(name, sound) {
this.name = name;
this.sound = sound;
}
fn speak() {
return this.name + " says " + this.sound + "!";
}
}
class Dog < Animal {
fn init(name) {
this.name = name;
this.sound = "woof";
}
}
let rex = Dog("Rex");
show(rex.speak()); // Rex says woof!
Enums
enum Color {
RED, GREEN, BLUE
}
show(Color.RED); // 0
show(Color.GREEN); // 1
match (Color.RED) {
0 => show("Red!")
1 => show("Green!")
2 => show("Blue!")
}
HTTP Server
httpListen(3000, (req) => {
show(req.method + " " + req.path);
if (req.path is "/") {
return readFile("index.html");
}
if (req.path is "/api/hello") {
return toJSON({message: "Hello from PT!"});
}
return {status: 404, body: "Not Found"};
});
req map: method, path, headers, body
Return a string for HTML, or a map with status, headers, body.
HTTP Client
let resp = httpGet("https://api.example.com/data");
show(resp.status); // 200
show(resp.body); // {"users": [...]}
show(resp.headers); // {content-type: application/json}
let post = httpPost("https://api.example.com/users", toJSON({name: "Alice"}));
let put = httpPut("https://api.example.com/users/1", toJSON({name: "Bob"}));
let del = httpDelete("https://api.example.com/users/1");
JSON
let data = parseJSON('{"name": "PT", "version": 42}');
show(data.name); // PT
show(data.version); // 42
let arr = parseJSON("[1, 2, 3]");
show(arr[0]); // 1
let json = toJSON({hello: "world", count: 5});
show(json); // {"hello":"world","count":5}
let pretty = toJSON({hello: "world"}, true);
show(pretty);
File I/O
let content = readFile("data.txt");
writeFile("output.txt", "Hello!");
let exists = fileExists("data.txt");
SQLite Database
// Open a database (creates file if it doesn't exist)
let db = sqliteOpen("mydata.db");
// Create a table
sqliteExec(db, "CREATE TABLE users (id INTEGER, name TEXT, age INTEGER)");
// Insert data
sqliteExec(db, "INSERT INTO users VALUES (1, 'Alice', 30)");
sqliteExec(db, "INSERT INTO users VALUES (2, 'Bob', 25)");
// Query data
let rows = sqliteQuery(db, "SELECT * FROM users");
show(rows);
// [{id: 1, name: Alice, age: 30}, {id: 2, name: Bob, age: 25}]
// Filtered query
let adults = sqliteQuery(db, "SELECT name FROM users WHERE age > 28");
// Update
sqliteExec(db, "UPDATE users SET age = 31 WHERE name = 'Alice'");
// Delete
sqliteExec(db, "DELETE FROM users WHERE id = 2");
// Close when done
sqliteClose(db);
Crypto & Auth
let hashed = hash("password123");
show(hashed); // SHA-256 hash
let md5hash = hash("hello", "md5");
show(md5hash);
let encoded = base64Encode("Hello, World!");
let decoded = base64Decode(encoded);
show(decoded); // Hello, World!
let id = uuid();
show(id); // 1bd84052-caa0-4bad-ae16-2c52075288e0
Concurrency
fn background() {
sleep(1000);
show("done in background");
}
spawn(background);
show("main continues immediately");
sleep(2000);
PT includes a bytecode VM with variable interning, environment pooling, and optimized opcodes. Here's how it compares to other interpreted languages:
Recursive Fibonacci — fib(30)
| Language | Time |
| Node.js (V8) | 0.005s |
| Python 3 | 0.052s |
| Ruby | 0.049s |
| PT | 0.169s |
Loop Sum — 10M iterations
| Language | Time |
| Node.js (V8) | 0.009s |
| Ruby | 0.204s |
| PT | 0.407s |
| Python 3 | 0.461s |
String Concatenation — 100K iterations
| Language | Time |
| Node.js (V8) | 0.003s |
| PT | 0.004s |
| Python 3 | 0.127s |
| Ruby | 0.244s |
Array Push + Iterate — 100K items
| Language | Time |
| Ruby | 0.002s |
| Python 3 | 0.003s |
| Node.js (V8) | 0.002s |
| PT | 0.016s |
Optimization Results
| Benchmark | v1 | v12 | Speedup |
| Loop 10M | 20.31s | 0.407s | 50x |
| Array 100K | 0.56s | 0.016s | 35x |
| String 100K | 0.63s | 0.004s | 158x |
| fib(30) | 28.48s | 0.169s | 168x |
PT uses a register-based bytecode VM with computed goto dispatch, variable interning, environment pooling, and optimized opcodes for common patterns like i++ and sum += i.
Full benchmark details: bench/