Skip to main content

A high-performance, Python-inspired programming language with bytecode VM, stdlib, and FFI

Project description

Po-Lang Engine v2.0

A high-performance, Python-inspired programming language with a bytecode VM, full standard library, and Python FFI bridge.

Install

pip install po-lang-engine

Quick Start

Create a file hello.po:

keep name = "World"
show "Hello, " + name + "!"

fn greet(person) {
    return "Welcome, " + person
}

show greet("Alice")

Run it:

pop run hello.po

Language Features

Variables & Types

keep age    = 25
keep price  = 9.99
keep name   = "Alice"
keep active = true
keep data   = null
keep items  = [1, 2, 3]
keep config = {host: "localhost", port: 8080}

Control Flow

if age >= 18 {
    show "Adult"
} else if age >= 13 {
    show "Teen"
} else {
    show "Child"
}

Loops

loop i from 0 to 5 {
    show i
}

loop item in items {
    show item
}

while active {
    show "running"
    keep active = false
}

Functions

fn add(a, b) {
    return a + b
}

keep result = add(10, 20)
show result

Classes & Inheritance

class Animal {
    fn init(name) {
        self.name = name
    }
    fn speak() {
        show self.name + " makes a sound"
    }
}

class Dog(Animal) {
    fn speak() {
        show self.name + " says: Woof!"
    }
}

keep dog = Dog("Rex")
dog.speak()

Standard Library

use io
keep content = io.read("file.txt")
io.write("out.txt", "Hello!")
keep lines = io.lines("data.txt")
keep rows = io.csv("data.csv")

use net
keep resp = net.get("https://api.example.com/data")
show resp["status"]
show resp["json"]
keep resp2 = net.post("https://api.example.com/users", {name: "Alice"})

use sys
keep result = sys.run("ls -la")
show result["stdout"]
keep py_ver = sys.env("PYTHON_VERSION")

use json
keep obj = json.parse('{"key": "value"}')
keep text = json.stringify(obj)

use math
show math.sqrt(144)
show math.pi

use time
keep now = time.now()
time.sleep(0.1)

use random
show random.int(1, 100)
show random.float()

use os
show os.cwd()
keep files = os.listdir(".")

use ffi
keep np = ffi.import("numpy")

CLI Commands

pop run file.po           # Run a .po file
pop run file.po --debug   # Run with bytecode disassembly + timing
pop check file.po         # Parse/compile check without running
pop repl                  # Interactive REPL
pop get <package>         # Install a Po-Lang package
pop new myproject         # Scaffold a new project
pop version               # Show version info

Interactive REPL

$ pop repl
Po-Lang REPL v2.0
po> keep x = 42
po> show x * 2
84
po> fn sq(n) { return n * n }
po> show sq(7)
49

Python FFI

Call any Python library from Po-Lang:

use ffi
keep math = ffi.import("math")
show math.sqrt(144)

keep os = ffi.import("os")
show os.getcwd()

Package Manager

Configure your registry with environment variables:

export PO_REGISTRY_URL="https://your-supabase-url.supabase.co"
export PO_REGISTRY_KEY="your-api-key"
pop get my-package

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

po_lang_engine-2.0.2.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

po_lang_engine-2.0.2-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file po_lang_engine-2.0.2.tar.gz.

File metadata

  • Download URL: po_lang_engine-2.0.2.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for po_lang_engine-2.0.2.tar.gz
Algorithm Hash digest
SHA256 1ccb6ceaa6675e338c575c275b777e3486f4407202184ab0ebf1c1d89ff5ec16
MD5 e85abdc8ddcf99a9a589246dd8aab93f
BLAKE2b-256 91a19af0d63d4af7679884e71f9513598ea0a1f67bcf24268255782e5bfa5623

See more details on using hashes here.

File details

Details for the file po_lang_engine-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: po_lang_engine-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for po_lang_engine-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 898553d4258b70b4ad010de1378b4b64d23351755cb16d6b4f0445d0c15a686a
MD5 b9982632db565c65bfb6a4aea663a1fe
BLAKE2b-256 f6dc879769068822edca98a3fdf8f00127afadc7c24aad1f635b5d78b57b1f31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page