Hylo (formerly Val) is a systems programming language that achieves memory safety through mutable value semantics — no borrow checker, no garbage collector, no unsafe blocks. Just values.
Why Hylo Matters
Rust achieves safety through a borrow checker that adds cognitive complexity. Hylo takes a different approach: everything is a value (like Swift structs), and the compiler ensures safety through ownership of values, not references.
What you get for free:
- Memory safety without a borrow checker
- No garbage collector — deterministic cleanup
- No unsafe blocks needed — ever
- Mutable value semantics (like Swift, but stricter)
- Generic programming with type traits
- Compiles to efficient native code via LLVM
- C and C++ interoperability
Quick Start
# Clone and build
git clone https://github.com/hylo-lang/hylo
cd hylo
swift build -c release
# Run a Hylo program
.build/release/hc run main.hylo
The Basics
// Functions
fun greet(_ name: String) -> String {
"Hello, " + name + "!"
}
// Entry point
public fun main() {
print(greet("World"))
// Variables are values
var x = 42
var y = x // y is an independent copy
&y += 1 // Mutate y — x is unchanged
print(x) // 42
print(y) // 43
}
Value Semantics
// Types are values by default
type Point {
var x: Float64
var y: Float64
// Initializer
public memberwise init
// Method
fun distance(to other: Point) -> Float64 {
let dx = x - other.x
let dy = y - other.y
return (dx * dx + dy * dy).square_root()
}
}
public fun main() {
var a = Point(x: 0.0, y: 0.0)
var b = a // b is an independent copy
&b.x = 3.0 // Mutate b — a is unchanged
&b.y = 4.0
print(a.distance(to: b)) // 5.0
}
Ownership and Borrowing (Without a Borrow Checker)
// Parameters have clear ownership conventions:
// let = read-only borrow (default)
// inout = mutable borrow
// sink = ownership transfer (move)
// set = initialize uninitialized memory
fun double(_ x: inout Int) {
&x *= 2
}
fun consume(_ x: sink String) {
print(x) // x is consumed here
}
public fun main() {
var n = 21
double(&n) // n is now 42
print(n) // 42
let s = "hello"
consume(s) // s is moved, cannot use after this
}
Generic Programming
// Traits (like interfaces)
trait Printable {
fun description() -> String
}
// Conformance
extension Int: Printable {
fun description() -> String { self.description() }
}
extension Point: Printable {
fun description() -> String {
"(" + x.description() + ", " + y.description() + ")"
}
}
// Generic function
fun print_all<T: Printable & Collection>(_ items: T) {
var i = items.start_index()
while i != items.end_index() {
print(items[i].description())
&i = items.index(after: i)
}
}
Pattern Matching
type Shape {
case circle(Float64)
case rectangle(Float64, Float64)
}
fun area(_ s: Shape) -> Float64 {
match s {
.circle(let r) -> 3.14159 * r * r
.rectangle(let w, let h) -> w * h
}
}
Safety Comparison
| Feature | C | Rust | Hylo |
|---|---|---|---|
| Memory safety | No | Yes (borrow checker) | Yes (value semantics) |
| Unsafe blocks | All code | Available | Not needed |
| Null pointers | Yes | No (Option) | No |
| Data races | Yes | Prevented | Prevented |
| Learning curve | Low | High | Medium |
Useful Links
Building safe, high-performance systems? Check out my developer tools on Apify for ready-made web scrapers, or email spinov001@gmail.com for custom solutions.
Top comments (0)