veko-lang.org
Download Free EPUB 3.0

Part I · Mental Model & Rosetta Stone

Chapter 1

The Veko Rosetta Stone & Language Ergonomics

Side-by-side Go, Rust, Python, and TypeScript translations plus Day-1 vs Day-14 fluency scores

SYNTAX & HOMOICONICITY

Whitespace Disambiguation & Two-Pass Pratt Homoiconic Engine

How [tight] vs [spaced] tokens let kebab-case prefix calls coexist cleanly with infix math, UFCS chains, and macros.

LEXICAL DISAMBIGUATION lexer.vk TWO-PASS PRATT ENGINE parser.vk HOMOICONIC EVALUATION macro_eval.vk + lib/dialect.vk Token stream Typed literals Arity table AST + RawBlock Block values Lexer4 Whitespace Rules[tight] vs [spaced] bits LexerFirst-Class Literals5s, 64kb, 0xFF, '...' Parser Pass 1Pass 1: Signature Scanfn / struct / def / use Parser Pass 2Pass 2: Pratt PrecedenceBP 80 postfix .. BP 10 pipe Homoiconicityquote & composeCode-as-Data Templates Dialectsparse-block DialectsEmbedded Domain Grammars
Component & ModuleArchitectural Role
4 Whitespace Rules
lexer.vk
Eliminates grammar ambiguity using single-character attachment flags.
First-Class Literals
lexer.vk
Parses human-readable durations, binary sizes, hex/binary ints, and UTF-8 strings.
Pass 1: Signature Scan
parser.vk
Collects top-level function arities, refinements, structs, and module imports.
Pass 2: Pratt Precedence
parser.vk
Binds tight postfix chains, prefix word arguments, infix math, comparisons, and \ pipes.
quote & compose
macro_eval.vk
Treats [ ... ] blocks as inspectable values and splices computed expressions cleanly.
parse-block Dialects
parser.vk + lib/dialect.vk
Matches typed pattern rules over homoiconic blocks to drive custom DSLs.

Recipe 1.1: Translating Go, Rust, Python & TypeScript Habits into Idiomatic Veko

Newcomers write fluent Veko fastest when they see familiar constructs side-by-side with their idiomatic Veko counterparts:

TaskGo / Rust / Python / TS HabitIdiomatic Veko (.vk)
Call a 2-arg functionos.WriteFile(path, data)os/write-file path data
Nested call in math / loopwhile i < len(items)while i < (len items) [ ... ]
Call a 0-arg functionhostBinPath()host-bin-path
Subtraction & divisionn-1, total/countn - 1, total / count (spaces required!)
Negative literal argumentseek(fd, -1)seek fd -1 (tight -1, spaced after fd)
Strings & interpolationf"https://{host}:{port}"`https://{host}:{port}` or 'literal\n'
1-arg method chainsraw.trim().toLowerCase()raw.trim.lower
Multi-step data pipelineitems.filter(...).map(...)items \ filter fn [x] [...] \ map fn [x] [...]
In-place buffer mutationbuf.push(10) / push(&mut buf, 10)bytes/push mut buf 10 (mut on both sides)
Fallback on error / missing keyif err != nil / try...catchport = str/to-i64/or raw [ 443 ]
Propagate contextual errorreturn fmt.Errorf("...: %w", err)raw = os/read-file/or p [e -> return (err read {p}: {mold e})]
Unit return / JSON nullNone / null / () / nil.ok (unit action) and .null (wire JSON null)

Recipe 1.2: Side-by-Side Service Function — Go & Rust vs. Veko

Consider loading a JSON peer list over HTTPS with a 3-second timeout, falling back to a local cache file, filtering active endpoints, and returning trimmed URLs.

In Go (imperative error sprawl):

GO
func activePeers(endpoint string) ([]string, error) {
    client := &http.Client{Timeout: 3 * time.Second}
    resp, err := client.Get(endpoint)
    var raw []byte
    if err != nil {
        raw, err = os.ReadFile("peers.cache.json")
        if err != nil {
            return nil, err
        }
    } else {
        defer resp.Body.Close()
        raw, err = io.ReadAll(resp.Body)
        if err != nil {
            return nil, err
        }
    }
    var peers []Peer
    if err := json.Unmarshal(raw, &peers); err != nil {
        return nil, err
    }
    var urls []string
    for _, p := range peers {
        if p.Active {
            urls = append(urls, strings.TrimSpace(p.URL))
        }
    }
    return urls, nil
}

In Idiomatic Veko (peers.vk):

VEKO
use [nc = net/client, j = json]

pub active-peers = fn [endpoint str] block[str] [
    raw = (nc/get/or endpoint (nc/RequestOpts { timeout = 3s }) [
        body_str = os/read-file/or 'peers.cache.json' [e ->
            return (err `peer lookup failed: {mold e}`)
        ]
        nc/HttpResponse { status = 200, reason = 'OK', headers = {}, body = (bytes/from-str body_str), final_url = endpoint }
    ]).body

    (bytes/to-str raw)
        \ j/decode
        \ filter fn [p] [ p.active ]
        \ map fn [p] [ p.url.trim ]
]

Notice how Veko eliminates both hidden exceptions and repetitive if err != nil blocks while keeping every failure boundary explicit on the page.

Recipe 1.3: Readability & Writability vs. Other Languages

Because Veko combines single-owner ORO systems memory (Native, WebAssembly 3.0, and 64-bit VM targets with zero GC pauses) and Rebol/Elixir-inspired expression ergonomics, its learning curve splits distinctly between Day 1 familiarity and Day 14 fluency:

DimensionScoreWhy
First-hour familiarity5.5 / 10Unlearning f(x), n-1, "strings", and null takes deliberate attention for the first few hours.
Steady-state readability9.0 / 10Near-zero syntactic noise; explicit mut at call sites; /or eliminates both hidden exceptions and 4-line error boilerplate; linear \ dataflow.
Steady-state writability8.5 / 10Very low ceremony, gradual types (prototype dynamically, lock down --strict-types for production), and homoiconic blocks/templates. Slight tax from fixed-arity memorization and explicit mut.
  • vs. Go (Readability: Veko >= Go | Writability: Veko > Go): Go and Veko both reject hidden magic. Veko pulls ahead on signal-to-noise ratio by replacing vertical if err != nil { return nil, err } repetition with inline /or [ ... ] and \ pipelines, while Go leads on Day-1 C-syntax familiarity and third-party IDE ecosystem size.
  • vs. Rust (Readability: Veko >> Rust | Writability: Veko >> Rust): Both enforce ownership, explicit mutation (&mut vs mut), and zero-GC safety. Veko delivers single-owner determinism, shared-nothing spawn/chan, and .secret taint safety without <'a, T: Send + Sync + 'static>, Arc<Mutex<...>>, or turbofish ::<> noise — trading away only complex multi-lifetime borrow graphs.
  • vs. Zig (Readability: Veko > Zig | Writability: Veko > Zig): Zig's catch |err| and orelse are close cousins to Veko's /or, and both prize defer and explicitness. Veko is faster to write and scan for networking, CLI, codec, web, and backend work (built-in strings/maps, backtick templates, pipes, gradual typing), while Zig stays lower-level for raw OS kernels or custom allocators.
  • vs. Elixir / Clojure / Rebol (Readability: Veko >= Elixir, > Clojure/Rebol | Writability: Tie): Captures Elixir's |> (\ in Veko) and Lisp's quote/compose homoiconicity without outer parenthesis walls — and solves classic Rebol's dynamic-arity scaling hazard via lexical scoping, explicit use/pub modules, mut borrow checking, and --strict-types.
  • vs. Python / TypeScript (Readability: Tie | Writability: Day-1 Python/TS > Veko; Maintenance Veko > Python/TS): Python and TypeScript feel effortless on Day 1 because everyone already knows their syntax, whereas over time hidden exceptions, None/undefined landmines, shared-reference mutation, and async/await coloring erode clarity. Veko reads like clean pseudocode while encoding mutation, errors, secrets, and capabilities directly on the page.