Skip to content

webcien/u-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

U Language

Modern, Safe, and Lightweight Systems Programming Language

Version License Build Status


πŸš€ What is U?

U is a systems programming language that combines the best features of modern languages while maintaining simplicity and performance. It offers:

  • Memory Safety through a complete ownership system (like Rust, but simpler)
  • Native GUI with a declarative DSL (like Flutter/SwiftUI)
  • Actor-based Concurrency without data races (like Erlang/Pony)
  • Modern Package Manager for ecosystem growth (like Cargo)
  • Full Generics Support with monomorphization and trait bounds
  • IDE Integration via Language Server Protocol (LSP) and VS Code extension
  • Cross-Platform compilation to Linux, Windows, macOS, and WebAssembly

U compiles to clean C code and uses Zig as a cross-compilation backend, resulting in:

  • ⚑ Zero runtime overhead
  • 🎯 Predictable performance
  • πŸ“¦ Tiny binaries (no runtime, no GC)
  • 🌍 True cross-platform support

✨ Key Features

1. Complete Ownership System

U implements a 7-rule ownership system that guarantees memory safety without garbage collection:

// Explicit deep copies with .clone()
let s1 = "hello";
let s2 = s1.clone(); // s2 is independent

// Multiple immutable references
let v = Vec_new<i32>();
let r1 = &v; // Immutable borrow
let r2 = &v; // OK: Multiple immutable borrows allowed

// Compile-time error on use-after-move
let x = Vec_new<i32>();
let y = x;  // x is moved
// let z = x;  // ERROR: use of moved value

No explicit lifetimes. No borrow checker complexity. Just simple, safe code.

2. Declarative GUI DSL

Build native user interfaces with a clean, declarative syntax:

ui my_app {
    Container {
        width: 600,
        height: 400,
        background: rgb(230, 240, 255),
        child: Column {
            children: [
                Text { text: "Hello, U Language!", size: 24 },
                Button { 
                    text: "Click Me", 
                    onClick: handle_click 
                },
                TextField { placeholder: "Enter text..." }
            ]
        }
    }
}

Compiles to Skia rendering calls. Runs on desktop and mobile.

3. Actor-Based Concurrency

Safe, scalable concurrency without locks or data races:

actor Counter {
    let mut count: i32 = 0;
    
    fn increment() {
        count = count + 1;
    }
    
    fn get_count() -> i32 {
        return count;
    }
}

fn main() {
    let counter = spawn Counter;
    send counter.increment();
    let result = await counter.get_count();
    return 0;
}

Micro-runtime of only 5.3 KB. Zero overhead message passing.

4. Modern Package Manager

Manage dependencies with a Cargo-like package manager:

# Create a new package
ul init my-package

# Install dependencies
ul install u-std

# Build your project
ul build --release

# Publish to registry
ul publish

Package manifest (ul.toml):

[package]
name = "my-package"
version = "1.0.0"

[dependencies]
u-std = "1.0.0"
u-gui = { version = "1.3.0", features = ["skia"] }

5. Full Generics Support

Write generic code that works with any type:

// Generic function with trait bound
fn print_clonable<T: Clone>(value: T) {
    let cloned = value.clone();
    unsafe { printf("Cloned!\n"); }
}

// Generic struct
type Point<T> {
    x: T,
    y: T,
}

fn main() {
    let p1 = Point<i32> { x: 10, y: 20 };
    let p2 = Point<f64> { x: 1.0, y: 2.0 };
    print_clonable(p1);
}

Monomorphization generates specialized code for each concrete type at compile time.

6. IDE Integration (LSP + VS Code)

First-class editor support with the U Language Server:

# Install the Language Server
cd lsp
cargo build --release

# Install VS Code extension
cd editors/vscode
npm install
npm run compile
code --install-extension u-language-1.4.0.vsix

Features:

  • βœ… Autocompletion
  • βœ… Go to definition
  • βœ… Hover information
  • βœ… Real-time diagnostics
  • βœ… Syntax highlighting

7. Cross-Platform Compilation

Compile to any platform from any platform using Zig:

# Compile for Linux
ul build --target x86_64-linux

# Compile for Windows
ul build --target x86_64-windows

# Compile for macOS
ul build --target x86_64-macos

# Compile for WebAssembly
ul build --target wasm32-wasi

πŸ“¦ Installation

Prerequisites

  • Rust (for building the compiler)
  • Zig (for cross-compilation)
  • Git

Build from Source

git clone https://github.com/webcien/u-lang.git
cd u-lang/compiler
cargo build --release

The compiler binary will be at target/release/ul.

Add to PATH

export PATH="$PATH:/path/to/u-lang/compiler/target/release"

🎯 Quick Start

Hello World

Create hello.ul:

fn main() {
    unsafe {
        printf("Hello, U Language!\n");
    }
    return 0;
}

extern "C" {
    fn printf(format: ptr, ...);
}

Compile and run:

ul build hello.ul
./hello

GUI Application

Create gui_app.ul:

ui my_window {
    Container {
        width: 400,
        height: 300,
        background: rgb(255, 255, 255),
        child: Text {
            text: "Hello, GUI!",
            size: 24,
            color: rgb(0, 0, 0)
        }
    }
}

fn main() {
    unsafe {
        skia_init();
        let surface = skia_create_surface(400, 300);
        let canvas = skia_get_canvas(surface);
        render_ui_my_window(canvas);
        skia_save_png(surface, "output.png");
    }
    return 0;
}

Compile:

ul build gui_app.ul

πŸ“š Documentation


πŸ—οΈ Project Structure

u-lang/
β”œβ”€β”€ compiler/          # U Language compiler (Rust)
β”‚   └── src/
β”‚       β”œβ”€β”€ lexer.rs           # Tokenization
β”‚       β”œβ”€β”€ parser.rs          # AST generation
β”‚       β”œβ”€β”€ type_checker.rs    # Type validation
β”‚       β”œβ”€β”€ ownership_checker.rs  # Ownership validation
β”‚       β”œβ”€β”€ concurrency_checker.rs # Concurrency validation
β”‚       β”œβ”€β”€ optimizer.rs       # Code optimization
β”‚       β”œβ”€β”€ package_manager.rs # Package management
β”‚       └── codegen/
β”‚           └── c.rs           # C code generation
β”œβ”€β”€ runtime/           # Runtime libraries (C)
β”‚   β”œβ”€β”€ actor_runtime.c     # Actor system (5.3 KB)
β”‚   β”œβ”€β”€ event_loop_sdl2.c   # Event loop
β”‚   β”œβ”€β”€ layout.c            # Flexbox layout
β”‚   └── skia_real.c         # Skia integration
β”œβ”€β”€ stdlib/            # Standard library (U)
β”‚   β”œβ”€β”€ clone.ul       # Clone trait
β”‚   β”œβ”€β”€ option.ul      # Option<T>
β”‚   β”œβ”€β”€ result.ul      # Result<T, E>
β”‚   β”œβ”€β”€ vec.ul         # Vec<T>
β”‚   └── hashmap.ul     # HashMap<K, V>
β”œβ”€β”€ examples/          # Example programs
β”œβ”€β”€ docs/              # Documentation
└── tests/             # Test suite

πŸ› οΈ Tooling

Compiler Commands

Command Description
ul build <file> Compile a U source file
ul build --release Compile with optimizations
ul build --target <triple> Cross-compile to target platform
ul fmt <file> Format source code
ul lint <file> Lint source code

Package Manager Commands

Command Description
ul init <name> Create a new package
ul install <package> Install a dependency
ul publish Publish package to registry
ul update Update dependencies

🎨 Standard Library

U provides a modern standard library with common data structures:

Type Description File
Option<T> Optional value stdlib/option.ul
Result<T, E> Error handling stdlib/result.ul
Vec<T> Dynamic array stdlib/vec.ul
HashMap<K, V> Hash map stdlib/hashmap.ul
Clone Deep copy trait stdlib/clone.ul

🌟 Why U?

vs. Rust

  • βœ… Simpler ownership (no explicit lifetimes)
  • βœ… Native GUI DSL (no external frameworks)
  • βœ… Smaller learning curve
  • ❌ No borrow checker complexity

vs. Go

  • βœ… No garbage collection (predictable performance)
  • βœ… Memory safety (ownership system)
  • βœ… Native GUI (no web-based UI)
  • ❌ Smaller ecosystem (for now)

vs. Zig

  • βœ… Memory safety (ownership system)
  • βœ… Actor concurrency (safe by default)
  • βœ… GUI DSL (declarative UI)
  • ❌ Uses Zig as backend (dependency)

vs. C/C++

  • βœ… Memory safety (no segfaults, no use-after-free)
  • βœ… Modern syntax (type inference, traits)
  • βœ… Package manager (dependency management)
  • βœ… Same performance (compiles to C)

πŸ“ˆ Roadmap

βœ… v1.6 (Q3 2026) - COMPLETED

  • βœ… Native Windows compiler
  • βœ… GUI with Skia integration
  • βœ… Macro system
  • βœ… Automatic linking scripts

v1.7 (Q4 2026)

  • Interactive GUI (event loop)
  • Compile-time execution
  • Advanced pattern matching
  • Module system improvements

v2.0 (Q4 2026)

  • Async/await over actors
  • LLVM backend (optional)
  • Garbage collection (optional)
  • WebAssembly improvements

🀝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

Development Setup

git clone https://github.com/webcien/u-lang.git
cd u-lang/compiler
cargo build
cargo test

πŸ“œ License

U Language is licensed under the MIT License.

See LICENSE for details.


πŸ™ Acknowledgments

U Language draws inspiration from:

  • Rust - Ownership system and safety
  • Go - Simplicity and tooling
  • Zig - Cross-compilation and C interop
  • Pony - Actor-based concurrency
  • Flutter/SwiftUI - Declarative UI

Special thanks to the open-source community.


πŸ“ž Contact


πŸš€ Get Started

# Clone the repository
git clone https://github.com/webcien/u-lang.git

# Build the compiler
cd u-lang/compiler
cargo build --release

# Try an example
cd ../examples
../compiler/target/release/ul build hello.ul
./hello

Welcome to U Language! πŸŽ‰


Copyright Β© 2025 Webcien and U contributors

About

U is a Modern, Safe, and Lightweight systems programming language

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published