THE JOA LANGUAGE

Examples

Run complete Joa examples for subnet membership, ordered configuration maps, closures, and simulated agent calls with expected output.

Each example is a complete program. Save a block as demo.jo and run go run . demo.jo from the repository root.

Check a network boundary

let trusted = 192.168.1.0/24
let clients = [192.168.1.10, 10.0.0.7]

for client in clients {
    if client in trusted {
        print(str(client) + " is trusted")
    } else {
        print(str(client) + " is outside")
    }
}

print(trusted.split(26)[0])
192.168.1.10 is trusted
10.0.0.7 is outside
192.168.1.0/26

Membership checks are local calculations. This program does not send packets or change access rules.

Read configuration values

let config = {host: "localhost", port: 8080, debug: true}
config["port"] = 9090

print(format("{}:{}", config["host"], config["port"]))
print(config.keys().join(", "))
assert(config.has("host"), "host must be configured")
localhost:9090
host, port, debug

Maps preserve insertion order. Use bracket notation when updating keys.

Keep state with a closure

fn make_counter(start) {
    let count = start
    fn next() {
        count += 1
        return count
    }
    return next
}

let counter = make_counter(40)
print(counter())
print(counter())
41
42

Explore a simulated agent

agent Analyst {
    model: "example-model",
    instructions: "Explain network events."
}

let reply = Analyst.ask("Review the network boundary")
print(reply)
[Agent Analyst (example-model)] Querying: Review the network boundary
[simulated response from example-model]

The current runtime prints a query and returns placeholder text. It makes no network request. See AI agents for the API and its limitations.

More repository examples

The repository includes examples/hello.jo, examples/features.jo, examples/network.jo, and examples/errors_demo.jo. The error demonstration intentionally fails to show diagnostics. Read errors and diagnostics to interpret failures.