diff options
Diffstat (limited to 'vendor/github.com/d5/tengo/README.md')
-rw-r--r-- | vendor/github.com/d5/tengo/README.md | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/vendor/github.com/d5/tengo/README.md b/vendor/github.com/d5/tengo/README.md index 7aa05966..e68b0f86 100644 --- a/vendor/github.com/d5/tengo/README.md +++ b/vendor/github.com/d5/tengo/README.md @@ -7,7 +7,6 @@ [](https://godoc.org/github.com/d5/tengo/script) [](https://goreportcard.com/report/github.com/d5/tengo) [](https://travis-ci.org/d5/tengo) -[](https://www.patreon.com/tengolang) **Tengo is a small, dynamic, fast, secure script language for Go.** @@ -16,6 +15,8 @@ Tengo is **[fast](#benchmark)** and secure because it's compiled/executed as byt ```golang /* The Tengo Language */ +fmt := import("fmt") + each := func(seq, fn) { for x in seq { fn(x) } } @@ -25,11 +26,11 @@ sum := func(init, seq) { return init } -n := sum(0, [1, 2, 3]) // == 6 -s := sum("", [1, 2, 3]) // == "123" +fmt.println(sum(0, [1, 2, 3])) // "6" +fmt.println(sum("", [1, 2, 3])) // "123" ``` -> Run this code in the [Playground](https://tengolang.com/?s=d01cf9ed81daba939e26618530eb171f7397d9c9) +> Run this code in the [Playground](https://tengolang.com/?s=0c8d5d0d88f2795a7093d7f35ae12c3afa17bea3) ## Features @@ -41,22 +42,23 @@ s := sum("", [1, 2, 3]) // == "123" - [Securely Embeddable](https://github.com/d5/tengo/blob/master/docs/interoperability.md) and [Extensible](https://github.com/d5/tengo/blob/master/docs/objects.md) - Compiler/runtime written in native Go _(no external deps or cgo)_ - Executable as a [standalone](https://github.com/d5/tengo/blob/master/docs/tengo-cli.md) language / REPL +- Use cases: rules engine, [state machine](https://github.com/d5/go-fsm), [gaming](https://github.com/d5/pbr), data pipeline, [transpiler](https://github.com/d5/tengo2lua) ## Benchmark | | fib(35) | fibt(35) | Type | | :--- | ---: | ---: | :---: | -| Go | `58ms` | `4ms` | Go (native) | -| [**Tengo**](https://github.com/d5/tengo) | `4,180ms` | `5ms` | VM on Go | -| Lua | `1,695ms` | `3ms` | Lua (native) | -| [go-lua](https://github.com/Shopify/go-lua) | `5,163ms` | `5ms` | Lua VM on Go | -| [GopherLua](https://github.com/yuin/gopher-lua) | `5,525ms` | `5ms` | Lua VM on Go | -| Python | `3,097ms` | `27ms` | Python (native) | -| [starlark-go](https://github.com/google/starlark-go) | `15,307ms` | `5ms` | Python-like Interpreter on Go | -| [gpython](https://github.com/go-python/gpython) | `17,656ms` | `5ms` | Python Interpreter on Go | -| [goja](https://github.com/dop251/goja) | `6,876ms` | `5ms` | JS VM on Go | -| [otto](https://github.com/robertkrimen/otto) | `81,886ms` | `12ms` | JS Interpreter on Go | -| [Anko](https://github.com/mattn/anko) | `97,517ms` | `14ms` | Interpreter on Go | +| Go | `48ms` | `3ms` | Go (native) | +| [**Tengo**](https://github.com/d5/tengo) | `2,349ms` | `5ms` | VM on Go | +| Lua | `1,416ms` | `3ms` | Lua (native) | +| [go-lua](https://github.com/Shopify/go-lua) | `4,402ms` | `5ms` | Lua VM on Go | +| [GopherLua](https://github.com/yuin/gopher-lua) | `4,023ms` | `5ms` | Lua VM on Go | +| Python | `2,588ms` | `26ms` | Python (native) | +| [starlark-go](https://github.com/google/starlark-go) | `11,126ms` | `6ms` | Python-like Interpreter on Go | +| [gpython](https://github.com/go-python/gpython) | `15,035ms` | `4ms` | Python Interpreter on Go | +| [goja](https://github.com/dop251/goja) | `5,089ms` | `5ms` | JS VM on Go | +| [otto](https://github.com/robertkrimen/otto) | `68,377ms` | `11ms` | JS Interpreter on Go | +| [Anko](https://github.com/mattn/anko) | `92,579ms` | `18ms` | Interpreter on Go | _* [fib(35)](https://github.com/d5/tengobench/blob/master/code/fib.tengo): Fibonacci(35)_ _* [fibt(35)](https://github.com/d5/tengobench/blob/master/code/fibtc.tengo): [tail-call](https://en.wikipedia.org/wiki/Tail_call) version of Fibonacci(35)_ |