Language Guide

Welcome to the Kit programming language guide. Kit is a functional programming language designed for clarity, expressiveness, and safety. It features immutable data structures, pattern matching, algebraic data types, and a clean, readable syntax.

Quick Start

Language Features

Functional First

Kit embraces functional programming with first-class functions, immutable data, and powerful list operations like map, filter, and fold.

# Transform data with functional operations
numbers = [1, 2, 3, 4, 5]
result = numbers
    |> filter (fn(x) => x % 2 == 0)
    |> map (fn(x) => x * x)

println result  # => [4, 16]

Pattern Matching

Destructure data and handle different cases elegantly with pattern matching.

describe = fn(list) =>
    match list
        | [] -> "empty"
        | [x] -> "single element: ${x}"
        | [head | tail] -> "starts with ${head}"

println (describe [1, 2, 3])  # => "starts with 1"

Algebraic Data Types

Define your own types with variants for modeling complex domains.

type Shape = Circle Float | Rectangle Float Float | Triangle Float Float

area = fn(shape) =>
    match shape
        | Circle r -> Float.pi * r * r
        | Rectangle w h -> w * h
        | Triangle b h -> 0.5 * b * h

println (area (Circle 5.0))  # => 78.54...

Clean Syntax

Kit's syntax is designed to be readable and uncluttered, with minimal punctuation.

# Bindings are simple assignments
name = "Kit"
age = 1

# String interpolation
println "${name} is ${age} year old"

# Pipe operator for chaining
"hello world"
    |> String.split " "
    |> map String.capitalize
    |> String.join " "
    |> println  # => "Hello World"

Learning Path

  1. Install Kit - Set up the compiler on your system
  2. Hello World - Write your first program
  3. Language Tour - Explore Kit's features and syntax
  4. Types - Understand Kit's type system and inference
  5. Functions - Learn about function definitions and closures
  6. Pattern Matching - Master destructuring and matching
  7. Standard Library - Explore built-in modules