시작하기
Hew를 설치하고 첫 프로그램을 작성하세요.
빠른 설치
Hew를 가장 빠르게 설치하는 방법은 설치 스크립트를 사용하는 것입니다:
v0.9.3 · 출시 버전
curl -fsSL https://hew.sh/install | bash -s -- --version 0.9.3curl -fsSL https://hew.sh/install | bash -s -- --version 0.9.3Invoke-WebRequest https://hew.sh/install.ps1 -OutFile install.ps1
.\install.ps1 -Version 0.9.3설치 프로그램은 컴파일러와 패키지 관리자를 포함한 hew를 설치합니다.
이 터미널에서 기본 설치 경로를 PATH에 추가하세요. 다음 터미널에서도 사용하려면 설치 프로그램이 표시한 셸의 영구 설정 명령을 실행하세요. 다른 디렉터리를 선택했다면 해당 PATH 명령을 사용하세요.
export PATH="$HOME/.hew/bin:$PATH"설치 후 새 터미널을 열어 업데이트된 PATH를 사용하세요.
이 명령은 강의와 같은 컴파일러 버전을 선택합니다. hew version으로 설치를 확인하세요.
hew versionHello World 출력하기
hello.hew라는 파일을 만드세요:
fn main() {
println("Hello, world!");
}컴파일 및 실행
hew build로 컴파일하고 생성된 바이너리를 실행하세요:
네이티브 빌드에는 C 컴파일러와 시스템 개발 도구가 필요합니다. macOS에서는 Xcode Command Line Tools, Linux에서는 Clang 또는 GCC, Windows에서는 LLVM과 Visual Studio C++ Build Tools를 사용하세요. 검사는 성공하지만 링크가 실패하면 문제 해결 안내(영어)를 참고하세요.
hew check hello.hew
hew build hello.hew -o hello
./helloHello, world!hew check hello.hew
hew build hello.hew -o hello.exe
.\hello.exeHello, world!hew build는 Rust frontend를 실행하고, 검사된 프로그램을 HIR과 MIR로 낮춘 뒤 LLVM을 통해 네이티브 바이너리를 생성합니다.
에디터 설정
VS Code의 확장에서 Hew Language(hew-lang.hew-lang)를 설치하세요. code 명령이 PATH에 있다면 다음 명령도 사용할 수 있습니다:
code --install-extension hew-lang.hew-langhello.hew를 여세요. 언어 모드가 Hew로 표시되고 구문 강조와 언어 서버 진단을 사용할 수 있어야 합니다. 게시된 확장에는 지원 플랫폼용 hew-lsp가 포함되어 있습니다.
특정 설치를 사용하려면 VS Code 설정에서 hew.lsp.serverPath와 hew.formatterPath를 hew-lsp와 hew의 전체 경로로 지정하세요. ~나 변수가 없는 절대 경로를 사용하세요. PATH를 변경한 후 VS Code를 다시 시작하세요.
Vim, Neovim, Emacs 및 다른 에디터(영어)
빠른 참조표
인쇄용 양면 차트에서 일상 문법, actor, 동시성, wire type, machine을 확인할 수 있습니다.
다른 설치 방법
실행 전에 설치 프로그램을 확인하려면 로컬 파일로 다운로드한 뒤 읽어보세요.
curl -fsSLo hew-install.sh https://hew.sh/install
less hew-install.sh
bash hew-install.sh --version 0.9.3Invoke-WebRequest https://hew.sh/install.ps1 -OutFile install.ps1
Get-Content .\install.ps1
.\install.ps1 -Version 0.9.3위에 표시된 버전을 내려받고 해당 SHA-256 체크섬 파일로 플랫폼 압축 파일을 검증하세요.
tag=v0.9.3
asset=hew-v0.9.3-darwin-aarch64.tar.gz # choose the asset for your Mac
base="https://github.com/hew-lang/hew/releases/download/$tag"
curl -fLO "$base/$asset"
curl -fLO "$base/hew-$tag-checksums.txt"
grep " $asset$" "hew-$tag-checksums.txt" | shasum -a 256 -c -tag=v0.9.3
asset=hew-v0.9.3-linux-x86_64.tar.gz # choose the asset for your Linux host
base="https://github.com/hew-lang/hew/releases/download/$tag"
curl -fLO "$base/$asset"
curl -fLO "$base/hew-$tag-checksums.txt"
grep " $asset$" "hew-$tag-checksums.txt" | sha256sum -c -$tag = "v0.9.3"
$asset = "hew-v0.9.3-windows-x86_64.zip"
$base = "https://github.com/hew-lang/hew/releases/download/$tag"
Invoke-WebRequest "$base/$asset" -OutFile $asset
Invoke-WebRequest "$base/hew-$tag-checksums.txt" -OutFile checksums.txt
$expected = (Select-String -Path checksums.txt -Pattern " $asset$").Line.Split(" ")[0]
$actual = (Get-FileHash -Algorithm SHA256 $asset).Hash.ToLower()
if ($actual -ne $expected) { throw "checksum mismatch" }아래의 빌드 요구 사항을 준비하면 지정된 릴리스를 소스에서 빌드할 수도 있습니다.
Using the mobile apps? Follow the illustrated iPhone/iPad guide or Android beta guide for examples, editing, running and saving code. These guides are in English.
필수 조건
소스 빌드에는 GNU Make와 Python 3.12 이상도 필요합니다. 전체 빌드 요구 사항 보기(영어).
macOS에서 소스 빌드를 하려면 LLVM 22와 Rust toolchain이 필요합니다. Homebrew로 LLVM을 설치하세요:
brew install llvm cmake ninja소스에서 Hew 컴파일러를 빌드하려면 LLVM 22와 Rust toolchain이 필요합니다. Ubuntu/Debian에서는:
# Install LLVM 22 (required by Inkwell)
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 22
# Install build tools
sudo apt install cmake ninja-buildWindows에서 소스 빌드를 하려면 Rust toolchain, VS Build Tools 2022(Desktop development with C++), cmake, Ninja, llvm.org의 LLVM 22가 필요합니다.
소스에서 빌드
저장소를 클론하고 컴파일러를 빌드하세요:
git clone --branch v0.9.3 https://github.com/hew-lang/hew.git
cd hew
make hew-native컴파일러 드라이버는 target/debug/hew에 있습니다. PATH에 추가하세요:
export PATH="$PWD/target/debug:$PATH"컴파일러 드라이버는 target\debug\hew.exe에 있습니다. PowerShell에서 PATH에 추가하세요:
$env:PATH = "$PWD\target\debug;$env:PATH"