Introduction to Ferret
Ferret is a modern, type-safe programming language designed for clarity, safety, and developer productivity.
Type Safety
Section titled “Type Safety”Ferret’s powerful type system catches errors at compile-time, not runtime. With optional types, error types, and flow-sensitive type narrowing, you can write code with confidence.
Modern Syntax
Section titled “Modern Syntax”Clean, expressive syntax that’s easy to learn and pleasant to write. Inspired by the best features of modern languages.
Error Handling
Section titled “Error Handling”First-class error handling with result types (E ! T) that make dealing with failures explicit and safe.
Optional Types
Section titled “Optional Types”No more null pointer exceptions! Optional types (T?) and the coalescing operator (??) make handling missing values a breeze.
Quick Example
Section titled “Quick Example”import "std/io";// Variables with type inference// Functionsfn greet(name: str) -> str { return "Hello, " + name + "!";}
fn main() { let name: str = "Ferret"; let version: i32 = 1;
// Optional types let maybeValue: i32? = 42;
if maybeValue != none { // Type narrowing - maybeValue is i32 here let doubled: i32 = maybeValue * 2; }
// Coalescing operator for default values let value: i32 = maybeValue ?? 0;
io::Println(greet(name));}