StradaLang

A strongly-typed language inspired by Perl that compiles to native executables via C.

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 overhead in production.

🔒

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.

🧩

Moose-Style OOP

Declarative OOP with has, extends, with, and method modifiers (before/after/around). Auto-generated constructors and accessors.

🌐

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.

📝

Variadic Functions

Accept variable arguments with ...@param syntax. Spread operator unpacks arrays at call sites.

Async/Await

First-class async/await with thread pool. async::all(), async::race(), timeouts, and cancellation.

💻

Interpreter & REPL

Tree-walking interpreter for interactive REPL, quick scripts, and embedded eval — no C compiler needed at runtime.

📖

POD Documentation

Document your code with POD (Plain Old Documentation). Generate HTML docs with the stradadoc tool.

🔧

Map, Grep, Sort

Perl-style array transformations with $_ and blocks. Create lookup hashes with map { $_ => 1 }.

For Perl Developers

Strada is its own language, but if you know Perl, you'll feel right at home.

Strada draws heavily from Perl's syntax — sigils, regular expressions, hashes, Moose-style OOP — and compiles it all to C and then to native machine code. The result is a single binary with no interpreter, no VM, and no runtime dependencies.

Familiar syntax

Sigils ($, @, %), regex (=~, s///), foreach, map, grep, push/pop — the idioms you know from Perl work in Strada with the addition of strong typing.

Perl-to-Strada converter

The included perl2strada tool translates Perl scripts and modules to Strada source as a starting point. Port your existing code and start compiling it.

Up to 5.7x faster

No interpreter dispatch loop, no symbol table lookups, no bytecode overhead. Function calls compile to a single call instruction. Integer arithmetic uses zero heap allocation.

Single-binary deployment

Compile your program once and distribute a standalone native executable. No language runtime required on the target machine.

Coming from Perl? See the Perl integration guide or try perl2strada on your codebase.

Performance Benchmarks

Strada compiles to native machine code via GCC. Here's how it compares.

vs Perl

Compute
5.7x faster
Functions
3.0x faster
OOP
1.8x faster
Array/Hash
3.2x faster
814x
faster than Python
String operations benchmark

Type System

Strong types with Perl-style sigils for clarity.

int

64-bit integers (tagged, zero alloc)

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
Variadic Functions
# Accept variable number of args
func sum(int ...@nums) int {
    my int $total = 0;
    foreach my int $n (@nums) {
        $total = $total + $n;
    }
    return $total;
}

sum(1, 2, 3, 4, 5);   # 15

# Spread operator unpacks arrays
my array @vals = [10, 20, 30];
sum(...@vals);            # 60
sum(1, ...@vals, 99);    # 160
Moose-Style OOP
package Animal;
has ro str $species (required);
has rw int $energy = 100;

package Dog;
extends Animal;
has ro str $name (required);

before "bark" func(scalar $self) void {
    say("[get ready]");
}
func bark(scalar $self) void {
    say($self->name() . " barks!");
}

my scalar $d = Dog::new("name", "Rex",
    "species", "dog");
$d->bark();  # [get ready] / Rex barks!
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.

Alternatively, the tree-walking interpreter can execute Strada programs directly from the AST without generating C code — ideal for interactive use and scripting.

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

Configure and build

Detect dependencies and build the compiler.

./configure && 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