g2a-com / g2a-com/kikd

Choosing an interpreter for running executors

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
decision
Dominant language
Go
Stars
0
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Klio lifecycle commands need scripting language engine for running executors (builders, deployers, etc). Currently they are using *goya*, but it was chosen as a temporary solution, without evaluating other options.

Good interpreter should meet the following requirements:

- It has to be small - chosen engine is going to be included in every binary, it shouldn't add 3MB to each one of them.
- It should have good documentation for both itself and a language.
- It should have good standard library, otherwise we need to create it by our own.

### Which engines are taken into consideration?

Stats as at 16 Sep 2021.

| Package | Language | Stars | Watchers | Forks | Last Commit |
| ----------------------------------------------------- | ----------- | ----- | -------- | ----- | ----------- |
| [otto](https://github.com/robertkrimen/otto) | JavaScript | 6222 | 189 | 521 | 14 Jun 2021 |
| [goja](https://github.com/dop251/goja) | JavaScript | 2386 | 66 | 201 | 12 Sep 2021 |
| [go-ducktape](https://github.com/olebedev/go-duktape) | JavaScript | 778 | 28 | 90 | 26 Mar 2021 |
| [gopher-lua](https://github.com/yuin/gopher-lua) | Lua | 4289 | 149 | 477 | 29 May 2021 |
| [go-lua](https://github.com/Shopify/go-lua) | Lua | 2152 | 312 | 156 | 2 Mar 2021 |
| [golua](https://github.com/aarzilli/golua) | Lua | 555 | 34 | 193 | 7 May 2021 |
| [go-python](https://github.com/sbinet/go-python) | Python | 1303 | 43 | 128 | 14 Apr 2021 |
| [gpython](https://github.com/go-python/gpython) | Python | 517 | 21 | 58 | 18 Nov 2019 |
| [yaegi](https://github.com/traefik/yaegi) | Golang | 3816 | 50 | 183 | 15 Sep 2021 |
| [tengo](https://github.com/d5/tengo) | Tengo | 2422 | 57 | 141 | 5 Sep 2021 |
| [starlark-go](https://github.com/google/starlark-go) | Starlark | 1367 | 46 | 122 | 1 Sep 2021 |
| [anko](https://github.com/mattn/anko) | Anko Script | 1167 | 47 | 111 | 21 May 2020 |
| [go-php](https://github.com/deuill/go-php) | PHP | 42 | 811 | 92 | 1 Oct 2018 |

### Additional size of commands

Following numbers are based on interpreters integrated with *build* command, compared with
interpreter-less version.

| Package | Compressed | Uncompressed |
| -------------- | ---------- | ------------ |
| **goja** | 3.19MB | 7.63MB |
| **gopher-lua** | 1.13MB | 2.47MB |
| **otto** | 1.21MB | 2.81MB |
| **tengo** | 0.36MB | 0.86MB |

### Standard libraries

Relevant features supported by standard libraries:

| Package | File System | Exec | HTTP | Regex | JSON | YAML | Print | Date & Time |
| -------------- | ----------- | ---- | ------ | ----- | ---- | ---- | ----- | ----------- |
| **goja** | no | no | no | yes | yes | no | yes\* | yes |
| **gopher-lua** | yes | no | no | no | no | yes | yes | yes |
| **otto** | no | no | no | yes | yes | no | yes | yes |
| **tengo** | yes | yes | no\*\* | yes | yes | no | yes | yes |

\* Provided by an additional library\
\*\* Maintainers are open for idea of adding it

## Remarks

### goja

- Simplest to integrate.
- Too heavy - it adds 3MB to compressed binary.
- Has partial support for ECMA 2015+, but it's poorly documented which features are actually supported.
- JavaScript is a divisive language.

### gopher-lua

- Using it wasn't a pleasant experience. For example, using userdata as a table froze command without any errors.
- Awful API.
- IO API is too barebone to be useful.
- Lua has some quirks, it tend to be hard to use for new developers.

### otto

- Substantially harder to work with than goja.
- No support for ES2015 or later.
- Errors tend to be a little bit cryptic.
- JavaScript is a divisive language.

### tengo

- Uses custom language, but it's quite nice and easy.
- Documentation could be better, but isn't the worst either.
- Has some issues with converting Golang types to Tengo, but they can be circumvented by
marshalling/unmarshalling.
- Pretty good standard library.
- It's really small, it adds only 0.36MB to compressed binary.

### gpython

- There is no documentation how to integrate it into golang app.
- Seems to be no longer actively maintained.
- Passing data into VM is not supported.
- Seems to be no way to extract data from a VM.
- Everybody loves python.

### yaegi

- Full-blown Golang interpreter, not suitable for scripting.

Contributor guide

No contributing guide indexed for this repository

Research direction

No source file or test is named. Review the size and standard-library tables and the remarks for goja, gopher-lua, otto, tengo, gpython, and yaegi; compare them with the stated requirements, then document a decision and rationale for the interpreter to use in place of goya.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, javascript, lua, php, python
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.