Functions & Native Interop
Last modified: 24 May 2026
What is this?
The ark keyword is the universal function definer, handling standard scopes and closures. Furthermore, ArkCode features powerful Native Interop functions—cpp and glsl—which allow developers to execute raw, unabstracted native code directly inside the ArkCode runtime.
What is its purpose?
To provide elegant logic separation via ark, while ensuring you are never truly "locked out" of low-level optimization. If a developer needs raw hardware pointers or massive computational pipelines that ArkCode abstracts away, they can seamlessly bypass the interpreter using cpp or glsl.
Where and how it can be used
Use ark to build named routines or closures. Use cpp to embed raw C++ blocks, and simply call the block name to trigger JIT compilation and execution. Use glsl for rendering pipelines.
// 1. Standard ArkCode function
ark processData() {
print("ArkCode logic...")
}
// 2. Raw C++ Embedded Execution
cpp native_worker("""
std::cout << "Raw C++ Execution Engine Activated!" << std::endl;
""")
// 3. GLSL Shader Definitions
glsl myshader("""
void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }
""")
ark main() {
native_worker // Instantly executes the C++ block above
shader.render = myshader // Assigns the GLSL to the render pipeline
}How it works
The parser dynamically checks the tokens following ark, cpp, and glsl. While ark blocks are mapped as AST nodes, cpp blocks are uniquely special. When you invoke a cpp identifier, the ArkCode engine writes the raw string to a temporary .cpp file, executes g++ -shared to compile it dynamically (JIT), and then loads the binary directly into memory using dlopen to execute the code at raw native speeds.
Where it can't be used and why
Because the cpp keyword relies on g++ and dlopen to orchestrate JIT evaluation, it cannot be used on locked-down host machines where external compilation is restricted. The host machine running the aake interpreter must have a C++ compiler installed to resolve the cpp blocks.