QuickStart

Get up and running with Strada in 5 minutes.

What you'll learn How to install Strada, write your first program, and understand the basics of the language.

Installation

Clone the Repository

Get the Strada source code from GitHub:

git clone https://github.com/strada-lang/strada-lang.git
cd strada-lang

Build the Compiler

Run make to build the self-hosting compiler:

make

This creates the ./stradac compiler and the ./strada wrapper script.

Verify Installation

Test that everything works by running an example:

make run PROG=test_simple

Your First Program

Create a file called hello.strada:

# hello.strada - Your first Strada program

func main() int {
    say("Hello, World!");
    return 0;
}

Compile and run it:

# Compile and run in one step
./strada -r hello.strada

# Or compile to executable, then run
./strada hello.strada
./hello

Understanding the Code

Let's break down what we wrote:

Variables and Types

Strada is strongly typed. Here are the basic types:

func main() int {
    # Integers
    my int $count = 42;

    # Floating-point numbers
    my num $price = 19.99;

    # Strings
    my str $name = "Strada";

    # Arrays (use @ sigil)
    my array @numbers = [1, 2, 3, 4, 5];

    # Hashes (use % sigil)
    my hash %config = {
        "host" => "localhost",
        "port" => 8080
    };

    say("Count: " . $count);
    say("First number: " . $numbers[0]);
    say("Host: " . $config{"host"});
    return 0;
}
Sigils Like Perl, Strada uses sigils to identify variable types: $ for scalars, @ for arrays, % for hashes.

Functions

Functions are declared with func, parameter types, and return type:

func greet(str $name) str {
    return "Hello, " . $name . "!";
}

func add(int $a, int $b) int {
    return $a + $b;
}

func main() int {
    say(greet("World"));  # Hello, World!
    say(add(10, 20));       # 30
    return 0;
}

Control Flow

If/Else

my int $x = 10;

if ($x > 5) {
    say("x is greater than 5");
} elsif ($x == 5) {
    say("x is exactly 5");
} else {
    say("x is less than 5");
}

Loops

# For loop
for (my int $i = 0; $i < 5; $i++) {
    say($i);
}

# While loop
my int $n = 0;
while ($n < 3) {
    say("n = " . $n);
    $n++;
}

# Foreach loop
my array @fruits = ["apple", "banana", "cherry"];
foreach my str $fruit (@fruits) {
    say($fruit);
}

Working with Arrays

my array @nums = [1, 2, 3];

# Add elements
push(@nums, 4);
push(@nums, 5);

# Get length
my int $len = len(@nums);  # 5

# Access by index
say($nums[0]);  # 1
say($nums[4]);  # 5

# Pop last element
my scalar $last = pop(@nums);  # 5

# Join into string
my str $joined = join(", ", @nums);  # "1, 2, 3, 4"

Working with Hashes

my hash %person = {
    "name" => "Alice",
    "age" => 30,
    "city" => "New York"
};

# Access values
say($person{"name"});  # Alice

# Add/update values
$person{"email"} = "alice@example.com";

# Get all keys
my array @keys = keys(%person);

# Check if key exists
if (exists(%person, "email")) {
    say("Email exists!");
}

String Operations

my str $s = "Hello, World!";

# Length
say(strlen($s));  # 13

# Substring
say(substr($s, 0, 5));  # Hello

# Find
say(index($s, "World"));  # 7

# Replace
my str $new = $s;
$new =~ s/World/Strada/;
say($new);  # Hello, Strada!

# Split
my array @words = split(", ", $s);

# Concatenation
my str $full = "Hello" . " " . "World";

Command-Line Arguments

Access command-line arguments with argc and argv parameters in main:

func main(int $argc, array @argv) int {
    say("Argument count: " . $argc);
    say("Program name: " . $argv[0]);

    if ($argc < 2) {
        say("Usage: " . $argv[0] . " <name>");
        return 1;
    }

    my str $name = $argv[1];
    say("Hello, " . $name . "!");
    return 0;
}

Run it with arguments:

./strada -r greet.strada Alice
# Output:
# Argument count: 2
# Program name: greet
# Hello, Alice!

Next Steps

Language Basics

Deep dive into syntax, operators, and core concepts.

Read more →

Functions

Learn about closures, references, and advanced function features.

Read more →

OOP

Build classes and objects with packages and bless.

Read more →

Cannoli Framework

Build web applications with the built-in web framework.

Read more →