by Vasiliy Tereshkov
A statically typed embeddable scripting language

Umka is a statically typed embeddable scripting language. It combines the simplicity and flexibility needed for scripting with a compile-time protection against type errors. Its aim is to follow the Python Zen principle Explicit is better than implicit more consistently than dynamically typed languages generally do.

Features

  • Clean syntax inspired by Go
  • Cross-platform bytecode compiler and virtual machine
  • Garbage collection
  • Polymorphism via interfaces
  • Multitasking based on fibers
  • Type inference
  • Distribution as a dynamic library with a simple C API
  • C99 source
// Constants
const a = 3
const b* = 2.38  // Exported identifier
const (
    c = sin(b) / 5
    d = "Hello" + " World"
)

// Types
type IntPtr = ^uint16
type Arr = [a]real
type (
    Quat = struct {
        q: [4]real
        normalized: bool
    }
    Printable = interface {
        print(): int
    }
    ErrFn = fn(code: int)
)        

// Variables
var e: int
var f: str = d + "!"
var (
    g: Arr = [3]real{2.3, -4.1 / 2, b}
    h: [var][5]int  // Dynamic arrays require calling make()
)
q := Quat{q: [4]real{1, 0, 0, 0}, normalized: true}

// Functions
fn tan(x: real): real {return sin(x) / cos(x)}

/*
Built-in functions:
    printf fprintf sprintf scanf fscanf sscanf
    round trunc fabs sqrt sin cos atan exp log
    new make append len sizeof
    fiberspawn fiberfree fibercall fiberalive
*/

// Methods
fn (a: ^Arr) print(): int {
    printf("Arr: {8.3lf} {8.3lf} {8.3lf}\n", a[0], a[1], a[2])
    return 0
}
Information updated 07/18/20
View Comments