Voyd logovoyd
Voyd logo

voyd

A high performance WebAssembly programming language with a focus on full stack web development.

Built for the web

voyd includes all the tools you need to build web apps, frontend and backend. Try it out!

Loading...

Hit the play button in the editor to render

Expressive

Features including (but not limited to) function overloads, labeled parameters, and universal function call syntax make writing maintainable code easy and fun.

////////
// Overloads keep functions semantic, no more add_ints and add_floats when the
// parameter types can do the disambiguation for you.
////////

fn add(a: i32, b: i32) = a + b
fn add(a: f64, b: f64) = a + b

add(1, 2) // 3
add(1.0, 2.0) // 3.0

// You can even overload operators!

fn '+'(a: Vec, b: Vec)
  Vec {
    x: a.x + b.x,
    y: a.y + b.y
  }

fn add(a: Vec, b: Vec) = a + b

////////
// Universal function call syntax (UFCS) lets you treat any function like
// a method, so you can call functions with a dot without having to extend objects.
////////

let (a, b) = (Vec { x: 1, y: 2 }, Vec { x: 1, y: 2 })
a.add(b) // Call the add fn defined above with UFCS

////////
// Labeled parameters help make intentions clear, you can even
// specify external and internal labels separately
////////

fn move({ from: Vec, to destination: Vec })
  send_move_instruction_to_robot(from, destination)

move(from: a, to: b)

// Since labeled parameters are just syntax sugar to objects, you can
// pass object literals too. This is handy when you already have an object
// with the parameter fields, or you want to take advantage of object literal
// shorthand so you don't have to repeat yourself

let from = a
let to = b

// Object literal shorthand lets you write:
move({ from, to })

// Instead of
move(from: from, to: to)