For the complete documentation index, see llms.txt. This page is also available as Markdown.

OSL

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

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:

osl run main.osl

Build an executable when you want a binary:

osl compile main.osl -o app
./app

Read this first

Start with Install and run OSL. The rest of the guide follows the order in which the language becomes useful:

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. Imported APIs live in the standard-library package reference.

Compiler and project commands have separate references:

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.

Last updated

Was this helpful?