Skip to main content

Welcome to Dryft

Dryft is an experimental stack-based concatenative programming language that brings together elegant syntax, memory safety, and functional programming principles.

Key Features

Simple Syntax

Concatenative syntax eliminates brackets and operator precedence rules, making code natural to read and write

Pure/Impure Distinction

Separate fun (pure functions) from act (actions with side effects) for better code organization and safety

Linear Types

Stack-based resource management ensures memory safety without garbage collection

Type Inference

Full optional type inference lets you write clean code while maintaining type safety

Why Concatenative?

Concatenative languages excel at expressing data transformations naturally. Compare these approaches: Nested functions (hard to read):
meal = serve(mash(boil(peel(potato), 10)))
Multiple assignments (verbose):
pure = peel(potato)
cooked = boil(pure, 10)
mashed = mash(cooked)
meal = serve(mashed)
Dryft concatenative style (elegant):
potato peel 10 boil mash serve
Data flows left to right, operations are applied in sequence, and no parentheses are needed.

Functions vs Actions

Dryft distinguishes between pure logic and stateful operations:
fun: double
    copy + ;

fun: quadra
    double double
:fun
Pure functions (fun) contain only logic and can be optimized, memoized, and evaluated at compile time. Actions (act) can perform I/O and side effects but cannot be called from pure functions.

Control Flow

Dryft provides three simple control structures that replace all traditional control flow:

Conditionals with then

true then:
    "This will execute\n" prints
:then

10 10 + 20 =? then: "equals!\n" prints ;

Multiple Conditions with when

2 var: x
when:
    $x 1 =? then: "one\n" ;
    $x 2 =? then: "two\n" ;
    $x 3 =? then: "three\n" ;
    "something else\n" ;
prints

Loops with cycle

10 var: max
0 var: i
cycle:
    $i $max =? then break ;
    $i printi
    $i 1 + i!
:cycle

Quick Example

Here’s a complete FizzBuzz implementation showcasing Dryft’s features:
include: std/io

(Int Int -> Bool)
fun: divby
    mod 0 =? ;

(Int ->)
act: fizzbuzz var: max
    1 var: x
    cycle: $x $max >? then: break ;
        when:
            $x 15 divby then: "FizzBuzz!" prints ;
            $x  3 divby then: "Fizz" prints ;
            $x  5 divby then: "Buzz" prints ;
            $x printi ;
        "\n" prints
        $x 1 + x!
    :cycle
:act

act: main 100 fizzbuzz ;

Get Started

Installation

Install the Dryft compiler and set up your development environment

Quick Start

Write your first Dryft program in minutes

Language Guide

Learn Dryft’s syntax, types, and control structures

Examples

Explore example programs and common patterns

Project Information

  • Current Version: 0.6.0
  • License: GNU General Public License v3.0
  • Compiler: Written in Rust
  • Backends: C99 (via GCC) and x86-64 assembly (via NASM)

Build docs developers (and LLMs) love