百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
U

umka-lang

> 数据库
开源

Umka:一种静态类型的嵌入式脚本语言

2.1K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Umka:一种静态类型的嵌入式脚本语言

Welcome to Umka!

Umka is a statically typed embeddable scripting language. It combines simplicity and flexibility with compile-time type checking, following the principle Explicit is better than implicit.

  • Playground
  • Downloads
    • Stable
    • Unstable
  • Installation
    • Homebrew
    • UmBox
  • Packages
  • Documentation
    • Language
    • Standard library
    • Embedding API
  • Editor support
    • Sublime Text
    • VS Code
    • Vim
    • Kakoune
    • Emacs
    • Unreal Engine
    • Zed
  • Community

Features

  • Clean syntax inspired by Go
  • Cross-platform bytecode compiler and virtual machine
  • Garbage collection
  • Arrays and structures compatible with C
  • Polymorphism via interfaces
  • Multitasking based on fibers
  • Type inference
  • Distribution as a static or dynamic library with a simple C API
  • C99 source

Performance

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

Getting Started

  • Try Umka in the playground
  • Download the latest release for Windows and Linux
  • Take a tour of Umka
  • Read the language and standard library documentation
  • Join our community chat
  • Explore the raytracer example that demonstrates many language features like fibers, interfaces and dynamic arrays
  • Play with the toy Lisp interpreter written in Umka
  • Try the more realistic C+Umka embedded scripting example (Note: raylib is required to compile and run it)
  • See what real-life projects successfully use Umka
  • If you are familiar with Go, read about the differences

Examples

  • Raytracer

  • Lisp interpreter

  • C+Umka 3D camera

Projects in Umka

  • tophat: A 2D game framework focused on minimalism

  • SaveScum: A tophat-based puzzle platformer game

  • Money, please!: A visual novel/puzzle game. Designed and developed in 96 hours for GMTK Game Jam 2024

  • I LOVE FEM: A tophat-based 2D finite element method demo

  • SpaceSim: A 3D orbital rendez-vous and docking simulation that uses a custom software renderer written in pure Umka, with tophat as a 2D drawing backend

  • Hover! maze demo: A 3D demo program that loads the original assets of the game Hover! and uses a software renderer similar to that of SpaceSim

  • Umka OS: A proof of concept operating system written in C and Umka

  • buum: A build system with Umka scripting, used in tophat

  • kilocat: A port of the kilo text editor

  • limeka: A port of the lite text editor

  • VDrift/Umka: A racing simulator that lets you design, tune and test your own car autopilot

  • TractorSim3D: A 6 DOF tractor dynamics simulator with a scriptable steering controller and raylib-based graphics

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

…

Variables

var e: int

var f: String = d + "!"

var (
    g: Arr = {2.3, -4.1 / 2, b}
    h: DynArr
    m: MyMap
)

q := Quat{{1, 0, 0, 0}, true}

Functions

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

fn getValue(): (int, bool) {
    return 42, true
}

callback := fn (event: int): bool |context| {   // Closure capturing context
    return context.ok && event > 0
}

Methods

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

Statements

Assignment

a = 42
m["Hello Umka"] = 3.14
alpha, beta = beta, alpha

Declaration via assignment (with type inference)

sum := 0.0
h := make([]int, 3)

Function call

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

Method call

g.print()

Conditional

if x, ok := getValue(); ok {
    printf("Got %v\n", x)
}

Switch

switch a {
    case 1, 3, 5, 7: printf("%d is odd\n", a)
    case 2, 4, 6, 8: printf("%d is even\n", a)
    default:         printf("I don't know\n")
}

switch v := type(val) {          // val is an interface 
    case int: printf("int: %d + 5 = %d\n", v, v + 5)
    case str: printf("str: %s + 5 = %s\n", v, v + "5")
    default:  printf("unknown: %v\n", a)
}

Loop

for k := 1; k <= 128; k *= 2 {
    printf("%v\n", k)
}

for i, x in g {
    if fabs(x) > 1e12 {break}
    if x < 0 {continue}
    sum += x
}

Multitasking

a := new(int)

child := make(fiber, |a| {    // a is captured  
    for i := 0; i < 5; i++ {
        printf("Child : i = %d buf = %d\n", i, a^)
        a^ = i * 3
        resume()              // Switch back to parent
    }
})

for i := 0; i < 10; i++ {
    printf("Parent: i = %d buf = %d\n", i, a^)
    a^ = i * 7
    if valid(child) {
        resume(child)         // Switch to child
    }
}

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 and identifiers: fn for func, in for range, str for string. 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. Closure definitions require explicit lists of captured variables.

Semantics

Umka allows implicit type casts and supports default parameters in function declarations. It features the ternary conditional operator deliberately omitted from Go. It doesn't have slices as separate data types. 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.

Reviews

  • Tsoding Daily

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •Playground
  • •Downloads
  • •Unstable
  • •Installation
  • •Homebrew
  • •Packages
  • •Documentation
  • •Language
  • •Standard library
  • •Embedding API

> 标签

Cccompilerconcurrencycoroutines

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库