A New Programming Language | Rift Update #1
Of course! It's great to add the personal journey and the "why" behind the project. That context makes the story much more compelling. Let's weave those points into the blog post.
Here is the updated version:
Introducing Rift: A New Programming Language for a Self-Sufficient Future
Ever wondered what a programming language would look like if it was built from the ground up with safety and self-sufficiency in mind, without relying on a legacy C runtime? That question is the driving force behind a new project I'm excited to share with you today: Rift.
Rift is a compiled, statically-typed programming language designed to be safe, efficient, and completely self-reliant. It’s built using LLVM, and its entire standard library is written in Rift itself, interfacing with the operating system only through direct syscalls.
This post will walk you through the core philosophy of Rift, its origins, its features, and where it's headed next.
Also a quick note, the formatting for the codeblocks is not working... Rift is clearly does not have an LSP yet and is not a suported language is any other formatting tools.
The 'Why' Behind Rift: From a Typed Python to Something More
The idea for Rift started from a simple place: I wanted an easily compiled version of Python. Like many Python developers, I was already using type hints extensively for clarity and robustness, and it felt like a natural next step to have a language that embraced this static nature from the start for better performance.
But as I delved deeper into the design, a more ambitious question emerged: Why stop at being a "better Python" when it could be something more unique? This led me to the core goal of Rift: to create a language that feels like a high-level language but grants the low-level control and performance you'd expect from a systems language.
This is where features like explicit memory management came in. I wanted a language where you could write clean, expressive code but also make conscious decisions about where your data lives on the stack, in the static data segment, or on the heap.
The Philosophy: Safety and Self-Sufficiency
Rift is built on a few core principles that guide its design:
- No C Runtime Dependencies: The standard library is written entirely in Rift. This eliminates a whole class of dependencies and gives us full control over the runtime environment.
- Minimal OS Interface: All operating system interactions, like writing to the console, are handled through direct syscall intrinsics. This makes the language's footprint incredibly small and predictable.
- Safety First: Unsafe operations, like raw pointer manipulation, are explicitly marked within
unsafe
blocks. This isolates potentially dangerous code, making it easier to audit and reason about program safety. - Zero-Cost Abstractions: High-level features are designed to compile down to highly efficient machine code without any hidden performance costs.
A Tour of the Language
Let's jump into some code. Here is a simple Rift program that defines a function and prints a message to the console.
# Rift v0.1 Example Program
stash version: Str = "Rift v0.1"
def add(a: Int, b: Int): Int
return a + b
def main(): Void
println(version)
put x: Int = 10
put y: Int = 20
put result: Int = add(x, y)
print("The sum is: ")
println(result)
This simple example already demonstrates several key features:
Memory Management Keywords
You'll notice the stash
and put
keywords. Rift has a clear and explicit memory allocation model:
put
: This is for stack allocation. It's the default, fast, and memory is automatically cleaned up when it goes out of scope.stash
: This is for static/global allocation. The data is immutable and lives for the entire duration of the program, stored in the data section of the binary.heap
: For manual memory management on the heap (currently a simplified implementation).
I am thinking about adding more keywords to varables soon, like how would you defign a global varable that is mutable? Or how would you make a put varable immutable?
Self-Hosted Standard Library
One thing I wanted for Rift is it to have its own self-hosted standard library. The print
and println
functions you see above are not magical compiler intrinsics in the traditional sense. They are Rift functions, written in stdlib/io.rft
, that build upon a minimal set of syscalls.
Here’s a peek at how print
is implemented in the standard library:
# Low-level syscall wrapper in stdlib/io.rft
def __internal_write(data: Ptr[Char], length: Int): Void
unsafe
syscall(1, 1, data as Int, length)
# High-level safe print function
def print(s: Str): Void
__internal_write(s.data, s.len)
The high-level print
function is completely safe. It calls an internal function which uses an unsafe
block to perform a direct syscall
. This makes OS interactions explicit and auditable while keeping everyday code safe and clean.
Enums, Structs, and More
Rift also includes modern features you'd expect for building robust applications:
- Enums and Pattern Matching: For creating expressive and safe data models, complete with exhaustiveness checking to prevent bugs.
- Structs and Operator Overloading: Allowing you to create custom data types that feel intuitive and integrate cleanly with the rest of the language.
Here's a quick look at a Vector2
struct with an overloaded +
operator:
struct Vector2
x: Float
y: Float
operator +(other: Vector2): Vector2
return Vector2{x: self.x + other.x, y: self.y + other.y}
def main(): Void
put v1: Vector2 = Vector2{x: 1.0, y: 2.0}
put v2: Vector2 = Vector2{x: 3.0, y: 4.0}
# Uses the overloaded '+' operator
put v3: Vector2 = v1 + v2
Performance Aspirations: The LLVM Advantage
Now, let's talk about performance. This is my first time designing a language, and I'm leaning heavily on the power of the LLVM compiler infrastructure. The goal here isn't to create a "C killer" or a "Rust killer" those languages are good at what they do, and I dont think I am in a position to have my first language's goal to be "killing Rust/C".
Instead, the ambition for Rift is to achieve performance that is competitive with languages like Go or Java. By leveraging LLVM's optimization passes, Rift can translate its high-level, expressive syntax into highly efficient machine code. For now i think it's about finding that sweet spot: a great developer experience without sacrificing the performance needed for serious applications.
Current Status and The Road Ahead
Rift is still in its early stages, and there's a lot of work to be done. The source code is currently private, as I want to make more progress before a public release.
One of the biggest limitations right now, a mega downside to be honest is that the compiler only targets Windows. Bringing full support to Linux and macOS is the absolute top priority... after I finish struct and opperator overloading... And it could be helpful to work on debug symbols and update the basic memory profiler so i can get better stats on the BIN, then I think it will be time to work on cross platform.
Here's a glimpse of what's on the roadmap:
- Finish up struct
- Finish up opperator overloading
- Get debug symbols working
- Update basic memory profiler
- Full cross-platform support (Linux, macOS)
- A more comprehensive ownership and memory model
- Richer pattern matching capabilities
- Standard library collections like
List
,Dict
, andSet
- Greatly improved compiler error messages
- Advanced compiler optimization passes
I'm incredibly excited about the potential of Rift to be a truly modern, safe, and self-sufficient systems programming language. It’s a journey that started with a simple idea and has grown into a passion project. I can't wait to share more as it develops. Stay tuned I will try and post an updated every few weeks or when a new milestone is reached!