The Zenith Language

Zenith is a modern, high-performance interpreted language designed for simplicity, readability, and power. Built with Rust, it bridges the gap between easy-to-learn scripting languages and robust systems programming.

This project was officialy developed by only VibeSlayer. Contributions are completely open! Zenith is stable for learning and scripting. It can be used to start programming but not developing softwares

Why Zenith?

Readable Syntax

English-like keywords (`set`, `is`, `define`) make code self-documenting.

Zero Dependencies

Single binary executable. No runtime environments to install.

Developer First

Built-in IDE with autocomplete, syntax highlighting, and instant run.

Quick Start

Here is a complete program that demonstrates the core features of Zenith.

// 1. Variables
set name = "Zenith User"
set level = 1

// 2. Functions
fn level_up(current) {
    return current + 1
}

// 3. Control Flow
if level less 10 {
    print("Beginner Mode")
    set level = level_up(level)
} else {
    print("Expert Mode")
}

// 4. Collections
set items = ["Sword", "Shield"]
array_push(items, "Potion")

set i = 0
while i less array_len(items) {
    print("Item: " + items[i])
    set i = i + 1
}

// 5. Structures
structure Hero with name, hp
set player = create Hero with name = name, hp = 100
print(player.name)

Installation

Zenith is distributed as a portable executable. No installation wizard required.

Steps

  1. Download the latest release (`.zip`) for your OS (Windows/Linux/macOS).
  2. Extract the folder to a location of your choice (e.g., `C:\Zenith`).
  3. Add the folder to your system `PATH` if you want to use the CLI globally.

Running the IDE

Double-click `ide.exe` (Windows) or run `./ide` (Linux/Mac) to start the integrated environment.

Antivirus Warning Because Zenith is a new, unsigned binary, Windows Defender may flag it. You may need to "Run Anyway" or add an exception.

Using the IDE

The Zenith IDE is a terminal-based tool designed for rapid prototyping.

Keyboard Shortcuts

Key Action
F5 / Ctrl+R Run current code
Ctrl+S Save file
Ctrl+O Open file
Esc Close popup / menus
Tab Autocomplete / Indent

Syntax Basics

Zenith syntax is minimal and whitespace-agnostic (mostly). It uses clear keywords to avoid ambiguity.

Comments

// This is a single-line comment.
// Multi-line comments are not supported yet.

Blocks

You can use C-style braces or Ruby-style keywords.

// Style 1: Braces (Recommended)
if true {
    print("Hello")
}

// Style 2: Keywords
if true then
    print("Hello")
end

Identifiers

Must start with a letter or underscore. Case-sensitive.

  • Valid: userName, _id, item1
  • Invalid: 1item, user-name (hyphens not allowed)

Variables & Types

Zenith is dynamically typed. Variables are declared with set.

Variable Naming Rules

Identifiers in Zenith must follow these rules:

  • Must start with a letter (a-z, A-Z) or an underscore (_).
  • Can contain letters, numbers (0-9), and underscores.
  • Cannot contain hyphens (-) or other special characters.
  • Case-sensitive: myVar is different from myvar.
Reserved Keywords The following words cannot be used as variable names: set, to, define, fn, return, if, elif, else, then, end, while, repeat, times, structure, create, with, import, true, false, null, and, or, not, is.

Declaration

set x = 10        // Number
set _temp = 0     // Valid identifier
set user_id = 1   // Valid identifier
set 1st = "no"    // Invalid (starts with number)

Data Types

Type Description
Number 64-bit float (double). Covers integers and decimals.
String UTF-8 text sequence.
Bool true or false.
Array Dynamic list of values.
Map Key-value pairs (String keys).
Struct User-defined object.

Operators

Arithmetic

+ Add / Concatenate
- Subtract
* Multiply
/ Divide

Comparison

Zenith supports both symbols and words for readability.

== / is Equality
!= Inequality
< / less Less than
> / greater Greater than

Logic

and, or, not.

if (x greater 5) and (y is not null) { ... }

Control Flow

If / Else

if score greater 90 {
    print("A")
} elif score greater 80 {
    print("B")
} else {
    print("C")
}

While Loop

set count = 0
while count less 5 {
    print(count)
    set count = count + 1
}

Repeat Loop

A simplified loop for iterating N times.

repeat 3 times {
    print("Knock")
}

Functions

Functions are reusable blocks of code that perform specific tasks. In Zenith, functions are first-class citizens, meaning they can be assigned to variables, passed as arguments, and returned from other functions.

Basic Syntax

fn greet(name) {
    return "Hello, " + name
}

print(greet("Zenith")) // Output: Hello, Zenith

Parameters and Return Values

Functions can take any number of parameters. If a function does not explicitly return a value using the return keyword, it returns null by default.

fn add(a, b) {
    return a + b
}

fn log(msg) {
    print("[LOG] " + msg)
    // Returns null implicitly
}

Higher-Order Functions

Since functions are values, you can pass them to other functions. This is powerful for creating flexible APIs.

fn apply(func, value) {
    return func(value)
}

fn square(x) {
    return x * x
}

print(apply(square, 5)) // Output: 25

Closures

Functions defined inside other functions "capture" the variables from their surrounding scope. This allows for data privacy and factory patterns.

fn make_counter() {
    set count = 0
    
    fn increment() {
        set count = count + 1
        return count
    }
    
    return increment
}

set counter = make_counter()
print(counter()) // 1
print(counter()) // 2
Scope Rules Variables declared inside a function are local to that function. They cannot be accessed from outside. However, inner functions can access variables from outer functions.

Arrays & Maps API

Arrays API

Arrays are ordered, dynamic lists of values.

array_len(arr) -> Number

Returns the number of elements in the array.

array_push(arr, val)

Adds val to the end of the array.

array_pop(arr) -> Value

Removes and returns the last element. Returns null if empty.

array_push_front(arr, val)

Adds val to the beginning of the array.

array_pop_front(arr) -> Value

Removes and returns the first element. Returns null if empty.

array_insert(arr, idx, val)

Inserts val at index idx. Throws if index out of bounds.

array_remove(arr, idx) -> Value

Removes element at idx. Throws if index out of bounds.

array_set(arr, idx, val)

Overwrites element at idx with val.

array_slice(arr, start, end) -> Array

Returns a new array from start (inclusive) to end (exclusive).

array_concat(a, b) -> Array

Returns a new array containing elements of a followed by b.

array_reverse(arr)

Reverses the array in-place.

array_fill(len, val) -> Array

Creates a new array of size len filled with val.

array_join(arr, delim) -> String

Joins elements into a string using delim.

array_contains(arr, val) -> Bool

Returns true if the array contains val.

Array Examples

// 1. Creating and Modifying
set numbers = [10, 20, 30]
array_push(numbers, 40)
array_set(numbers, 0, 99)
print(numbers) // [99, 20, 30, 40]

// 2. Iterating
set i = 0
while i less array_len(numbers) {
    print("Value: " + numbers[i])
    set i = i + 1
}

// 3. Stack Operations
set stack = []
array_push(stack, "A")
array_push(stack, "B")
set top = array_pop(stack) // "B"

Maps API

Maps are key-value stores (dictionaries). Keys must be strings.

map_new() -> Map

Creates and returns a new empty map.

map_set(map, key, val)

Sets key to val. If key exists, it is overwritten.

map_get(map, key) -> Value

Returns the value for key, or null if not found.

map_has(map, key) -> Bool

Returns true if the map contains key.

map_keys(map) -> Array

Returns an array of all keys in the map (order not guaranteed).

map_len(map) -> Number

Returns the number of entries in the map.

Map Examples

// 1. Creating and Accessing
set user = map_new()
map_set(user, "name", "Alice")
map_set(user, "role", "Admin")

if map_has(user, "name") {
    print("User: " + map_get(user, "name"))
}

// 2. Iterating Keys
set keys = map_keys(user)
set i = 0
while i less array_len(keys) {
    set key = keys[i]
    set val = map_get(user, key)
    print(key + ": " + val)
    set i = i + 1
}

Structures

Structs are lightweight data containers.

structure Point with x, y

set p1 = create Point with x = 10, y = 20
print(p1.x)
Validation Zenith checks that you provide all fields when creating a struct. Missing fields will cause an error.

Imports (NOT FULLY IMPLIMENTED YET)

The import statement allows you to include other Zenith files.

import "utils.zen"

Currently, imports are shallow (copy-paste mechanism). Namespaces are not yet supported.

Input / Output

print(value)

Writes a value to standard output with a newline.

input(prompt) -> String

Reads a line from standard input.

Math Library

All math functions accept and return numbers (64-bit floats).

math_pi

Constant: 3.14159...

math_e

Constant: 2.71828...

math_abs(x)

Absolute value.

math_floor(x)

Rounds down to nearest integer.

math_ceil(x)

Rounds up to nearest integer.

math_round(x)

Rounds to nearest integer.

math_min(a, b)

Returns the smaller of two numbers.

math_max(a, b)

Returns the larger of two numbers.

math_clamp(x, min, max)

Constrains x between min and max.

math_pow(base, exp)

Raises base to the power of exp.

math_sqrt(x)

Square root.

math_log(x)

Natural logarithm (ln).

math_log10(x)

Base-10 logarithm.

math_sin(x)

Sine (radians).

math_cos(x)

Cosine (radians).

math_tan(x)

Tangent (radians).

math_asin(x)

Arc sine.

math_acos(x)

Arc cosine.

math_atan(x)

Arc tangent.

math_hypot(x, y)

Euclidean distance (hypotenuse).

math_lerp(a, b, t)

Linear interpolation between a and b.

math_sign(x)

Returns 1, -1, or 0.

math_random(min, max)

Pseudo-random number between min and max.

math_is_nan(x) -> Bool

Returns true if x is Not-a-Number.

range(start, end) -> Array

Returns array of numbers from start to end (exclusive).

parse_int(str) -> Number

Parses string to integer number, or null if failed.

Strings

Utilities for text manipulation.

str_len(s) -> Number

Returns length of string (bytes).

str_split(s, delim) -> Array

Splits string by delimiter.

str_replace(s, old, new) -> String

Replaces all occurrences of old with new.

str_substr(s, start, end) -> String

Returns substring from start to end indices.

str_contains(s, sub) -> Bool

Checks if string contains substring.

str_find(s, sub) -> Number

Returns index of first occurrence, or -1.

str_starts_with(s, sub) -> Bool

Returns true if string starts with substring.

str_ends_with(s, sub) -> Bool

Returns true if string ends with substring.

str_to_upper(s) -> String

Converts string to uppercase.

str_to_lower(s) -> String

Converts string to lowercase.

str_trim(s) -> String

Removes whitespace from both ends.

str_repeat(s, count) -> String

Repeats string count times.

char_at(s, idx) -> String

Returns character at index.

is_digit(s) -> Bool

Returns true if string contains only digits.

is_alpha(s) -> Bool

Returns true if string contains only letters.

File System

Permissions File operations have full access to the user's file system.
read_file(path) -> String

Reads entire file contents as a string.

write_file(path, content)

Writes content to file, overwriting if exists.

fs_exists(path) -> Bool

Returns true if path exists.

fs_is_dir(path) -> Bool

Returns true if path is a directory.

fs_mkdir(path) -> Bool

Creates directory recursively. Returns true on success.

fs_delete(path) -> Bool

Deletes file or directory. Returns true on success.

fs_list(path) -> Array

Returns array of file names in directory.

fs_size(path) -> Number

Returns file size in bytes, or -1 on error.

fs_rename(old, new) -> Bool

Renames/moves a file or directory.

fs_copy(src, dst) -> Bool

Copies a file. Returns true on success.

fs_abs_path(path) -> String

Returns absolute canonical path.

fs_permissions(path) -> Map

Returns map with keys like readonly.

System & OS Library

system(cmd) -> String

Executes a shell command (via cmd /C or sh -c) and returns the stdout output.

sleep(ms)

Pauses execution for ms milliseconds.

time_now() -> Number

Returns the current timestamp (seconds since Unix Epoch).

exit(code)

Terminates the program immediately with the given exit code.

os_name() -> String

Returns the operating system name (e.g., "windows", "linux").

os_args() -> Array

Returns command-line arguments as an array of strings.

os_env(key) -> String | Null

Returns the value of an environment variable, or null if unset.

os_cwd() -> String

Returns the current working directory path.

os_cpu_count() -> Number

Returns the number of logical CPU cores.

os_pid() -> Number

Returns the current process ID.

assert(cond, msg)

Throws a runtime error with msg if cond is false.

panic(msg)

Immediately stops execution with a runtime error message.

OS Examples

// 1. Executing Shell Commands
set output = system("echo Hello")
print(output)

// 2. Environment Variables
set path = os_env("PATH")
if path is not null {
    print("PATH found")
}

// 3. System Info
print("OS: " + os_name())
print("Cores: " + os_cpu_count())

Type Conversion

to_string(val) to_number(val) type_of(val)

Runtime Errors

Common errors you might encounter while running Zenith programs.

Error Description Common Fix
Type Mismatch Operation performed on incompatible types (e.g., adding Number to Map). Check variable types using type_of(). Ensure correct types for operators.
Index Out of Bounds Accessing an array index that does not exist. Check array_len() before accessing. Arrays are 0-indexed.
Unknown Identifier Using a variable or function that hasn't been defined. Check for typos. Ensure variable is declared with set before use.
Invalid Argument Count Calling a function with too few or too many arguments. Check function definition and provide correct number of arguments.
Division by Zero Dividing a number by 0. Add a check: if divisor != 0 before dividing.
Stack Overflow Infinite recursion or too many nested function calls. Ensure recursive functions have a base case (exit condition).
File Not Found Trying to read a file that doesn't exist. Check file path. Use fs_exists() before reading.
Permission Denied OS blocked file access (e.g., writing to system folder). Run IDE as Administrator or check file permissions.
Parse Error Syntax error in code (e.g., missing brace). Check line number reported. verifying matching {} and ().
Struct Field Missing Creating a struct without initializing all fields. Provide values for all fields defined in structure.

Troubleshooting

IDE not running?

Ensure you have `ide.exe` and `compiler.exe` in the same folder.

Known Bugs

Interactive Input input() does not work inside the IDE output window. Use an external terminal.
Break/Continue Loops do not yet support `break` or `continue`.

Zenith Programming Language © 2026