https://github.com/shoriwe/plasma
Thread safe Go embeddable ruby like scripting language
https://github.com/shoriwe/plasma
dynamic-type embeddable-scripting-language go golang ruby scripting-language
Last synced: 14 days ago
JSON representation
Thread safe Go embeddable ruby like scripting language
- Host: GitHub
- URL: https://github.com/shoriwe/plasma
- Owner: shoriwe
- License: bsd-2-clause
- Created: 2021-04-04T16:35:18.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-11-30T19:20:51.000Z (over 3 years ago)
- Last Synced: 2026-01-15T07:27:56.151Z (3 months ago)
- Topics: dynamic-type, embeddable-scripting-language, go, golang, ruby, scripting-language
- Language: Go
- Homepage: https://shoriwe.github.io/plasma/
- Size: 2.21 MB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# plasma
[](https://github.com/shoriwe/plasma/actions/workflows/build.yml)
[](https://codecov.io/github/shoriwe/plasma)

[](https://goreportcard.com/report/github.com/shoriwe/plasma)
Plasma is an embeddable scripting ruby like language.
## Features
- Simple extensibility: Easy to add new go bindings
- Zero dependency: The language used as a library doesn't depend on any external project.
- Thread safe: the virtual machine and all the objects created during runtime are thread safe
- Rich syntax: Generators, defer, special boolean operators and more (check documentation for more details)
- Bytecode VM backend: the language compiles to a custom bytecode that can then stored and preloaded in the machine
without recompiling scripts.
- Stop vm execution: Plasma let you stop at any the time the execution of the VM.
## Documentation
You can find documentation in:
- [Official documentation](https://shoriwe.github.io/plasma/index.html)
- [pkg.go.dev](https://pkg.go.dev/github.com/shoriwe/plasma)
## Install interpreter
```shell
go install github.com/shoriwe/plasma/cmd/plasma@latest
```
## Preview
### REPL
You can start a REPL with:
```shell
plasma
```
### Embedding and creating Go bindings
```shell
go get -u github.com/shoriwe/plasma@v1
```
```go
package main
import (
"github.com/shoriwe/plasma/pkg/vm"
"os"
)
const myScript = `
args = get_args()
if args.__len__() > 1
println(args.__string__())
else
println("No")
end
`
func main() {
plasma := vm.NewVM(os.Stdin, os.Stdout, os.Stderr)
plasma.Load("get_args", func(plasma *vm.Plasma) *vm.Value {
return plasma.NewBuiltInFunction(plasma.RootSymbols(),
func(argument ...*vm.Value) (*vm.Value, error) {
tupleValues := make([]*vm.Value, 0, len(os.Args))
for _, cmdArg := range os.Args {
tupleValues = append(tupleValues, plasma.NewString([]byte(cmdArg)))
}
return plasma.NewTuple(tupleValues), nil
})
})
_, errorChannel, _ := plasma.ExecuteString(myScript)
err := <-errorChannel
if err != nil {
panic(err)
}
}
```
## Contributing
To contribute to this project please follow the [contribution guidelines](CONTRIBUTING.md) and
the [code of conduct](CODE_OF_CONDUCT.md)