Start here

Zy tutorials

These short, runnable examples introduce the language. Each .zy file includes the code first and a commented Output: section at the bottom.

The agent tutorial demonstrates simulated calls, keyword matching, and printed security messages. See status and limitations for the actual behavior.

How to Run

From the project root:

.\bin\zy.exe examples\tutorials\01-basics.zy
.\bin\zy.exe examples\tutorials\02-strings-and-lists.zy
.\bin\zy.exe examples\tutorials\03-maps-config.zy
.\bin\zy.exe examples\tutorials\04-network-subnets.zy
.\bin\zy.exe examples\tutorials\05-semantic-agent.zy

You can also rebuild the interpreter first:

go build -o bin/zy.exe .

Snippet 1: Basics

File: examples/tutorials/01-basics.zy

Use this to introduce the core language shape: let bindings, fn functions, if/else if, while, and for.

let service = "checkout-api"
let load = 72

fn status_label(percent) {
    if percent >= 90 {
        return "critical"
    } else if percent >= 75 {
        return "busy"
    }
    return "healthy"
}

print("Status: " + status_label(load))

Snippet 2: Strings and Lists

File: examples/tutorials/02-strings-and-lists.zy

Use this to show method chaining and list helpers:

let raw_event = "  LOGIN failure from Admin  "
let normalized = raw_event.trim().lower().replace(" ", "_")

let severities = ["low", "critical", "medium"]
severities.append("high")

print(normalized)
print(severities.sort())

Snippet 3: Maps as Config

File: examples/tutorials/03-maps-config.zy

Use this when discussing small structured objects and dynamic updates:

let service = {
    name: "payments",
    port: 8443,
    replicas: 3
}

service["replicas"] = service.replicas + 2
print(service.keys())

Snippet 4: Native Networking

File: examples/tutorials/04-network-subnets.zy

This is the strongest Zy-specific snippet for backend and infrastructure readers:

let office = 10.20.0.0/16
let app_vlan = office.split(18)[1]
let app_host = 10.20.64.25

if app_host in app_vlan {
    print("host allowed")
}

Snippet 5: Semantic Agent Workflow

File: examples/tutorials/05-semantic-agent.zy

Use this near the end of the post to connect semantic matching, AI agents, and security primitives:

agent SecurityMonitor {
    model: "gemini-2.0-pro",
    temperature: 0.1,
    instructions: "Classify infrastructure security events in one sentence."
}

let payload = "login retry storm using leaked passwords"

if payload ~ "password security threat" {
    let verdict = SecurityMonitor.ask("Classify: " + payload)
    print(verdict)
}
Found something to improve?Edit this page on GitHub ↗
Search guides, language features, and APIs ↵ to open first result