Prise en main
Installez Hew et écrivez votre premier programme.
Installation rapide
La façon la plus rapide d'installer Hew est avec le script d'installation :
curl -fsSL https://install.hew.sh | bashOu avec Homebrew:
brew tap hew-lang/hew
brew install hewLes deux méthodes installent hew (compilateur), adze (outil de construction), hew-codegen (backend MLIR), et hew-lsp (serveur de langage pour le support éditeur).
Prérequis
Pour construire le compilateur Hew depuis les sources, vous avez besoin de LLVM 21 avec support MLIR et d'un compilateur C++20. Sur Ubuntu/Debian :
# 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-buildConstruire depuis les sources
Clonez le dépôt et construisez le compilateur :
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 ..Le pilote du compilateur se trouve à target/debug/hew. Ajoutez-le à votre PATH :
export PATH="$PWD/target/debug:$PATH"Bonjour le monde
Créez un fichier appelé hello.hew :
fn main() {
println("Hello, world!");
}Compilation et exécution
Compilez avec hew build et exécutez le binaire résultant :
hew build hello.hew -o hello
./hello
Hello, world!C'est tout ! La commande hew build pilote le frontend Rust (lexeur, analyseur, vérificateur de types), puis invoque le backend MLIR pour abaisser via LLVM IR et produire un binaire natif.