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.1.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.1-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: po_lang_engine-2.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a8d8b009794b4084f26f7facc7e902ccdc9b453eda9225cf30cb5bea49828fa2
MD5 5307e6cccc8a65410b4dcf961f05151b
BLAKE2b-256 47f86941c0573440510055d179344c7c157f7171b16a7c719672ce05525810dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: po_lang_engine-2.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9d386f00df28c24948b0a5c81de4ab339aa747fc9b8b2d0b6e5f85d06733b0e
MD5 8d6d8884aac0234bb4086ae39bc125ea
BLAKE2b-256 61362aca851f77218ae9ad6c8dc6681d915cbdbb2be81ea55a56b6327fa711f2

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