Overview
Mux is a statically-typed, reference-counted programming language combining simplicity with safety.
Introduction
Mux (fully "MuxLang") is designed with the following principles:
- Java-style explicit typing with local type inference
- Python-style collection literals
- Rust-style pattern matching with guards
- Curly-brace syntax and no semicolons
- Minimal trait/class model using
isinstead ofimplements - Built-in
result<T,E>andoptional<T>for error handling
Key Features
Static Type System
Mux uses strict static typing with no implicit type conversions. All type conversions must be explicit.
auto x = 42 // Type inferred as int
auto y = 3.14 // Type inferred as float
auto name = "Mux" // Type inferred as string
// Explicit conversions required
auto sum = x + y.to_int() // OK
// auto bad = x + y // ERROR: cannot add int and float
No Semicolons
Statements are terminated by end-of-line only:
auto x = 10
auto y = 20
auto sum = x + y
Pattern Matching
Rust-style pattern matching with guards:
match value {
some(v) if v > 10 {
print("Large value: " + v.to_string())
}
some(v) {
print("Small value: " + v.to_string())
}
none {
print("No value")
}
}
Memory Safety
Reference counting provides deterministic memory management without manual allocation or garbage collection pauses.
Language Sections
Explore the detailed language documentation:
- Types - Primitive types, conversions, and the type system
- Variables - Variable declarations, constants, and type inference
- Functions - Function definitions, parameters, and return types
- Control Flow - If/else, loops, match statements
- Classes - Classes, interfaces, and object-oriented features
- Enums - Tagged unions and pattern matching
- Generics - Generic functions and classes
- Collections - Lists, maps, sets, and collection methods
- Error Handling - result and optional types
- Memory - Reference counting and memory model
- Modules - Import system and code organization
Lexical Structure
- Case-sensitive identifiers: letters, digits,
_, not starting with a digit - Whitespace (spaces, tabs, newlines) separates tokens
- Comments:
- Single-line:
// comment - Multi-line:
/* comment */
- Single-line:
- Statement termination: by end-of-line only (no semicolons)
- Underscore placeholder:
_can be used for unused parameters, variables, or pattern matching wildcards
Keywords
func, returns, const, auto, class, interface, enum, match, if, else, for, while, break, continue, return, import, is, as, in, true, false, common, none, some, result, optional, ok, err
Type System Principles
Critical Design Decisions:
- NO dynamic typing
- NO implicit type conversions
- NO runtime reflection
- All generics must monomorphize at compile time
- Interfaces use static dispatch (no vtables)
Getting Help
- Quick Start Guide
- Examples - Code examples for common patterns
- GitHub Issues