# Programs, files, and names

> Learn how Alice files, statements, imports, namespaces, and entry points fit together.

Canonical: https://alice-lang.org/documentation/language/programs/

[Documentation index](https://alice-lang.org/documentation/llms.txt) · [Complete book](https://alice-lang.org/llms-full.txt)

## A program is a set of files

Alice source uses `.al`. Top-level statements execute as the program's entry point. Methods, classes, modules, and other type definitions can appear alongside those statements.

```alice
# A comment runs to the end of the line.
def greet(name : String)
  "Hello, #{name}"
end

puts greet("Alice")
```

A newline ends a statement. Indentation makes nesting readable, but `end` closes a definition or control block. Brace blocks use `}`. The formatter uses two-space indentation.

## Require an Alice file

`require` loads another source file at compile time, relative to the requiring file. You can omit `.al`:

```alice
# lib/greeting.al
def greeting : String
  "Welcome"
end
```

```alice
# main.al
require "./lib/greeting"
puts greeting
```

`alice run main.al` follows transitive requirements and includes each file once. A missing file is a compilation error. This is useful for loose scripts. In a package, `src/**/*.al` is already part of the project; use [package dependencies](https://alice-lang.org/documentation/tools/manifest.md) for separate libraries.

## Import a namespace

```alice
using System.Text
builder = StringBuilder.new
builder.Append("Alice")
puts builder.ToString()
```

`using` makes types from a .NET namespace available by short name. It does not install a dependency. Add external packages with `alice add` first.

For an Alice module, `using Tools` imports its static functions so they can be called without a module prefix. `include` and `extend` are different: they copy mixin behavior into a class. See [modules](https://alice-lang.org/documentation/language/modules.md).

## Namespaces and qualification

```alice
namespace Demo
  module Calc
    def self.twice(x : Int32) : Int32
      x * 2
    end
  end
end
puts Demo::Calc.twice(4)
```

`::` qualifies namespaces, nested types, and constants. A dot calls members. CLR APIs retain their declared spelling: `Math.Sqrt`, `StringBuilder.Append`, and `List(Int32).Add`.

## Application arguments

`ARGV` is the program's argument array. Pass arguments after `--` so the CLI does not treat them as Alice options:

```sh
alice run main.al -- Alice Rabbit
```

```alice
ARGV.each { |arg| puts arg }
```

Use a [project](https://alice-lang.org/documentation/learn/first-project.md) for a repeatable source layout, tests, and dependency restoration.

## Continue reading

- Previous: [Coming from Ruby or C#](https://alice-lang.org/documentation/learn/from-ruby.md)
- Next: [Variables and assignment](https://alice-lang.org/documentation/language/variables.md)
