Installation

macOS

Install Simplex using Homebrew:

Terminal
brew install simplex

Linux

Use the install script:

Terminal
curl -fsSL https://simplex-lang.org/install.sh | sh

Verify Installation

Terminal
simplex --version
# Simplex 0.1.0

Your First Program

Create a file called hello.sx:

hello.sx
fn main() {
    print("Hello, Simplex!")
}

Run it:

Terminal
simplex run hello.sx
# Hello, Simplex!

Project Structure

Create a new project:

Terminal
simplex new my-project
cd my-project

This creates the following structure:

Directory Structure
my-project/
├── simplex.toml        # Project configuration
├── src/
│   ├── main.sx         # Entry point
│   ├── actors/         # Actor definitions
│   └── types/          # Custom types
└── tests/              # Test files

CLI Commands

Essential commands for working with Simplex:

Command Description
simplex run <file> Run a Simplex program
simplex build <file> Compile to bytecode (.sbc)
simplex test Run all tests
simplex fmt Format code
simplex check Type check without running
simplex new <name> Create a new project

Your First Actor

Actors are the core building blocks in Simplex. Create a simple counter actor:

counter.sx
actor Counter {
    var count: i64 = 0

    receive Increment {
        count += 1
    }

    receive Decrement {
        count -= 1
    }

    receive GetCount -> i64 {
        count
    }
}

fn main() {
    let counter = spawn Counter

    send(counter, Increment)
    send(counter, Increment)
    send(counter, Increment)

    let value = ask(counter, GetCount)
    print("Count: {value}")  // Count: 3
}

Your First AI Call

Simplex has first-class AI support. Here's a simple example:

ai-example.sx
fn main() {
    // Simple text completion
    let response = await ai::complete(
        "Explain quantum computing in one sentence."
    )
    print(response)

    // Generate an embedding
    let embedding = ai::embed("Hello, world!")
    print("Embedding dimension: {embedding.len()}")

    // Structured extraction
    struct Person {
        name: String,
        age: i64,
        occupation: String
    }

    let person = await ai::extract<Person>(
        "John Smith is a 35-year-old software engineer."
    )
    print("Name: {person.name}, Age: {person.age}")
}

Build Your First Simplex Solution

Let's build a simple document processor that demonstrates actors, AI, and fault tolerance:

doc-processor.sx
// Define message types
struct Document {
    id: String,
    content: String
}

struct ProcessedDoc {
    id: String,
    summary: String,
    entities: List<String>,
    sentiment: String
}

// Document processor actor
actor DocProcessor {
    var processed: i64 = 0

    receive Process(doc: Document) -> ProcessedDoc {
        // Checkpoint before processing (for fault tolerance)
        checkpoint()

        // Parallel AI operations
        let (summary, entities, sentiment) = await parallel(
            ai::complete("Summarize: {doc.content}"),
            ai::extract<List<String>>("Extract entities: {doc.content}"),
            ai::classify<String>("Sentiment: {doc.content}")
        )

        processed += 1

        ProcessedDoc {
            id: doc.id,
            summary,
            entities,
            sentiment
        }
    }

    receive GetStats -> i64 {
        processed
    }
}

// Supervisor for fault tolerance
supervisor ProcessorSupervisor {
    strategy: OneForOne,
    max_restarts: 3,
    within: Duration::seconds(60),

    children: [
        child(DocProcessor, restart: Always)
    ]
}

fn main() {
    // Start supervised processor
    let supervisor = spawn ProcessorSupervisor
    let processor = supervisor.get_child(DocProcessor)

    // Process a document
    let doc = Document {
        id: "doc-001",
        content: "Simplex is a new programming language designed for AI..."
    }

    let result = ask(processor, Process(doc))

    print("Summary: {result.summary}")
    print("Entities: {result.entities}")
    print("Sentiment: {result.sentiment}")
}

Deploy to the Cloud

Deploy your Simplex application to a swarm:

Terminal
# Deploy to AWS with spot instances
simplex deploy --cloud aws \
    --region us-east-1 \
    --instance-type t4g.micro \
    --spot-enabled \
    --min-nodes 3 \
    --max-nodes 50 \
    --storage s3 \
    --ai-pool g4dn.xlarge:2

# Monitor costs
simplex costs --watch
# Current hourly burn rate: $0.43/hr
# Projected monthly cost: $310
# Spot savings: $892 (74%)

Next Steps

Need Help?

Check out the GitHub repository for source code, discussions, and issue tracking.