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, dynamically-typed programming language with optional type annotations. It combines object-oriented programming with functional concepts like the pipeline operator, making it ideal for web development and data processing.
Hello World
# The classic first program
print("Hello, World!");
Your First Soli Program
# A simple program that calculates the area of a circle
def calculate_area(radius: Float) -> Float
3.14159 * radius * radius
end
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.sl
# Run with hot reload (development)
soli serve
# Run tests
soli test
# Lint code for style issues
soli lint # all .sl files in current dir
soli lint src/ # lint a directory
soli lint app/main.sl # lint a single file
# Build for production
soli build --release
Quick Reference
# Variables
let name = "Alice";
let age: Int = 30;
const PI = 3.14159;
# Function
def add(a: Int, b: Int) -> Int
a + b
end
class Person
name: String;
new(name: String)
this.name = name;
end
def greet -> String
"Hello, " + this.name
end
end
# If/Else
if (condition)
# code
else
# code
end
# For Loop
for (item in collection)
# code
end
# Try/Catch
try
risky_operation();
catch e
print(e);
end
# Match
match value
pattern => result,
_ => default,
end
# Pipeline
value |> transform() |> format();
# Collections
arr.map(def(x) x * 2);
hash.filter(def(p) p[1] > 0);
Ready to Learn?
Start with Variables & Types to learn the fundamentals of Soli.