Skip to content

Latest commit

 

History

History
211 lines (159 loc) · 5.42 KB

File metadata and controls

211 lines (159 loc) · 5.42 KB

ProXPL v1.4.0: The "Async Engine" Release

Target Release Date: Q3 2026
Status: Planned
Codename: Async Engine


🌟 Overview

ProXPL v1.4.0 delivers a production-ready Async/Await runtime, a real Event Loop scheduler, Generators/Iterators, and the first stable implementation of std.net for networking. This release transforms ProXPL from a synchronous scripting language into one capable of building high-concurrency servers and I/O-bound applications.


✨ New Features

1. Production Async/Await Runtime

Full coroutine-based asynchronous programming with a real scheduler.

async func fetchData(url) {
    let response = await http.get(url);
    return response.body;
}

async func main() {
    // Parallel execution
    let [users, posts] = await all([
        fetchData("https://api.example.com/users"),
        fetchData("https://api.example.com/posts")
    ]);

    print("Users: " + to_string(length(users)));
    print("Posts: " + to_string(length(posts)));
}

Implementation Details:

  • Stackful coroutines implemented in C (using setjmp/longjmp or platform fibers)
  • LLVM Coroutines support for the AOT path
  • Event loop with epoll (Linux), kqueue (macOS), IOCP (Windows)
  • async func compiles to coroutine frame allocation
  • await suspends current coroutine and yields to scheduler
  • New built-in functions: all(), race(), sleep(), timeout()
  • New opcodes: OP_ASYNC_CALL, OP_AWAIT, OP_YIELD, OP_RESUME

2. Generators and Iterators

Lazy evaluation with yield keyword.

func* range(start, end) {
    let i = start;
    while (i < end) {
        yield i;
        i = i + 1;
    }
}

func* fibonacci() {
    let a = 0;
    let b = 1;
    while (true) {
        yield a;
        let temp = a;
        a = b;
        b = temp + b;
    }
}

// Usage
for (let n in range(0, 10)) {
    print(to_string(n));
}

// Take first 20 fibonacci numbers
let fibs = take(fibonacci(), 20);

Implementation Details:

  • func* syntax for generator functions
  • yield keyword suspends generator and returns value
  • for...in loop integration with iterator protocol
  • Lazy evaluation — values computed on demand
  • Built-in helpers: take(), skip(), filter(), map() for iterators
  • New AST nodes: DECL_GENERATOR, EXPR_YIELD
  • New opcodes: OP_GENERATOR, OP_YIELD_VALUE, OP_ITERATOR_NEXT

3. Networking Standard Library (std.net)

First-class networking support.

use std.net;

// TCP Server
async func startServer() {
    let server = net.listen("0.0.0.0", 8080);
    print("Server listening on port 8080");

    while (true) {
        let conn = await server.accept();
        handleConnection(conn);  // Non-blocking
    }
}

async func handleConnection(conn) {
    let data = await conn.read();
    await conn.write("HTTP/1.1 200 OK\r\n\r\nHello from ProXPL!");
    conn.close();
}

// HTTP Client
async func fetch(url) {
    let response = await net.http.get(url);
    print("Status: " + to_string(response.status));
    print("Body: " + response.body);
}

Modules:

Module Functions
std.net.tcp listen(), connect(), accept(), read(), write(), close()
std.net.udp bind(), sendTo(), recvFrom()
std.net.http get(), post(), put(), delete(), request()
std.net.url parse(), encode(), decode()

4. Enhanced for...in Loops

Unified iteration syntax for all collection types.

// Arrays
for (let item in [1, 2, 3]) { print(to_string(item)); }

// Dictionaries (key-value)
for (let [key, val] in {"a": 1, "b": 2}) {
    print(key + " = " + to_string(val));
}

// Strings (character iteration)
for (let ch in "hello") { print(ch); }

// Ranges
for (let i in 0..10) { print(to_string(i)); }

// Generators
for (let fib in take(fibonacci(), 10)) { print(to_string(fib)); }

5. JSON Standard Library (std.json)

Native JSON parsing and serialization.

use std.json;

let data = json.parse('{"name": "ProXPL", "version": "1.4.0"}');
print(data["name"]);  // "ProXPL"

let str = json.stringify(data, indent: 2);
write_file("output.json", str);

🐛 Bug Fixes

ID Description Component
BUG-201 Fix event loop starvation under heavy I/O Runtime/scheduler
BUG-202 Fix coroutine frame memory leak on early return GC/coroutines
BUG-203 Properly propagate async exceptions through await chains VM/async
BUG-204 Fix for loop iterator variable scoping Parser/compiler

📊 Compiler Changes

Component Change
Lexer New tokens: TOKEN_YIELD, TOKEN_IN, TOKEN_RANGE_OP (..)
Parser Generator declarations, for...in loops, range expressions
Bytecode Gen Coroutine frame opcodes, iterator protocol opcodes
VM Event loop integration, coroutine scheduler, fiber stack management
LLVM Backend LLVM Coroutine intrinsics for AOT async functions

📈 Performance Goals

  • Event loop: Handle 10,000+ concurrent connections
  • Coroutine context switch: < 50ns
  • Generator iteration: On par with native for loop (< 2x overhead)

🔧 Breaking Changes

  • async keyword now reserved (cannot be used as identifier)
  • yield keyword now reserved
  • in keyword now reserved for for...in loops

ProXPL v1.4.0 — Async by design, concurrent by default.