Introduction

Husk is a modern programming language that brings Rust's elegant syntax and powerful type system to the JavaScript ecosystem. Write code with familiar Rust patterns and compile to clean, readable ES modules that run on Node.js.

Why Husk?

  • Rust-inspired syntax - Structs, enums, pattern matching, and Result types
  • Strong static typing - Catch errors at compile time with algebraic data types
  • JavaScript output - Generate clean ES modules with full npm ecosystem access
  • First-class tooling - LSP support, VS Code extension, formatter, and watch mode

Quick Example

struct Person {
    name: String,
    age: i32,
}

fn greet(person: Person) -> String {
    format!("Hello, {}! You are {} years old.", person.name, person.age)
}

fn main() {
    let alice = Person { name: "Alice".to_string(), age: 30 };
    println!("{}", greet(alice));
}

This compiles to readable JavaScript:

const alice = { name: "Alice", age: 30 };
console.log(`Hello, ${alice.name}! You are ${alice.age} years old.`);

Getting Started

Ready to try Husk? Head to the Installation guide to get started.

Installation

If you have Rust installed, you can install Husk using Cargo:

cargo install husk-lang

Verify Installation

After installation, verify that Husk is working:

husk --version

Editor Setup

For the best development experience, install the VS Code extension or configure your editor with LSP support. See Editor Setup for details.

Hello World

Let's write your first Husk program.

Create a File

Create a file called hello.hk:

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

Compile and Run

Compile the file to JavaScript:

husk build hello.hk

This creates hello.js. Run it with Node.js:

node hello.js

You should see:

Hello, world!

Watch Mode

For rapid development, use watch mode to automatically recompile on changes:

husk watch hello.hk

Next Steps

Now that you have Husk running, learn about the Basic Syntax.

Basic Syntax

Coming soon.

Types

Coming soon.

Functions

Coming soon.

Structs

Coming soon.

Enums

Coming soon.

Pattern Matching

Coming soon.

Error Handling

Coming soon.

Generics

Coming soon.

Closures

Coming soon.

Modules

Coming soon.

npm Interop

Coming soon.

CLI Reference

Coming soon.

Editor Setup

Coming soon.