Getting Started

Install Hew and write your first program.

Quick install

The fastest way to install Hew is with the installer script:

Terminal
curl -fsSL https://install.hew.sh | bash

Or with Homebrew:

Terminal
brew tap hew-lang/hew
brew install hew

Both methods install hew (compiler), adze (build tool), hew-codegen (MLIR backend), and hew-lsp (language server for editor support).

Prerequisites

Building the Hew compiler from source requires LLVM 21 with MLIR support and a C++20 compiler. On Ubuntu/Debian:

Terminal
# Install LLVM 21 (includes MLIR)
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 21

# Install build tools
sudo apt install cmake ninja-build

Building from source

Clone the repository and build the compiler:

Terminal
git clone https://github.com/hew-lang/hew.git
cd hew

# Build the Rust frontend (lexer, parser, type checker, driver)
cargo build -p hew-cli

# Build the C++ MLIR backend (codegen)
cd hew-codegen
cmake -B build -G Ninja \\
  -DLLVM_DIR=/usr/lib/llvm-21/lib/cmake/llvm \\
  -DMLIR_DIR=/usr/lib/llvm-21/lib/cmake/mlir
cmake --build build
cd ..

The compiler driver is at target/debug/hew. Add it to your PATH:

Terminal
export PATH="$PWD/target/debug:$PATH"

Hello World

Create a file called hello.hew:

hello.hew
fn main() {
    println("Hello, world!");
}

Compiling and running

Compile with hew build and run the resulting binary:

Terminal
hew build hello.hew -o hello
./hello
Hello, world!

That's it! The hew build command drives the Rust frontend (lexer, parser, type checker), then invokes the MLIR backend to lower through LLVM IR and produce a native binary.