Skip to content

Latest commit

 

History

History
131 lines (87 loc) · 2 KB

File metadata and controls

131 lines (87 loc) · 2 KB

Sona Quickstart

This guide gets a new developer from install to a working .sona program in 5-10 minutes.

Estimated time: 5-10 minutes.

Documentation truth rule: if this page and runtime behavior disagree, runtime behavior wins and this page must be corrected before release.

1. Install Sona

Use Python 3.11 or newer.

python -m pip install sona-lang

Check the CLI:

sona --version

Expected shape:

Sona 0.15.1

2. Create hello.sona

Bash or macOS/Linux shell:

echo 'print("Hello, Sona!")' > hello.sona

Windows PowerShell:

'print("Hello, Sona!")' | Out-File -Encoding utf8 hello.sona

3. Run the file

Run it with either CLI form:

sona run hello.sona

or:

sona hello.sona

Expected output:

Hello, Sona!

4. Use one stdlib module

Create math_demo.sona:

import math;

let total = math.add(2, 3);
print("2 + 3 = " + total);

Run it:

sona run math_demo.sona

5. Fix a simple error

Create this broken file:

print(total);

Run it:

sona run broken.sona

Sona should print a short diagnostic. The important part is the hint: define the value before using it. See the full diagnostics contract in docs/errors/v0.14-diagnostics.md.

Corrected version:

let total = 5;
print(total);

6. Source-checkout examples

Official examples are source-repository examples. They are validated by release tests, but installed packages are not required to include them.

From a source checkout:

sona run examples/hello.sona

To validate the full official example suite:

python tools/run_examples.py

CLI behavior contract

  • sona --version prints one line.
  • sona --help is grouped and human-readable.
  • sona with no arguments prints help to stderr and exits 1.
  • CLI errors print to stderr.
  • CLI errors exit with a nonzero code.
  • Stack traces are hidden unless explicitly requested.