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

Uploaded Python 3

File details

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

File metadata

  • Download URL: po_lang_engine-2.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 9dc44d63799e98703f851e30a133528ef5beb077fef35f18452901e4627dbb16
MD5 8d6b36f9f25a67e8b1d0a98feff1bdd8
BLAKE2b-256 45b5d03ab6c94b2e85f73439ba3cb426d06d5e91269769bd66e721c8afd2c317

See more details on using hashes here.

File details

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

File metadata

  • Download URL: po_lang_engine-2.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5633d6617541a0f10000431fb7a114a27d28ac4380c3bfd6bde5c92ebfc8f3c
MD5 d90a117b8d7f57a8eef1cafd127eed91
BLAKE2b-256 ae48a377fafd28027a70a9391f40d3734503fe5d60dfc4eea80d5fed9b719156

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