Soli Language Reference
A comprehensive guide to the Soli programming language. Learn the syntax, types, control flow, functions, classes, and advanced features that make Soli unique.
Getting Started
What is Soli?
Soli is a modern, statically-typed programming language designed for clarity and expressiveness. It combines object-oriented programming with functional concepts like the pipeline operator, making it ideal for web development and data processing.
Hello World
hello.soli
Runnable
// The classic first program
print("Hello, World!");
Your First Soli Program
area.soli
// A simple program that calculates the area of a circle
fn calculate_area(radius: Float) -> Float {
return 3.14159 * radius * radius;
}
let radius = 5.0;
let area = calculate_area(radius);
print("The area of a circle with radius " + str(radius) + " is " + str(area));
// Output: The area of a circle with radius 5.0 is 78.53975
Running Soli Code
# Run a single file
soli run hello.soli
# Run with hot reload (development)
soli serve
# Run tests
soli test
# Build for production
soli build --release
Quick Reference
Variables & Functions
// Variables
let name = "Alice";
let age: Int = 30;
const PI = 3.14159;
// Function
fn add(a: Int, b: Int) -> Int {
return a + b;
}
Class
class Person {
name: String;
new(name: String) {
this.name = name;
}
fn greet() -> String {
return "Hello, " + this.name;
}
}
Control Flow
// If/Else
if (condition) {
// code
} else {
// code
}
// For Loop
for (item in collection) {
// code
}
// Match
match value {
pattern => result,
_ => default,
}
Pipeline & Collections
// Pipeline
value |> fn1() |> fn2();
// Collections
arr.map(fn(x) x * 2);
hash.filter(fn(p) p[1] > 0);
Ready to Learn?
Start with Variables & Types to learn the fundamentals of Soli.