Skip to main content

Introduction

Raven is a web-native programming language. It combines the flexibility of a scripting tool with the ambition of a systems one: code is concise, high-level and easy to read, but compiles ahead of time to fast, small WebAssembly binaries that run anywhere – in the browser, on a server, or sandboxed inside another application.

Here's a taste:

fn fib(n) { fib(n-1) + fib(n-2) }
fn fib(1) { 1 }
fn fib(0) { 0 }

fn fibSequence(n) {
xs = []
for i = range(1, n) {
append(&xs, fib(i))
}
return xs
}

show fibSequence(10)
$ raven build fib.rv
$ raven fib.wasm
fibSequence(10) = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

Some things that make Raven distinctive:

  • Type inference without annotations. Type annotations are optional and gradual, but even fully unannotated code is type-inferred, for both performance and correctness. There's no interpreter or JIT to fall back on – everything compiles to efficient static code.
  • Real data types, defined in the library. Integers, bytes, even malloc are written in Raven itself. You get good control over layout and allocation when you want it, without giving up a high-level feel.
  • Values first. Compound data is immutable by default, with a swap operator that makes working with values as convenient as mutation – but changes can never turn up in unexpected places.
  • Multiple dispatch and pattern matching. Functions can have many definitions, selected by matching on the arguments – types, values or structure.
  • No function colouring. There are no async/await keywords splitting your code in two. Any code can suspend without complications.
  • First-class JavaScript interop. Raven can call JS directly – the DOM, npm packages, anything – without glue code, and Raven functions can be exported to JS in turn.
  • An incremental compiler. The whole pipeline is incremental, for fast rebuilds, editor tooling, and live REPL and notebook experiences.

Current status

It's early days, and if you try Raven out you're beta testing. Expect bugs! We currently compile a single entry file (plus its imports) at a time; separate compilation is on the roadmap. The standard library is sparse and missing core data structures, like hash maps. Editor tooling is basic, and interfaces will change and break. See Status & Roadmap for an honest accounting.

But we think it's fun all the same.

Where to go next