Object-oriented.
Clean by design.
Sapphire is a Ruby-inspired programming language with gradual typing, first-class blocks, and a clean object model. No magic. No sigils. Just elegant code.
class Greeter {
attr name: String
def greet() -> String {
"Hello, #{self.name}! Welcome to Sapphire."
}
}
g = Greeter.new(name: "world")
print g.greet()
# Blocks, iterators, type annotations — all built in
[1, 2, 3].map { |n| n * n }.each { |n| print n }See the language
Real examples from the standard library and documentation — no toy snippets.
class Shape {
attr color = "red"
def area() { 0 }
def describe() {
"A #{self.color} shape"
}
}
class Rectangle < Shape {
attr width: Int
attr height: Int
def area() {
self.width * self.height
}
def describe() {
super.describe() + " (#{self.width}x#{self.height})"
}
}
r = Rectangle.new(width: 4, height: 5)
print r.describe() # A red shape (4x5)
print r.area() # 20
print r.is_a?(Shape) # trueBuilt with intention
Every design decision in Sapphire has a reason. No magic, no surprises.
Everything is an Object
Primitives like Int, Bool, and String are objects with methods. Call .even?, .upcase, or .times directly on literals.
Blocks & Iterators
First-class blocks and yield make iteration expressive. Build your own higher-order functions naturally.
Gradual Typing
Add type annotations where you want compile-time safety. Leave them off where you want flexibility. Enforced at runtime when present.
Dual Execution
Runs on a tree-walk interpreter today. A bytecode VM is experimental and in active development — it will become the default runtime.
Ruby-Inspired Syntax
Clean, readable syntax with no sigils or metaprogramming surprises. Familiar to Ruby developers, approachable to everyone.
Interfaces as Mixins
Interfaces compose behavior, not just types. Mix them into classes for clean, reusable functionality without multiple inheritance.
Get started
Use facet — the official Sapphire toolchain manager — to install Sapphire and create projects.
- 1
Install facet
$ cargo install --git https://github.com/sapphire-project/facetOr grab a pre-built binary from the facet releases page.
- 2
Install the Sapphire toolchain
$ facet sapphire install latest - 3
Create and run your first project
$ facet new myproject && cd myproject$ facet runHello, Sapphire!