Draft:Rex (programming language)

You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed arti

Draft:Rex (programming language)
Rex
ParadigmMulti-paradigm: imperative programming, concurrent computing, systems programming
Designed by0xh7
Typing disciplineStatic, strong, type inference
OSCross-platform
LicenseMIT License
Website0xh7.com/projects/rex/
Influenced by
C, C++, Rust, Go


Rex is a systems programming language designed to provide high performance, strong memory safety, and modern concurrency features. The language is inspired by established programming languages such as C, C++, Rust, and Go. Rex aims to combine low-level control over system resources with compile-time safety mechanisms to reduce common programming errors.

The Rex compiler uses a front-end written in Lua and targets C code generation. This approach allows Rex programs to compile into portable C code that can run efficiently across different operating systems and hardware platforms.[1]

Rex focuses on addressing long-standing challenges in systems programming, particularly memory management and concurrent execution. By introducing concepts such as strict ownership rules and transactional state management through its bond system, the language aims to prevent memory leaks, data races, and other concurrency-related errors during compilation rather than at runtime.[1]

Design principles

The design of Rex follows several core principles intended to improve reliability and developer productivity in systems programming:

  • Predictable performance – Rex compiles to C and avoids runtime garbage collection, allowing performance comparable to languages like C and C++.
  • Memory safety without garbage collection – Ownership and borrowing rules enforce safe memory access during compilation.
  • Concurrency by design – The language includes built-in primitives for safe concurrent execution.
  • Developer productivity – Clean syntax and type inference aim to reduce boilerplate code.
  • Structured error handling – The Result type and the ? operator allow explicit and predictable error management.

Core features

Ownership and borrow checking

Rex implements an ownership-based memory management model. Every value in Rex has a single owner, and ownership is transferred when values are passed to functions or assigned to new variables. This prevents common memory errors such as use-after-free.

The Rex compiler also includes a borrow checker that ensures safe references to data. The borrow rules include:

  • Multiple immutable references may exist simultaneously.
  • Only one mutable reference may exist at a time.
  • Mutable and immutable references cannot coexist.

These rules are enforced at compile time, eliminating the need for a garbage collector.[2]

Bond system

Rex introduces a transactional state-management mechanism using the keywords bond, commit, and rollback. This mechanism allows a group of operations to be executed atomically.

fn update_player_score(mut player_score: i32, points: i32) -> Result<i32, str> {
    bond temp_score = player_score
    temp_score += points

    if temp_score < 0 {
        rollback
        return Err("Score cannot be negative")
    } else {
        commit
        return Ok(temp_score)
    }
}

This feature allows developers to ensure that changes to program state are either fully applied or completely reverted.[3]

Concurrency primitives

Rex provides built-in support for concurrent programming:

  • spawn creates lightweight concurrent tasks.
  • channels provide safe communication between tasks through ownership transfer.

These mechanisms aim to reduce the complexity and risk associated with multithreaded programming.

Type system

The Rex type system supports several modern programming constructs:

  • Structs for grouping related data
  • Enums for algebraic data types and pattern matching
  • Generics for reusable abstractions

Deferred execution

The defer keyword ensures that cleanup code is executed when leaving the current scope.

fn process_file(path: str) -> Result<str, str> {
    let file = fs.open(path)?
    defer { fs.close(file) }

    Ok("Success")
}

This feature simplifies resource management such as file handling.

Syntax

Rex syntax is influenced by the C family of programming languages and uses curly braces ({}) to define code blocks.

Variables

let x = 10
mut y = 20
y = y + 1

Functions

fn add(a: i32, b: i32) -> i32 {
    return a + b
}

Standard library

Rex includes a standard library that provides tools for systems programming.[4]

Module Description
rex::io Input and output utilities
rex::fs File system operations
rex::thread Thread management and synchronization primitives
rex::fmt String formatting utilities
rex::net TCP and UDP networking
rex::http HTTP communication and JSON handling
rex::collections Data structures such as vectors and hash maps

Command-line tools

The Rex toolchain includes several command-line utilities:[1]

  • rex run — compile and execute a source file
  • rex build — compile a standalone executable via C
  • rex check — perform static analysis without compiling
  • rex fmt — automatically format source code

References

  1. ^ a b c "Rex-language repository on GitHub". Retrieved 10 March 2026.
  2. ^ "Rex ownership documentation". Retrieved 10 March 2026.
  3. ^ "Rex bond system documentation". Retrieved 10 March 2026.
  4. ^ "Rex standard library documentation". Retrieved 10 March 2026.

Category:Systems programming languages Category:Statically typed programming languages Category:Concurrent programming languages Category:Programming languages created in the 2020s

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.