Skip to content

Syntax & Basics

TeRiRi_606 edited this page Mar 21, 2026 · 1 revision

Syntax & Basics

Freak uses the .fk file extension and features a clean, modern syntax designed for readability and power.

Basic Structure

Every executable Freak program starts with a main function.

fn main() {
    // Your code goes here
}

Control Flow

Freak supports standard control flow mechanisms, enhanced for modern paradigms (as seen in control_flow.fk).

if / else / else if

while loops

Standard iterative loops

Functions & Closures

Functions are first-class citizens in Freak. You can assign them to variables, pass them as arguments, and create closures (closures.fk).

fn apply_twice(f, x) {
    return f(f(x));
}

The Maybe Type

To handle null-safety gracefully, Freak implements a Maybe pattern (maybe.fk), preventing unexpected runtime crashes by forcing the developer to handle both the existence and absence of a value.

Operator Overloading

Freak allows you to redefine how standard operators (+, -, *, ==) work for your custom structs and objects (operator_overload.fk). This is especially useful for mathematical implementations (e.g., vectors, matrices, or shapes.fk).

Strings & Bytes

Freak provides robust standard types for handling text (strings.fk) and raw data (bytes.fk).

Freak-Lang Wiki

Welcome to the Freak Language!

🚀 Introduction

Home

Installation & Setup

📖 Language Guide

Syntax & Basics

Functions & Closures

Control Flow

Advanced Features (Operator Overloading, Maybe)

Async: Isekai & Eventually

🛠 Tooling

The Freak CLI

Hangar Package Manager

🤝 Contributing

Compiler Architecture

Contributing Guide

Clone this wiki locally