COMPLETE SYNTAX & ARCHITECTURE SPECIFICATION

Language Reference Manual

TezzNative combines the clean clarity of Python with bare-metal native performance, built-in SIMD, native tensors, Erlang-style actor supervision, and zero garbage collection pauses.

1. Type System

TezzNative is statically typed with compile-time verification and zero runtime overhead. Built-in primitive types map directly to CPU registers and native SIMD vectors.

// Primitive scalar types
let a:int = 42              // 64-bit signed integer
let b:float = 3.14159       // 64-bit double precision float
let c:char = 'Z' as char    // 8-bit character
let s:str = "TezzNative"    // UTF-8 string slice

// Built-in SIMD Vector Types
v4:Vec4f                    // 128-bit SIMD vector (4 x f32)
v8:Vec8f                    // 256-bit AVX vector (8 x f32)

2. Variables, Scoping & File I/O

Variables are declared with optional let or direct type annotation name:type = value. The standard io module provides high-throughput buffered and streaming file operations.

import "io"

fn process_file(path:str) -> int:
  h:*File = io.file_open(path, "w")
  if h == 0:
    ret 0 - 1

  io.file_write_line(h, "TezzNative High-Performance I/O")
  io.file_close(h)
  say "File written successfully to:", path
  ret 0

3. Control Flow

Clean indentation-based blocks with if / else, while loops, and arithmetic modulo operators.

let count:int = 0
while count < 10:
  if count % 2 == 0:
    say count, "is even"
  else:
    say count, "is odd"
  count = count + 1

4. Functions & Tail-Call Optimization (TCO)

Functions compile to standard native calling conventions with register-passed arguments. Tail-recursive functions are automatically optimized into zero-overhead loop jumps without stack growth.

// Guaranteed Tail-Call Optimized Fibonacci
fn fib_tail(n:int, a:int, b:int) -> int:
  if n == 0: ret a
  if n == 1: ret b
  ret fib_tail(n - 1, b, a + b)  // Lowered to zero-overhead JMP

fn main() -> int:
  say "fib(10) =", fib_tail(10, 0, 1)
  ret 0

5. Structs & Memory Layout

Structs lay out fields continuously in memory without hidden padding. Dot syntax works seamlessly on values (val.field) and pointers (ptr.field).

struct TensorShape:
  ndim:int
  rows:int
  cols:int
  total_elements:int

fn create_matrix(rows:int, cols:int) -> TensorShape:
  shape:TensorShape
  shape.ndim = 2
  shape.rows = rows
  shape.cols = cols
  shape.total_elements = rows * cols
  ret shape

6. Concurrency & Erlang-Style Actor Supervision

TezzNative features robust Erlang-style process supervision with isolated mailboxes, message passing, restart policies, and fault tolerance built into the core runtime.

import "actor"

fn main() -> int:
  sys:*ActorSystem = actor.system_new(4, 2, 2)
  if sys == 0:
    ret 1

  worker:int = actor.spawn(sys, "worker")
  actor.send(sys, worker, 10, 1, 0, 0, 0)
  say "Actor spawned with ID:", worker
  say "Mailbox length:", actor.mailbox_len(sys, worker)

  actor.system_free(sys)
  ret 0

7. Native Deep Learning Tensors & SIMD Kernels

First-class tensor primitives with SIMD AVX-512 and SSE accelerated kernels. Supports multidimensional representations, stride manipulation, and hardware-accelerated computation.

import "tensor"

fn main() -> int:
  // Allocate SIMD-aligned 2D tensor descriptor [128 x 512]
  desc:TensorDesc = tensor.tensor_desc(128, 512, tensor.tensor_dtype_f32(), tensor.tensor_device_cpu(), 64)
  say "Tensor shape rows:", desc.rows, "cols:", desc.cols
  say "Total elements:", desc.size, "allocated bytes:", desc.bytes
  ret 0

8. Native Audio Subsystem (TTS Engine)

Integrated native text-to-speech synthesis with zero external dependencies. Supports customizable voice profiles, speech rate, pitch tuning, and direct speaker output.

import "tts"

fn main() -> int:
  // Initialize native neural/rule-based TTS engine
  eng:*TtsEngine = tts.tts_new()
  tts.tts_speak(eng, "Welcome to TezzNative voice assistant.")
  tts.tts_free(eng)
  ret 0

9. High-Performance GUI Framework

Native 60 FPS immediate-mode desktop GUI framework with rounded surfaces, anti-aliased font rendering, theme palettes, and input event dispatching.

import "tezzui"

fn main() -> int:
  ui:TzUI
  ui_create(&ui, "TezzNative Desktop App", 800, 600)
  while ui_alive(&ui) != 0:
    ui_begin(&ui)
    ui_rect_r(&ui, 50, 50, 700, 100, TZ_SURFACE, 16)
    ui_label(&ui, 80, 85, "Hello TezzNative Native GUI!", TZ_ACCENT, 2, 1)
    ui_end(&ui)
  ret 0

10. Unsafe Blocks & Low-Level Hardware Access

TezzNative guarantees safety for all regular code. When low-level hardware memory, pointer arithmetic, or OS driver interaction is required, explicit unsafe: blocks isolate raw pointers.

fn peek_raw_byte(addr:int) -> int:
  byte_val:int = 0
  unsafe:
    ptr:*char = addr as *char
    byte_val = ptr[0] as int
  ret byte_val