Rust's syntax meets JavaScript's flexibility

Choose your own adventure: Run interpreted for rapid development or transpile to JavaScript for the entire npm ecosystem

Husk
fn greet(name: string) -> string {
    format!("Hello, {}!", name)
}

fn main() {
    let message = greet("World");
    println(message);
}
JavaScript
function greet(name) {
    return `Hello, ${name}!`;
}

function main() {
    const message = greet("World");
    console.log(message);
}

main();

Choose Your Own Adventure

Husk adapts to your workflow with two powerful execution modes

Interpreter Path

Quick & Iterative

Perfect for rapid prototyping and learning

  • Zero configuration
  • Instant feedback with REPL
  • No build step required
  • Great for scripting & CLI tools
# Run directly - no setup needed!
husk run script.husk

# Or use the REPL
husk repl
> let x = 42
> println(x)
Best for: Build Scripts CLI Tools Prototyping Learning
OR

Transpiler Path

Production Ready

Tap into the entire JavaScript ecosystem

  • Access 1M+ npm packages
  • Deploy anywhere JS runs
  • TypeScript-like workflow
  • Browser & Node.js compatible
# Build your project
husk build

# Use with npm packages
npm install express
node dist/app.js
Best for: Web Apps npm Packages Production Integration

Leverage the JavaScript Ecosystem

When you transpile to JavaScript, you get access to the entire npm ecosystem

React React
Express Express
Vue Vue.js
Next.js Next.js
Jest Jest
1M+
npm packages

Why Husk?

Familiar Syntax

Write scripts with Rust's clean, expressive syntax without the complexity of memory management

Best of Both Worlds

Rust's elegant syntax with JavaScript's ecosystem - use 1M+ npm packages while writing clean, type-safe code

Type Safety

Static typing with inference catches errors early while keeping your code concise and readable

See Husk in Action

enum Result {
    Ok(int),
    Err(string),
}

fn divide(a: int, b: int) -> Result {
    if b == 0 {
        Result::Err("Division by zero")
    } else {
        Result::Ok(a / b)
    }
}

fn main() {
    match divide(10, 2) {
        Result::Ok(value) => println(format!("Result: {}", value)),
        Result::Err(msg) => println(format!("Error: {}", msg)),
    }
}
async fn fetchUser(id: int) -> Result<string, string> {
    let response = fetch(format!("/api/users/{}", id)).await?;
    let user = response.json().await?;
    Ok(user.name)
}

async fn main() {
    match fetchUser(123).await {
        Ok(name) => println(format!("User: {}", name)),
        Err(error) => println(format!("Failed: {}", error)),
    }
}
// In utils.husk
pub fn log(message: string) {
    println(format!("[LOG] {}", message));
}

// In main.husk
use local::utils::log;

fn main() {
    log("Application started");
    
    let numbers = [1, 2, 3, 4, 5];
    for n in numbers {
        log(format!("Processing: {}", n));
    }
}
fn main() {
    // Numeric conversions
    let i = 42;
    let f = i as float;  // 42.0
    
    // String parsing
    let input = "123";
    let num = input as int;
    let doubled = num * 2;
    println(format!("{} * 2 = {}", input, doubled));
    
    // To string conversion
    let result = doubled as string;
    println(format!("Result: {}", result));
}

Get Started with Husk

cargo install husk-lang

Requires Rust and Cargo. Install Rust

Quick Start

1

Create a file

// hello.husk
fn main() {
    println("Hello, Husk!");
}
2

Run it

husk run hello.husk
3

Or transpile to JS

husk compile hello.husk | node