Why did Brook choose Tengo as its embedded script language

Updated at: 2023-11-17

Context

Brook needs to add programmable functions, so that scripts can be used to flexibly control the entire process in a programmatic manner. Lua and JavaScript were considered during the period, but after deliberation, it was found that both were relatively complicated and not simple enough. So I was going to write a scripting language to implement a few simple functions, such as types, process control, and functions. Then I found Tengo, which basically met my expectations, so I chose Tengo. The following is an introduction to this scripting language, which has almost no learning cost and can be used in a few minutes.

value

a := "foo"          // string
b := -19.84         // floating point
c := 5              // integer
d := true           // boolean
e := [1, 2, 3]      // array
f := {a: 1, b: 2}   // map

if and for

if c == 1 {
    //
} else if c == 2 {
    //
} else {
    //
}

for i:=0; i<10; i++ {
    //
}

function

add := func(a, b){
    return a + b
}
c := add(1, 2)

It can be seen that functions are also a value type, just like defining a variable, which is pretty good

Builtin Functions

len(e)

more builtin functions

Standard Library

fmt := import("fmt")
fmt.println("hello")

The library is to package a series of functions and give them a name, more standard library

Playground

https://tengolang.com

Example

https://github.com/txthinking/bypass/blob/master/example_script.tengo

Brook and Shiliew

https://brook.app

https://www.txthinking.com/shiliew.html


Comments