> For the complete documentation index, see [llms.txt](https://osl.mistium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osl.mistium.com/start/readme.md).

# OSL

OSL is a compiled scripting language. The compiler reads `.osl` source, generates Go, and builds a native executable.

```osl
import "std:serve"

*serve.Router app = serve.New()

app.GET("/", def(*serve.Context context) -> (
  context.string(200, "Hello from OSL")
))

app.run(":8080")
```

Run a source file while working on it:

```bash
osl run main.osl
```

Build an executable when you want a binary:

```bash
osl compile main.osl -o app
./app
```

## Read this first

Start with [Install and run OSL](/start/getting-started.md). The rest of the guide follows the order in which the language becomes useful:

1. [Programs and variables](/language-guide/programs-and-variables.md)
2. [Types](/language-guide/types.md)
3. [Arrays and objects](/language-guide/collections.md)
4. [Control flow](/language-guide/control-flow.md)
5. [Functions](/language-guide/functions.md)
6. [Structs, enums, and classes](/language-guide/nominal-types.md)
7. [Operators](/language-guide/operators.md)
8. [Errors and results](/language-guide/errors.md)
9. [Imports and project structure](/language-guide/imports-and-projects.md)

The examples use the same style as the production code in `originchats-osl`: type-first declarations, narrow functions, directory imports, typed package handles, explicit assertions at dynamic boundaries, and parentheses around mixed arithmetic.

## Find an API

Language-level functions and methods are listed in [Built-ins and value methods](/tools-and-reference/builtins-and-methods.md). Imported APIs live in the [standard-library package reference](/standard-library/packages.md).

Compiler and project commands have separate references:

* [OSL command line](/tools-and-reference/cli.md)
* [Opal projects](/tools-and-reference/opal.md)
* [Testing](/tools-and-reference/testing.md)
* [Editor tooling](/tools-and-reference/editor.md)

## One rule worth learning now

OSL arrays and strings are 1-indexed. The first item is at index `1`. This affects indexing, loops, slicing, and every example in this guide.
