Built-in Functions & Control Flow

Last modified: 24 May 2026

What is this?

These are the foundational native primitives (like loop, if, and spawnthread) embedded directly into the ArkCode parser.

What is its purpose?

To provide you with extreme power (like spawning OS directories or multi-threading) without requiring you to import any libraries or write heavy boilerplate. Traditional loops and conditionals in C-like languages require excessive brackets, semicolons, and initialization logic. ArkCode strips this down to the absolute essentials.

Where and how it can be used

Use them globally in any ArkCode script. You can use loop(5) to iterate, spawnthread { ... } to execute code asynchronously in the background, or leverage the built-in networking and JSON libraries.

// Make an HTTP GET request
value response = netget("https://api.github.com")

// Parse JSON payload into variables
value data = jsonparse(response)

// Spawn an HTTP server asynchronously
spawnthread {
    netserver(8080) {
        // Handle incoming HTTP request and return JSON response
        value res = jsonstringify(data)
        res
    }
}

How it works

When the AST encounters these specific standard functions, it routes execution directly to optimized C++ native integrations. For instance, spawnthread natively initializes a detached std::thread. The netserver, netget, and netpost commands utilize a custom socket pipeline for lightweight, high-performance networking, and jsonparse/jsonstringify handle fast serialization and deserialization of flat key-value collections.

Where it can't be used and why

You cannot use these functions to execute arbitrary binary machine code payloads or evaluate dynamic C strings. They are rigidly mapped to safe C++ wrappers to ensure the interpreter cannot be exploited by malformed control blocks.