---
title: Getting Started
canonical_url: https://mew-lang.org/getting-started/
sidecar_url: https://mew-lang.org/getting-started.md
content_hash: sha256:39cbeeca992783dce16d0bb7bd3af65ebac417ee87f7248d7aed4ae9e2258fcb
tokens: 425
uid: getting-started
reading_time_minutes: 2
---

Getting Started
# Getting Started

 
A Mew program is a file called `main.mew`.

 
```mew
use std;
  
println("Hello, world!");
```

 
Run it:

 
```shell
mew main.mew
```

 
```
Hello, world!
```

 
`run` is the default command, so a bare path runs the program. `mew run main.mew` does the same thing.

 
## The entry point

 
A program starts at the top of `main.mew` and runs its statements in order.

 
Only that file may contain them. Every other file in the compilation holds declarations, and a statement outside a declaration there is an error.

 
```mew
// file: helper.mew
use std;
  
pub fn greet(name: string) -> void {
    println($"Hello, {name}!");
}
  
// file: main.mew
#load "helper.mew"
  
greet("world");
```

 
> [!NOTE]
> The rule is the filename, and it is compared exactly. `Main.mew` is not an entry point.

 
## Exit code

 
A `return` at the top level ends the program and becomes its exit code. It has to be an `int`, since that is all an exit code can carry.

 
```mew
use std;
  
println("giving up");
return 1;
```

 
Reaching the end of `main.mew` without a `return` exits with `0`.

 
## Building without running

 
`mew build` compiles the program and prints where it put it, without launching anything.

 
```shell
mew build main.mew
```

 
```
/home/you/hello/.mew/main.dll
```

 
The build goes in a `.mew` directory beside the file the program starts from. The leading dot matters: a directory whose name starts with one is skipped when sources are discovered, so a build never becomes part of the next compilation.

 
A build is skipped entirely when nothing that decides the program has changed, so running the same unchanged program twice only compiles it once.