Concise syntax
Typed function signatures, inferred local values, and optional semicolons keep everyday code compact.
PrinciPL is a statically typed, compiled programming language. The v0.2 compiler turns concise, structured source into native Windows executables.
.prnc and .princi are equivalentOne language, two source suffixesPrinci v0.2.0 · Windows x86-64Portable ZIPAll release files and checksums
Factorial and main
factorial.prnc
fn factorial(n: Int) -> Int {
if n <= 1 {
return 1
}
return n * factorial(n - 1)
}
fn main() {
let result = factorial(5)
println(result)
}princi build factorial.prncfactorial.exePrinci combines explicit blocks and static types with local inference and a single native build command.
Typed function signatures, inferred local values, and optional semicolons keep everyday code compact.
Names, types, calls, members, and control-flow conditions are checked before native code is emitted.
Classes share managed references; structs copy their fields by value. Both fit ordinary structured programs.
The current compiler lowers supported programs through LLVM and links Windows x86-64 executables.
These examples use syntax supported by the v0.2 compiler and its Windows target.
Bindings
values.prnc
fn main() {
let pi: Float = 3.14159
var count = 2
count += 1
println(count)
}Functions and calls
functions.prnc
fn add(a: Int, b: Int) -> Int {
return a + b
}
fn main() {
println(add(20, 22))
}Conditions and loops
control.prnc
fn main() {
var count = 0
if count == 0 {
println("starting")
} else {
println("already running")
}
while count < 2 {
count += 1
}
for index in 0..3 {
println(index)
}
}Classes
user.prnc
class User {
name: String
age: Int
init(name: String, age: Int) {
self.name = name
self.age = age
}
fn birthday() {
self.age += 1
}
}
fn main() {
var user = User("Alice", 24)
user.birthday()
println(user.age)
}Struct values
point.prnc
struct Point {
x: Float
y: Float
}
fn main() {
var point = Point(3.0, 4.0)
let snapshot = point
point.x = 5.0
println(snapshot.x)
println(point.x)
}List<T>
numbers.prnc
fn main() {
var numbers: List<Int> = [1, 2, 3]
numbers[1] = 7
numbers.add(9)
println(numbers.length)
println(numbers[1])
}Both source extensions enter the same compiler pipeline and produce the same target format.
.prnc / .princi
Tokens with source spans
Structured syntax tree
Built-in registry
Typed representation
Verified module
x86-64 COFF
MinGW-w64 runtime
Windows x86-64
Clang verifies LLVM IR and emits the Windows COFF object; MinGW-w64 GCC links the executable and Windows C runtime.
Compiler architectureClasses are references, while structs copy their fields. Generic declarations can specialize either representation.
Assigning a class value shares the same heap object. Instance methods use static dispatch.
Class instance
user.prnc
class User {
name: String
age: Int
init(name: String, age: Int) {
self.name = name
self.age = age
}
fn birthday() {
self.age += 1
}
}
fn main() {
var user = User("Alice", 24)
user.birthday()
println(user.age)
}No inheritance, virtual class methods, or method overloading in v0.2.
Assignment, parameters, and returns copy struct fields. A mutable var can update its fields.
Struct copy
point.prnc
struct Point {
x: Float
y: Float
}
fn main() {
var point = Point(3.0, 4.0)
let snapshot = point
point.x = 5.0
println(snapshot.x)
println(point.x)
}Structs are value types; they can implement traits. Custom layouts are not supported.
A deliberately bounded native compiler, with v0.2 generics, contracts, enums, and documented limitations.
Int, Float, Bool, String, local inference, functions, recursion, assignments, and checked expressions.
if/else, while, integer ranges, classes, value-oriented structs, List<T>, enums, and exhaustive matching.
Monomorphized generic functions and types, bounds, interfaces with dynamic dispatch, traits with defaults, and Result-based propagation.
print/println, a limited C ABI, verified LLVM IR, and Windows x86-64 executable linking.
The compiler also recognizes the built-in io and math import names;math currently exports nothing. C FFI is limited toInt32, Int64, Float64, and Void signatures.
These are possible areas beyond v0.2, not features available in the compiler today. No delivery dates are promised.
Tracing collection is a future possibility. v0.2 keeps managed allocations until main returns; it does not collect during execution.
Ownership, borrowing, raw pointers, and unsafe blocks are not part of the current language.
Linux, macOS, WebAssembly, package management, async, inheritance, and lower-level memory control remain outside v0.2.
Save the program as hello.prnc or hello.princi; the compiler treats them identically.
princi build hello.prnchello.exeUse -o app.exe to choose another output path.Read the compiler, inspect the examples, and track the documented language boundary in the repository.