A scripting language for Go programs

Small, fast, and safe by default.

Evie is a dynamically typed language written in pure Go. Bindings are immutable unless you say otherwise, tasks run as cooperative fibers you can await, and a Go program can embed it in a few lines.

Install the CLIgo install github.com/hxkhan/evie/evie@latest

account.evRun it
package main imports("io")

class Account(owner) {
    var balance := 0

    fn deposit(amount) {
        this.balance += amount
    }

    fn withdraw(amount) {
        if amount > this.balance {
            throw error("not enough money")
        }
        this.balance -= amount
    }
}

fn main() {
    account := Account("Ada")
    account.deposit(100)
    account.withdraw(30)
    io.println(`{account.owner} has {account.balance} left`)
}

What it feels like

Immutable unless you ask

x := 10 can never change. var x := 10 can. Mistakes surface at compile time, not three calls later.

Tasks you can await

go starts a fiber and hands back a task. await, await.all, await.race, timeouts and cancellation are built in. One fiber runs at a time, so shared state needs no locks.

Classes with a fixed shape

Fields are known when the program compiles, so this.x is a slot, not a lookup. Single inheritance, super, bound methods and is checks.

Errors that point at the line

Every error shows the source with the span underlined, the call trace, and a suggestion when a name is almost right.

Made to be embedded

Typed wrappers turn Go functions into natives. Host types, sandboxed files, context deadlines and Interrupt keep scripts on a leash.

Fast, in pure Go

No cgo, no JIT, a closure compiler over a 16-byte value. It is the fastest language you can embed in Go, 3 to 10 times ahead of the others, and a little faster than Lua 5.4 overall.

How fast

Geometric mean of eight workloads, from recursion and closures to strings and matrix math, process start included. Lower is better.

The suite and how it was measured

  1. EvieGo53.2 ms
  2. Lua 5.4C54.4 ms
  3. QuickJSC79.7 ms
  4. Python 3C109.2 ms
  5. V8 jitlessC++115.4 ms
  6. KavunGo159.9 ms
  7. gopher-luaGo229.8 ms
  8. TengoGo236.2 ms
  9. StarlarkGo321.9 ms
  10. gojaGo332.7 ms
  11. YaegiGo550.4 ms

A few lines of Go

Create an engine, load a script, and call its functions from Go. Arguments and results convert on the way in and out.

Embedding guide
main.go
package main

import (
	"fmt"

	"github.com/hxkhan/evie"
)

func main() {
	eng := evie.New()
	defer eng.Close()

	_, err := eng.Eval(`package main
fn greet(name) => "Hello, " + name + "!"`)
	if err != nil {
		panic(err)
	}

	v, err := eng.Call("main.greet", "Gopher")
	if err != nil {
		panic(err)
	}
	fmt.Println(v) // Hello, Gopher!
}