All Projects → vtereshkov → Umka Lang

vtereshkov / Umka Lang

Licence: bsd-2-clause
Umka: a statically typed embeddable scripting language

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Umka Lang

V8
The official mirror of the V8 Git repository
Stars: ✭ 18,808 (+6006.49%)
Mutual labels:  compiler, interpreter, virtual-machine
Ph7
An Embedded Implementation of PHP (C Library)
Stars: ✭ 422 (+37.01%)
Mutual labels:  compiler, interpreter, virtual-machine
Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines.
Stars: ✭ 1,856 (+502.6%)
Mutual labels:  concurrency, coroutines, fibers
Gravity
Gravity Programming Language
Stars: ✭ 3,968 (+1188.31%)
Mutual labels:  fibers, interpreter, virtual-machine
Go.vm
A simple virtual machine - compiler & interpreter - written in golang
Stars: ✭ 178 (-42.21%)
Mutual labels:  compiler, interpreter, virtual-machine
Cymbal
Yet another Rust implementation of the Monkey language from "Writing an Interpreter in Go" and "Writing a Compiler in Go"
Stars: ✭ 49 (-84.09%)
Mutual labels:  compiler, interpreter, virtual-machine
Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-94.16%)
Mutual labels:  interpreter, virtual-machine, concurrency
Swift Lispkit
Interpreter framework for Lisp-based extension and scripting languages on macOS and iOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.
Stars: ✭ 228 (-25.97%)
Mutual labels:  compiler, interpreter, virtual-machine
Lioness
The Lioness Programming Language
Stars: ✭ 155 (-49.68%)
Mutual labels:  compiler, interpreter, virtual-machine
Quickjs
The official repo is at bellard/quickjs.
Stars: ✭ 1,429 (+363.96%)
Mutual labels:  compiler, interpreter, virtual-machine
Cub
The Cub Programming Language
Stars: ✭ 198 (-35.71%)
Mutual labels:  compiler, interpreter, virtual-machine
Openj9
Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Stars: ✭ 2,802 (+809.74%)
Mutual labels:  compiler, interpreter, virtual-machine
asynchronous
A D port of Python's asyncio library
Stars: ✭ 35 (-88.64%)
Mutual labels:  coroutines, fibers
jingle
🔔 Jingle is a dynamically-typed, multi-paradigm programming language designed for humans and machines.
Stars: ✭ 34 (-88.96%)
Mutual labels:  interpreter, virtual-machine
vein
🔮⚡️Vein is an open source high-level strictly-typed programming language with a standalone OS, arm and quantum computing support.
Stars: ✭ 31 (-89.94%)
Mutual labels:  interpreter, virtual-machine
X11Basic
X11-Basic BASIC programming language.
Stars: ✭ 42 (-86.36%)
Mutual labels:  interpreter, virtual-machine
snap
Snap Programming Language
Stars: ✭ 20 (-93.51%)
Mutual labels:  interpreter, coroutines
jaws
Jaws is an invisible programming language! Inject invisible code into other languages and files! Created for security research -- see blog post
Stars: ✭ 204 (-33.77%)
Mutual labels:  interpreter, virtual-machine
hematita
A memory safe Lua interpreter
Stars: ✭ 118 (-61.69%)
Mutual labels:  interpreter, virtual-machine
maxc
Programming Language maxc
Stars: ✭ 36 (-88.31%)
Mutual labels:  interpreter, virtual-machine

CI

Welcome to Umka!

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

Performance

Due to the efficient for loop implementation and support for static data structures, Umka demonstrates high performance in multidimensional array operations and similar tasks.

400 x 400 matrix multiplication (AMD A4-3300M @ 1.9 GHz, Windows 7)

Getting Started

Raytracer example

C+Umka 3D camera example

A Tour of Umka

Hello

fn main() {
    printf("Hello Umka!\n")
}

Declarations

Constants

const a = 3
const b* = 2.38                         // Exported identifier
const (
    c = sin(b) / 5
    d = "Hello" + " World"
)

Types

type IntPtr = ^uint16                   // Pointer
type Arr = [a]real                      // Array
type (
    DynArr = [][5]int                   // Dynamic array
    String = str                        // String
    Quat = struct {                     // Structure
        q: [4]real
        normalized: bool
    }
    Printable = interface {             // Interface
        print(): int
    }
    ErrFn = fn(code: int)               // Function
)

Variables

var e: int
var f: String = d + "!"
var (
    g: Arr = [3]real{2.3, -4.1 / 2, b}
    h: DynArr
)
q := Quat{q: [4]real{1, 0, 0, 0}, normalized: true}

Functions

fn tan(x: real): real {return sin(x) / cos(x)}
fn getValue(): (int, bool) {return 42, true}

Methods

fn (a: ^Arr) print(): int {
    printf("Arr: %s\n", repr(a^))
    return 0
}

Statements

Assignment

h = make([][5]int, 3)          // Dynamic arrays are initialized with make()

Declaration via assignment (with type inference)

sum := 0.0

Function call

y := tan(30 * std.pi / 180)
h = append(h, [5]int{10, 20, 30, 40, 50})
h = delete(h, 1)

Method call

g.print()

Conditional

if x, ok := getValue(); ok {
    std.println("Got " + repr(x))
}

Switch

switch a {
    case 1, 3, 5, 7: std.println(std.itoa(a) + " is odd")
    case 2, 4, 6, 8: std.println(std.itoa(a) + " is even")
    default:         std.println("I don't know")
}

Loop

    for k := 1; k <= 128; k *= 2 {
        std.println(repr(k))
    }
    
    for i, x in g {
        if fabs(x) > 1e12 {break}
        if x < 0 {continue}
        sum += x
    }

Multitasking

fn childFunc(parent: ^fiber, buf: ^int) {
    for i := 0; i < 5; i++ {
        std.println("Child : i=" + std.itoa(i) + " buf=" + std.itoa(buf^))
        buf^ = i * 3
        fibercall(parent)
    }
}

fn parentFunc() {
    a := 0
    child := fiberspawn(childFunc, &a)    
    for i := 0; i < 10; i++ {
        std.println("Parent: i=" + std.itoa(i) + " buf=" + std.itoa(a))
        a = i * 7
        if fiberalive(child) {
            fibercall(child)
        }
    }    
}

Functional tools

import "../import/fnc.um"

fn main() {
    var data: fnc.AnyArray = [6]fnc.Any{3, 7, 1, -4, 2, 5}
    printf("Array = %s\n", repr(data))
     
    sqr  := fn (x, ctx: fnc.Any): fnc.Any    {p := ^int(x); return p^ * p^}
    less := fn (x, ctx: fnc.Any): bool       {p := ^int(x); q := ^int(ctx); return p^ < q^} 
    sum  := fn (x, y, ctx: fnc.Any): fnc.Any {p := ^int(x); q := ^int(y); return p^ + q^}     
    
    const max = 30     
    result := data.map(sqr, null).filter(less, max).reduce(sum, null)    
    printf("Sum of all squares less than %d = %s\n", max, repr(result))       
}

Umka vs Go

Purpose

While Go is a compiled systems programming language with a complex runtime library and big output binaries, Umka is a scripting language with a lightweight interpreter that can be easily embedded into any application as a shared library.

Syntax

Umka is very similar to Go syntactically. However, in some aspects it's different. It has shorter keywords: fn for func, str for string, in for range. For better readability, it requires a : between variable names and types in declarations. It doesn't follow the unfortunate C tradition of pointer dereferencing. Instead of *p, it uses the Pascal syntax p^. As the * character is no longer used for pointers, it becomes the export mark, like in Oberon, so that a programmer can freely use upper/lower case letters in identifiers according to his/her own style. Type assertions don't have any special syntax; they look like pointer type casts.

Semantics

Umka allows implicit type casts and supports default parameters in function declarations. It doesn't have slices. Instead, it supports dynamic arrays, which are declared like Go's slices and initialized by calling make(). Method receivers must be pointers. The multithreading model in Umka is inspired by Lua and Wren rather than Go. It offers lightweight threads called fibers instead of goroutines and channels. The garbage collection mechanism is based on reference counting, so Umka needs to support weak pointers. Maps are implemented as an imported module rather than a language core feature. Closures and Unicode support are under development.

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].