Skip to main content
Dryft is an experimental stack-based concatenative programming language under active development. Contributions are welcome!

About Dryft

Dryft is an experimental programming language featuring:
  • Stack-based concatenative programming - Programs compose functions that transform a data stack
  • Pure and impure function distinction - Explicit separation between functions (pure) and actions (impure)
  • Linear types - Stack-based resource management with linear type tracking
  • Optional type inference - Full type inference with optional annotations
  • Simple extensible syntax - Minimal keywords with clear semantics

Project Structure

The Dryft compiler is written in Rust and organized as follows:
src/
├── backends/          # Code generation backends
│   ├── c99/          # C99 transpiler backend
│   └── x86/          # x86-64 assembly backend (in development)
├── targets/           # Build profiles for different platforms
│   ├── gcc.toml      # GCC/C99 build configuration
│   └── elf.toml      # Native x86-64 ELF configuration
├── frontend.rs        # Single-pass compiler frontend
├── backends.rs        # Backend trait and selection
├── state.rs           # Compiler state and types
└── main.rs            # CLI entry point

doc/
├── how_to_add_a_backend.md    # Backend development guide
└── build_graph.md              # Compilation pipeline diagram

native/
└── stdc/              # C standard library bindings

Development Setup

1

Clone the repository

git clone https://github.com/your-repo/dryft.git
cd dryft
2

Install Rust

Dryft requires Rust 2021 edition or later. Install via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
3

Install build dependencies

For C99 backend:
# GCC (most Linux distributions)
sudo apt install gcc
For x86 backend:
# NASM assembler
sudo apt install nasm
4

Build the compiler

cargo build --release
The binary will be in target/release/dryft
5

Run tests

cargo test

Ways to Contribute

1. Add Language Features

New language features typically require changes to:
  • src/frontend.rs - Add token handling in handle_token()
  • src/backends.rs - Add method to the Backend trait
  • Each backend - Implement the new method
  • src/state.rs - Add types or state if needed
Example areas:
  • Structs and composite types
  • Module system improvements
  • Pattern matching
  • More control flow constructs
  • Compile-time evaluation

2. Create a New Backend

See the Backend System guide for detailed instructions on adding backends. Good candidates:
  • LLVM IR - Unlock powerful optimizations
  • WebAssembly - Run Dryft in browsers
  • ARM assembly - Target embedded systems
  • JVM bytecode - Integrate with Java ecosystem
  • Other languages - Python, JavaScript, Go, etc.

3. Improve Existing Backends

The x86 backend (src/backends/x86/mod.rs) is incomplete - many functions use todo!() placeholders:
  • Variables (create, read, write)
  • Control flow (loops, conditionals)
  • Comparisons and logic operations
  • String support
The C99 backend works well but could be optimized:
  • Better stack management
  • Inline small functions
  • Optimize away unnecessary push/pop sequences

4. Standard Library

The standard library lives in native/stdc/ and provides FFI to C functions. Contributions needed:
  • File I/O operations
  • Network sockets
  • String manipulation
  • Data structures (lists, maps, etc.)
  • Math functions
  • System calls

5. Tooling

  • Syntax highlighting - VSCode, Vim, Emacs, etc.
  • LSP server - IDE integration
  • Formatter - Code formatting tool
  • Debugger - Interactive debugging support
  • Package manager - Dependency management
  • REPL - Interactive interpreter

6. Documentation

  • Tutorial for beginners
  • Language reference
  • Standard library documentation
  • Example programs
  • Video tutorials
  • Blog posts about Dryft

7. Testing

  • Write test programs in .dry
  • Add unit tests for compiler components
  • Integration tests for build pipeline
  • Fuzzing for compiler robustness
  • Benchmark suite for performance tracking

Contribution Workflow

1

Create an issue

Before starting work, create an issue describing:
  • What you want to add/fix
  • Why it’s useful
  • Your proposed approach
This helps avoid duplicate work and gets early feedback.
2

Fork and branch

# Fork the repo on GitHub, then:
git clone https://github.com/YOUR-USERNAME/dryft.git
cd dryft
git checkout -b feature/your-feature-name
3

Make your changes

  • Follow existing code style
  • Add tests for new features
  • Update documentation as needed
  • Keep commits focused and atomic
4

Test thoroughly

# Run all tests
cargo test

# Test with example programs
cargo run -- examples/fizzbuzz.dry

# Check formatting
cargo fmt --check

# Run linter
cargo clippy
5

Commit and push

git add .
git commit -m "Add feature: your feature description"
git push origin feature/your-feature-name
Use clear commit messages that explain the “why” not just the “what”.
6

Open a pull request

  • Go to GitHub and create a pull request
  • Reference the related issue
  • Describe what changed and why
  • Add screenshots/examples if applicable
  • Request review from maintainers
7

Address feedback

  • Respond to review comments
  • Make requested changes
  • Push updates to your branch
  • Mark conversations as resolved

Code Style Guidelines

Rust Code

  • Follow standard Rust style (cargo fmt)
  • Use meaningful variable names
  • Add comments for complex logic
  • Prefer explicit types in public APIs
  • Keep functions focused and small
  • Use Rust idioms (iterators, ? operator, etc.)

Dryft Code

  • Use descriptive function names
  • Separate functions and actions clearly
  • Add comments explaining stack effects: # ( in -- out )
  • Keep functions small and composable
  • Use proper indentation for nested blocks

Documentation

  • Write clear, concise explanations
  • Include code examples
  • Link to related sections
  • Keep language simple and accessible

Backend Development Guidelines

When implementing a backend:
  1. Start simple - Get basic arithmetic and functions working first
  2. Study C99 backend - It’s the reference implementation
  3. Use todo!() - For unimplemented features, don’t leave stubs empty
  4. Test incrementally - Test each feature as you implement it
  5. Document limitations - Be clear about what’s not supported yet
  6. Add build profile - Create a TOML file in src/targets/
See the Backend System page for detailed instructions.

Compiler Architecture Notes

  • Single-pass compilation - Tokens are processed immediately, no AST
  • Stack-based - The compiler tracks stack state and types
  • Type checking - Each operation validates input types and pushes output types
  • Definition stack - Tracks nested contexts (function, loop, conditional, etc.)
  • Backend abstraction - Frontend is backend-agnostic
See the Compiler Architecture page for more details.

Testing Guidelines

Unit Tests

Add tests in the relevant .rs file:
#[cfg(test)]
mod tests {
    use super::*;
    
    #[test]
    fn test_feature() {
        // Test code
    }
}

Integration Tests

Create .dry test programs in tests/ directory and add test runners.

Test Coverage

Aim to test:
  • Happy path (normal usage)
  • Edge cases (empty input, boundary values)
  • Error cases (invalid syntax, type errors)
  • Interactions (how features work together)

Communication

  • GitHub Issues - Bug reports, feature requests, questions
  • Pull Requests - Code review and discussion
  • Discussions - General questions and ideas

License

Dryft is licensed under the GNU General Public License v3.0. By contributing, you agree that your contributions will be licensed under the same terms. All source files should include the GPL header:
/*
 * Copyright (C) 2025 Filip Chovanec
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

Getting Help

If you need help:
  1. Check existing documentation and issues
  2. Look at similar code in the codebase
  3. Ask in GitHub Discussions
  4. Open an issue with your question

Code of Conduct

Be respectful, constructive, and professional. We’re all here to learn and build something cool together.

Recognition

Contributors will be recognized in:
  • Release notes
  • Contributors list
  • Project documentation
Thank you for contributing to Dryft!

Build docs developers (and LLMs) love