Skip to content

Latest commit

 

History

300 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Abrase

zero dependencies leak free rustc 1.85+ playground MIT

CI codecov crates.io

Abrase (.abe, abbreviated Abe) is a small, strongly-typed language with algebraic effects and region-based memory. Source compiles to Polka bytecode on the Myriad runtime.

One source, three ways to run:

  • Add to any Rust application — zero-dependency runtime.
  • Transpile to Rust (no std), run on bare metal.
  • In the browser — try it here.

It is a self-hosting language. Its own memory management — allocation, reference counting, regions — is written in Abrase, equivalent to native-speed Rust.

Plus algebraic effects & handlers, a linter, and a debugger. See wiki.

Installation

cargo install abrase-cli

# and use
abrase run hello.abe
abrase disasm examples/nqueens.abe

Or download pre-compiled GitHub Releases.

Code Editor

Language Overview

effect Metric {
  op record(msg: String) -> Unit
}

fn fib(n: Int) -> <Metric> Int {
  Metric.record("entering fib({n})");
  if n < 2 { n } else { fib(n - 1) + fib(n - 2) }
}

fn main() -> Int {
  handle fib(10) {
    return v       => v,
    Metric.record msg => {
      println(msg);
      resume(())
    }
  }
}

Benchmarks

Generally 2.5x better than CPython. On pure function tasks, could be ~20x faster. In most cases, it's equivalent to JIT like JavaScript in V8 engine. See Wiki / Optimizations.

Reproduce with hyperfine.

Polka — bytecode design

  • 46 opcodes, 4 bytes each. Data & opcode are aligned.
  • 128 registers per frame.

See Wiki / Bytecode Spec.

Read about the blog here.

About

An effectful language that compiles to Rust.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages