Skip to content
/ Orng Public

Orng is a modern systems programming language designed for developers who want fine-grained control without sacrificing expressiveness

License

Notifications You must be signed in to change notification settings

Rakhyvel/Orng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Budi the Orangutan!
For When Life Gives You Orngs...

Orng Programming Language

⚠️WARNING! Orng is still a work in progress! Expect exciting changes and improvements.

🍊 What is Orng?

Orng is a versatile systems programming language I've been developing that gives developers control without sacrificing expressiveness. It is designed to be both lightweight and simple, making it a great choice for enthusiasts and professionals alike.

πŸš€ Quick Start

# Orng compiler requires Zig 0.13.0 at the moment
git clone --recursive https://github.com/Rakhyvel/Orng.git

# Set the Orng Standard Library path environment variable
# For Linux:
export ORNG_STD_PATH="/wherever/you/put/Orng/std"
# For Windows:
$env:ORNG_STD_PATH="/wherever/you/put/Orng/std"

# Build Orng
cd Orng
zig build orng

A fancy hello-world example:

fn main(sys: System) -> !() {
    greet("Orng! 🍊", sys.stdout) catch unreachable
}

fn greet(recipient: String, out: $T impl Writer) -> T::Error!() {
    try out.>println("Hello, {s}", recipient)
}

Run it with:

orng run

✨ Standout Features

Orng comes with a wide range of features that make it a powerful and flexible programming language, including:

First-Class Types

In Orng, types are first class citizens. Pass types as function arguments, return them from functions, and create powerful generic abstractions.

fn make_array_type(const n: Int, const T: Type) -> Type { [n]T }

fn main() {
    let x: template(4, Char) = ('1', '2', '3', '4')
    println("{c} squared is 9", x[3])
}

More examples

Parametric Effect System

Say goodbye to hidden side effects! Orng forbids global variables and requires all objects to be explicitly passed as parameters, making your program's behavior transparent and predictable.

// We can tell this function doesn't do anything dangerous
fn something_harmless(x: T) { /* ... */ }

// We can tell this function probably mutates it's arguments
fn maybe_mutate(x: &mut T) { /* ... */ }

// We can tell this function probably allocates memory
fn maybe_alloc(alloc: impl Allocator) { /* ... */ }

// We can tell this function probably does stuff with IO
fn maybe_write(reader: impl Reader, writer: impl Writer) { /* ... */ }

Traits

Traits offer a flexible way to define behavior that can be attatched to any type. Instead of deep inheritance hierarchies, Orng lets you extend types with new capabilities through simple composable traits.

trait Counter {
    fn increment(&mut self) -> Int
    fn total(&self) -> Int
    fn reset(&mut self) -> ()
}

impl Counter for (count: Int, max: Int) {
    fn increment(&mut self) -> Int {
        self.count = (self.count + 1) % self.max
        self.count
    }
    
    fn total(&self) -> Int { self.count }
    
    fn reset(&mut self) -> () { self.count = 0 }
}

fn main(sys: System) -> !() {
    let mut counter = (0, 5)
    try sys.stdout.>println("{d}", counter.>increment())  // Prints 1
    try sys.stdout.>println("{d}", counter.>increment())  // Prints 2
}

More examples

Algebraic Data Types

Algebraic Data Types (ADTs) allow you to define types that can be one of several variants with zero runtime overhead. Represent complex state machines, parse abstract syntax trees, or handle error conditons with a single, compact type definition.

const Shape = (
    | circle: (radius: Float)
    | rectangle: (width: Float, height: Float)
    | triangle: (base: Float, height: Float))

fn calculate_area(shape: Shape) -> Float {
    match shape {
        .circle(r)         => 3.14 * r * r
        .rectangle(w, h)   => w * h
        .triangle(b, h)    => 0.5 * b * h
    }
}

More examples

Pattern Matching & Destructuring

Pattern matching in Orng lets you elagantly deconstruct complex data structures with a single, readable expression. Forget verbose if-else chains and nested conditionals - match on ADTs, extract values, and handle different cases with unprecedented clarity.

const Person = (name: String, age: Int, job: String)

fn classify_person(person: Person) -> String {
   match person {
       (name, age, "Teacher") if age > 50 => "Veteran Educator"
       (name, _,   "Doctor")                => "Medical professional"
       (_,    age, _)         if age < 18 => "Baby πŸ‘Ά"
   }
}

More examples

Seamless C Interoperability

Compile to C and parse C header files with ease. Orng bridges the gap between low-level system programming and high-level expressiveness.

More examples

🀝 Get Involved

Contributions of all kinds are welcome:

  • πŸ› Report bugs
  • πŸ“ Improve documentation
  • πŸ’‘ Suggest features
  • πŸ§‘β€πŸ’» Submit pull requests

Check out CONTRIBUTING.md for more info!

πŸ“„ License

Orng is open-source and released under the MIT License. See LICENSE for details.