StradaLang

A strongly-typed programming language inspired by Perl that compiles to C for blazing-fast native executables.

my str $greeting = "Hello, Strada!";
my array @numbers = [1, 2, 3, 4, 5];

foreach my int $n (@numbers) {
    say($greeting . " Number: " . $n);
}
Get Started Documentation

Why Strada?

Combining Perl's expressiveness with strong typing and native performance.

🚀

Native Performance

Compiles to C, then to native machine code via GCC. No VM, no interpreter overhead.

🔒

Strong Typing

Catch errors at compile time with explicit types: int, num, str, array, hash, and more.

Perl-Inspired Syntax

Familiar sigils ($, @, %), expressive string handling, and powerful regex support.

🔄

Self-Hosting Compiler

The Strada compiler is written in Strada itself, demonstrating the language's capabilities.

🧩

OOP Support

Clean object-oriented programming with packages, methods, inheritance via bless().

🌐

Web Framework

Includes Cannoli, a built-in web framework with routing, file uploads, chunked responses, and SSL/TLS support.

🔗

C Interoperability

Embed C code directly with __C__ blocks. Create and import shared libraries (.so) with import_lib.

📦

Closures & First-Class Functions

Anonymous functions with automatic variable capture. Pass functions as values.

Exception Handling

Modern try/catch/throw for robust error handling. Clean exception propagation.

🔐

SSL/TLS Support

Built-in ssl:: module for secure networking with OpenSSL. Full TLS 1.3 support.

📊

Function Profiling

Built-in profiler with -p flag shows call counts and timing for performance analysis.

Type System

Strong types with Perl-style sigils for clarity.

int

64-bit integers

num

Floating-point numbers

str

UTF-8 strings

array

Dynamic arrays

hash

Key-value maps

scalar

Generic type

$var

Scalar sigil

@arr

Array sigil

%hash

Hash sigil

Code Examples

See Strada in action with real-world examples.

Hello World
func main() int {
    say("Hello, World!");
    return 0;
}
Variables & Types
my int $count = 42;
my num $price = 19.99;
my str $name = "Strada";
my array @items = [1, 2, 3];
my hash %config = {
    "host" => "localhost",
    "port" => 8080
};
Functions
func factorial(int $n) int {
    if ($n <= 1) {
        return 1;
    }
    return $n * factorial($n - 1);
}

say(factorial(10)); # 3628800
Object-Oriented Programming
package Dog;

func new(str $name) scalar {
    my hash %self = { "name" => $name };
    return bless(\%self, "Dog");
}

func speak(scalar $self) void {
    say($self->{"name"} . " says woof!");
}

my scalar $dog = Dog::new("Rex");
$dog->speak();  # Rex says woof!
Closures
func make_counter() scalar {
    my int $count = 0;
    return func () {
        $count++;
        return $count;
    };
}

my scalar $counter = make_counter();
say($counter->());  # 1
say($counter->());  # 2
Exception Handling
func divide(int $a, int $b) int {
    if ($b == 0) {
        throw "Division by zero";
    }
    return $a / $b;
}

try {
    my int $result = divide(10, 0);
} catch ($e) {
    say("Error: " . $e);
}
Web Server (Cannoli)
func handle(scalar $c) hash {
    my str $path = $c->path();

    if ($path eq "/") {
        return $c->json({
            "message" => "Welcome to Strada!"
        });
    }

    return $c->not_found();
}
Command-Line Arguments
func main(int $argc, array @argv) int {
    if ($argc < 2) {
        say("Usage: " . $argv[0] . " <name>");
        return 1;
    }
    say("Hello, " . $argv[1] . "!");
    return 0;
}
C Interop (__C__ Blocks)
__C__ {
    #include <math.h>
}

func fast_sqrt(num $x) num {
    __C__ {
        double val = strada_to_num(x);
        return strada_new_num(sqrt(val));
    }
}

say(fast_sqrt(16.0)); # 4.0

Compilation Pipeline

From source code to native executable in three steps.

📝
Strada Source
.strada
⚙️
C Code
.c
🚀
Native Binary
executable

The self-hosting compiler is written in Strada and compiles Strada source code to portable C, which is then compiled by GCC to produce fast, native executables with no runtime dependencies beyond the standard C library.

Getting Started

Up and running in minutes.

1

Clone the repository

Get the source code from GitHub.

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

Build the compiler

Compile the self-hosting Strada compiler.

make
3

Write your first program

Create hello.strada with your favorite editor.

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

Compile and run

Use the Strada compiler to build and execute.

./strada -r hello.strada