Categorygithub.com/mvp-joe/tengo
repositorypackage
0.9.3
Repository: https://github.com/mvp-joe/tengo.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

The Tengo Language

GoDoc Go Report Card Build Status

Tengo is a small, dynamic, fast, secure script language for Go.

Tengo is fast and secure because it's compiled/executed as bytecode on stack-based VM that's written in native Go.

/* The Tengo Language */

each := func(seq, fn) {
    for x in seq { fn(x) }
}

sum := func(init, seq) {
    each(seq, func(x) { init += x })
    return init
}

n := sum(0, [1, 2, 3])   // == 6
s := sum("", [1, 2, 3])  // == "123"

Run this code in the Playground

Features

  • Simple and highly readable Syntax
    • Dynamic typing with type coercion
    • Higher-order functions and closures
    • Immutable values
    • Garbage collection
  • Securely Embeddable and Extensible
  • Compiler/runtime written in native Go (no external deps or cgo)
  • Executable as a standalone language / REPL

Benchmark

fib(35)fibt(35)Type
Go58ms4msGo (native)
Tengo4,334ms5msVM on Go
Lua1,740ms3msLua (native)
go-lua5,229ms5msLua VM on Go
GopherLua5,486ms5msLua VM on Go
Python3,116ms27msPython (native)
starlark-go15,414ms5msPython-like Interpreter on Go
gpython17,754ms6msPython Interpreter on Go
goja6,843ms6msJS VM on Go
otto86,542ms13msJS Interpreter on Go
Anko98,962ms26msInterpreter on Go

* fib(35): Fibonacci(35)
* fibt(35): tail-call version of Fibonacci(35)
* Go does not read the source code from file, while all other cases do
* See here for commands/codes used

References