Application programming first
One language for servers, native interfaces, browsers and GPU code.
Dia stands for “do it all”. It aims to be the only language you need for application programming, from the interface to the code underneath. Native compilation, a reactive UI library, and direct access to C libraries are part of that design.
import ui.{View, run, Column, Text, Button, state}
@observable
struct CounterState {
value: i32
}
fn Counter(): View !{alloc} {
let s = state(CounterState{ value: 0 })
<Column spacing=12>
<Text>"Count: ${s.value}"</Text>
<Button
label="Increment"
on_click=() => { s.value += 1 }
/>
</Column>
}
pub fn main(): void !{alloc, io} {
run(() => <Counter />)
}
extern "C" import "raylib.h" as rl
pub fn main(): void !{io, alloc} {
rl.InitWindow(800, 600, "Hello from Dia")
defer rl.CloseWindow()
rl.SetTargetFPS(60)
while !rl.WindowShouldClose() {
rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE)
rl.DrawText(
"A C library, called from Dia.",
40, 40, 24, rl.BLACK
)
rl.EndDrawing()
}
}
struct Note {
title: String
}
fn rename(mut note: Note): void {
note.title = "Revised"
}
fn is_draft(note: Note): bool => note.title == "First draft"
pub fn main(): void !{alloc} {
let original = Note{ title: "First draft" }
var draft = copy original // independent copy
rename(mut draft) // borrow to mutate
let unchanged = is_draft(original) // borrow to read
let saved = take draft // transfer ownership
// draft can no longer be used here.
// original still contains "First draft".
// Owned values are dropped at scope exit.
}
One language for servers, native interfaces, browsers and GPU code.
Safe ownership using owning pointers, second-class borrows and arenas for cyclic structures. No tracing GC.
Import real C headers directly. Manifests add ownership, errors and safety contracts without redeclaring the ABI.
Incremental compilation, editor-oriented checking and state-preserving native hot reload are architectural features.
Dia is a pre-alpha research implementation. The compiler already has native and WebAssembly code generation, C-header interoperability, ownership checking, structured concurrency and an executable reactive runtime. The standard library, UI renderer and developer tooling are still being built.
It is not ready for production use yet.
A language for the whole application: native interfaces, reusable UI and editor libraries, and the freedom to replace the parts you need. Where the ideas come from, who Dia is for, and what’s still ahead.
Read the design note