Ultraviolet is a general-purpose systems programming language designed to enhance source code legibility and execution predictability. Built for both human and AI use, it emphasizes clear authority and visible behavior, making it ideal for experimentation and contributions. Explore its unique design philosophy and essential tools.
Ultraviolet is a high-performance, general-purpose programming language crafted to enhance human-AI collaboration through explicit authority, predictable execution behavior, and source code readability. This innovative language serves as a powerful tool for both developers and AI systems, ensuring that code remains legible and maintainable.
Overview
Ultraviolet encompasses a comprehensive suite, including the language specification, a bootstrap compiler, runtime libraries, and developer tools, as well as a conformance verification suite. While currently in the alpha stage, it invites early experimentation, specification reviews, and contributions to its compiler and runtime.
Core Design Principles
Ultraviolet is devised around a set of foundational principles aimed at minimizing hidden costs and ambient risks in programming:
- One Correct Way: Each operation has one standard syntax to eliminate ambiguity, simplifying code comprehension and maintenance.
- Local Reasoning: The impacts of mutability and synchronization are clearly visible in the syntax and types.
- Explicit over Implicit: There are no hidden side effects or operations, ensuring clarity in code behavior.
- Static by Default: The language emphasizes static checks while allowing dynamic behaviors to be utilized only when explicitly permitted.
Language Features
Ultraviolet offers a variety of advanced features:
Capability-Based Authority
External side effects are managed through an explicit capability handle within the program's context, ensuring controlled I/O operations:
public procedure main(ctx: Context) -> i32 {
let io: $IO = ctx.io
let write_result: Outcome<(), IoError> = io~>write_file(
"output.txt",
bytes::view_string("Hello, Ultraviolet!")
)
return if write_result is {
@Value { 0 }
@Error { 1 }
}
}
Modal Types
Ultraviolet supports modeling of state machines and resource lifecycles directly through its type system:
public modal Connection {
@Closed {
public transition connect(address: string@View) -> @Connected {
return Connection@Connected { address: address }
}
}
@Connected {
public address: string@View
public procedure send(~, data: bytes@View) -> bool {
return true
}
public transition disconnect() -> @Closed {
return Connection@Closed {}
}
}
}
Scoped Memory Management
The language introduces arena memory management and frame allocators, allowing efficient resource handling:
public procedure processData() -> i32 {
var sum: i32 = 0
region as scratch {
let temp_array: Ptr<[i32; 3]> = scratch ^ [1, 2, 3]
frame {
let local_val: i32 = ^10
sum = local_val + temp_array[0]
}
}
return sum
}
Concurrency Model
Ultraviolet features a Static Key System within its type system to manage shared memory, permitting safe concurrent operations:
public procedure worker(counter: shared i32) -> i32 {
var observed: i32 = 0
%write counter {
counter = counter + 1
observed = counter
}
return observed
}
public procedure runConcurrency(context: Context) -> i32 {
var counter: shared i32 = 0
return parallel context~>cpu() {
let task_a: Spawned<i32> = spawn [name: "worker-a"] {
worker(counter)
}
let task_b: Spawned<i32> = spawn [name: "worker-b"] {
worker(counter)
}
(wait task_a) + (wait task_b)
}
}
Project Structure
The repository is logically organized into several sections that streamline access to resources:
- Docs/: Contains the official language specification, guiding developers on syntax and semantics.
- Bootstrap/Ultraviolet/: Hosts the C++ implementation of the bootstrap compiler and runtime libraries.
- HelloUltraviolet/: Offers a suite for testing and validating Ultraviolet's core functionalities.
Supported Alpha Targets
The language is available for various platforms, including Linux x86_64, Apple Silicon macOS, and Windows x86_64, with release archives provided for each environment.
Community Engagement
Engagement with the Ultraviolet community can be facilitated through GitHub discussions, email for direct support, and following updates on social media. For contributors, guidelines for getting involved are available in the repository.
For more details and comprehensive documentation, please refer to the Ultraviolet GitHub repository.
No comments yet.
Sign in to be the first to comment.