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.oslBuild an executable when you want a binary:
osl compile main.osl -o app
./appStart with Install and run OSL. The rest of the guide follows the order in which the language becomes useful:
- Programs and variables
- Types
- Arrays and objects
- Control flow
- Functions
- Structs, enums, and classes
- Operators
- Errors and results
- Imports and project structure
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.
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:
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.