Socket
Book a DemoInstallSign in
Socket

surdeus.su/core/xgo

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

surdeus.su/core/xgo

Go Modules
Version
v1.24.8
Version published
Created
Source

The Tengo Language

GoDoc Go Report Card Build Status Sourcegraph

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 */

fmt := import("fmt")

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

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

fmt.println(sum(0, [1, 2, 3]))   // "6"
fmt.println(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
  • Use cases: rules engine, state machine, gaming, data pipeline, transpiler

Benchmark

fib(35)fibt(35)Type
Go48ms3msGo (native)
Tengo2,349ms5msVM on Go
Lua1,416ms3msLua (native)
go-lua4,402ms5msLua VM on Go
GopherLua4,023ms5msLua VM on Go
Python2,588ms26msPython (native)
starlark-go11,126ms6msPython-like Interpreter on Go
gpython15,035ms4msPython Interpreter on Go
goja5,089ms5msJS VM on Go
otto68,377ms11msJS Interpreter on Go
Anko92,579ms18msInterpreter 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

FAQs

Package last updated on 25 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts