Learn

Install

SG is built from source for now; packages come with the preview. It runs on Linux, macOS and Windows.

What it needs

Running a program in the interpreter (sg file.sg) needs no C compiler.

Build it

git clone https://github.com/sg-language/sg-lang
cd sg-lang/interpreter
cargo build --release

The command is target/release/sg; put it on your PATH.

Use it

sg hello.sg                      # runs the program in the interpreter
sg build hello.sg -o hello       # compiles it through C: a debug build, which checks overflow
sg build hello.sg --release      # optimised; overflow wraps
sg test hello.sg                 # runs its tests; --compiled runs them compiled
sg emit-c hello.sg               # prints the C
sg help read                     # the page of a word, with no network
sg build --help                  # the page of a command

A folder is a program too (sg shop): every .sg file in it, with the folders beside it as its modules.

An editor

The extension for VS Code is in the repository (editors/vscode): colours, and the first error of the program as you type, with a fix applied with one click for some hints. It starts sg lsp, the language server built into sg. It is not on the Marketplace yet; until then:

(cd editors/vscode && npm ci --ignore-scripts)
code --extensionDevelopmentPath="$PWD/editors/vscode" .

and set sg.path to the sg you built if it is not on the PATH.