All Projects → ozanh → ugo

ozanh / ugo

Licence: MIT and 2 other licenses found Licenses found MIT LICENSE BSD-3-Clause LICENSE.golang MIT LICENSE.tengo
Script Language for Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to ugo

vm
The mm-ADT Virtual Machine
Stars: ✭ 29 (-61.33%)
Mutual labels:  virtual-machine
leema
A functional programming language designed for concurrency and failure
Stars: ✭ 43 (-42.67%)
Mutual labels:  virtual-machine
Arduino-FVM
Byte Token Threaded Forth Virtual Machine (FVM) for Arduino
Stars: ✭ 35 (-53.33%)
Mutual labels:  virtual-machine
minima
A fast, byte-code interpreted language
Stars: ✭ 43 (-42.67%)
Mutual labels:  virtual-machine
VPS
Script and resources to install VitalPBX on VPS Machines
Stars: ✭ 21 (-72%)
Mutual labels:  virtual-machine
ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (+109.33%)
Mutual labels:  virtual-machine
TWVM
A tiny, lightweight and efficient WebAssembly virtual machine.
Stars: ✭ 105 (+40%)
Mutual labels:  virtual-machine
YukimiScript
Scripting language for visual novel.
Stars: ✭ 26 (-65.33%)
Mutual labels:  script-language
RSqueak
A Squeak/Smalltalk VM written in RPython.
Stars: ✭ 78 (+4%)
Mutual labels:  virtual-machine
wiser
🐎 Extremely minimal vmm for linux written in C. Hopefully someday will spin linux-vm for you.
Stars: ✭ 249 (+232%)
Mutual labels:  virtual-machine
mima
MIninmal MAchine Assembler and Simulator
Stars: ✭ 19 (-74.67%)
Mutual labels:  virtual-machine
clover2
Clover2 can be used as shell. The completion is powerfull like IDE. Also clover2 is a Ruby-like compiler language with static type like Java. This is high performnace. Please see the wiki for details
Stars: ✭ 100 (+33.33%)
Mutual labels:  virtual-machine
nj
NJ is a simple script engine in golang with Lua-like syntax.
Stars: ✭ 19 (-74.67%)
Mutual labels:  script-language
Arduino-Shell
RPN Postscript/Forth Command Shell for Arduino
Stars: ✭ 19 (-74.67%)
Mutual labels:  virtual-machine
jMiniLang
用Kotlin实现的编译器和虚拟机,并在此基础上构建操作系统。
Stars: ✭ 62 (-17.33%)
Mutual labels:  virtual-machine
thislang
A subset of javascript implemented in that subset of javascript. Yes, it can run itself.
Stars: ✭ 31 (-58.67%)
Mutual labels:  virtual-machine
ubuntu-vnc-xfce-chromium
Retired. Headless Ubuntu/Xfce container with VNC/noVNC and Chromium (Generation 1)
Stars: ✭ 20 (-73.33%)
Mutual labels:  virtual-machine
wasm-joey
Serverless Wasm - A lightweight Node.js application for deploying and executing WebAssembly(Wasm) binary-code via HTTP
Stars: ✭ 48 (-36%)
Mutual labels:  virtual-machine
Plotty
C language compiler from scratch for a custom architecture, with virtual machine and all
Stars: ✭ 33 (-56%)
Mutual labels:  virtual-machine
uvmm
Virtual machine monitor for L4Re
Stars: ✭ 22 (-70.67%)
Mutual labels:  virtual-machine

The uGO Language

Go Reference Go Report Card uGO Test uGO Dev Test Maintainability

uGO is a fast, dynamic scripting language to embed in Go applications. uGO is compiled and executed as bytecode on stack-based VM that's written in native Go.

uGO is inspired by awesome script language Tengo by Daniel Kang. A special thanks to Tengo's creater and contributors.

To see how fast uGO is, please have a look at fibonacci benchmarks.

Play with uGO via Playground built for WebAssembly.

Fibonacci Example

param arg0

var fib

fib = func(x) {
    if x == 0 {
        return 0
    } else if x == 1 {
        return 1
    }
    return fib(x-1) + fib(x-2)
}
return fib(arg0)

Features

  • Written in native Go (no cgo).
  • if else statements.
  • for and for in statements.
  • try catch finally statements.
  • param, global, var and const declarations.
  • Rich builtins.
  • Module support.
  • Go like syntax with additions.

Why uGO

uGO name comes from the initials of my daughter's, wife's and my name. It is not related with Go.

I needed a faster embedded scripting language with runtime error handling.

Quick Start

go get github.com/ozanh/ugo@latest

uGO has a REPL application to learn and test uGO scripts.

go install github.com/ozanh/ugo/cmd/ugo@latest

./ugo

repl-gif

This example is to show some features of uGO.

https://play.golang.org/p/1Tj6joRmLiX

package main

import (
    "fmt"

    "github.com/ozanh/ugo"
)

func main() {
    script := `
param ...args

mapEach := func(seq, fn) {

    if !isArray(seq) {
        return error("want array, got " + typeName(seq))
    }

    var out = []

    if sz := len(seq); sz > 0 {
        out = repeat([0], sz)
    } else {
        return out
    }

    try {
        for i, v in seq {
            out[i] = fn(v)
        }
    } catch err {
        println(err)
    } finally {
        return out, err
    }
}

global multiplier

v, err := mapEach(args, func(x) { return x*multiplier })
if err != undefined {
    return err
}
return v
`

    bytecode, err := ugo.Compile([]byte(script), ugo.DefaultCompilerOptions)
    if err != nil {
        panic(err)
    }
    globals := ugo.Map{"multiplier": ugo.Int(2)}
    ret, err := ugo.NewVM(bytecode).Run(
        globals,
        ugo.Int(1), ugo.Int(2), ugo.Int(3), ugo.Int(4),
    )
    if err != nil {
        panic(err)
    }
    fmt.Println(ret) // [2, 4, 6, 8]
}

Roadmap

More standard library modules will be added.

More tests will be added.

Basic object oriented programming support.

Documentation

LICENSE

uGO is licensed under the MIT License.

See LICENSE for the full license text.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].