# Getting Started

All examples use the same Stof document.

## The Example

Save this as `hello.stof`:

```rust
str message: "Hello, Stof!"

fn greet() -> str {
    `${self.message} Data and logic, together.`
}

#[main]
fn main() {
    pln(self.greet());
}

/* Output:
Hello, Stof! Data and logic, together.
*/
```

***

## CLI

**Install:**

```bash
cargo install stof-cli
```

{% hint style="info" %}
Don't have Rust? [Install it here](https://doc.rust-lang.org/book/ch01-01-installation.html) - cargo comes with it.
{% endhint %}

**Run:**

```bash
stof run hello.stof
```

{% hint style="info" %}
VS Code user? Search "Stof" in the extensions tab for syntax highlighting.
{% endhint %}

***

## TypeScript

**Install:**

```bash
npm i @formata/stof
```

**Run:**

```typescript
import { stofAsync } from '@formata/stof';

const doc = await stofAsync`
    message: "Hello, Stof!"

    fn greet() -> str {
        \`\${self.message} Data and logic, together.\`
    }

    #[main]
    fn main() {
        pln(self.greet());
    }
`;

// Bridge with your host environment
doc.lib('Std', 'pln', (...args: unknown[]) => console.log(...args));

await doc.run(); // Hello, Stof! Data and logic, together.
```

***

## Python

**Install:**

```bash
pip install stof
```

**Run:**

```python
from pystof import Doc

doc = Doc()
doc.parse("""
    str message: "Hello, Stof!"

    fn greet() -> str {
        `${self.message} Data and logic, together.`
    }

    #[main]
    fn main() {
        pln(self.greet());
    }
""")
doc.run()
# Hello, Stof! Data and logic, together.
```

***

## Rust

Add to `Cargo.toml`:

```toml
[dependencies]
stof = "0.9.*"
```

**Run:**

```rust
use stof::model::Graph;

fn main() {
    let mut graph = Graph::default();

    graph.parse_stof_src(r#"
        str message: "Hello, Stof!"

        fn greet() -> str {
            `${self.message} Data and logic, together.`
        }

        #[main]
        fn main() {
            pln(self.greet());
        }
    "#, None).unwrap();

    graph.run(None, true).unwrap();
    // Hello, Stof! Data and logic, together.
}
```

***

## What's next?

* [Try the playground](https://play.stof.dev/) — no install required
* [Core Concepts](/core-concepts/design.md) — understand how Stof works
* [Schemas](/common-patterns/schemas.md) — self-validating data
* [Async](/advanced-features/async.md) — parallel execution


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stof.dev/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
