Quick Start Guide
Get up and running with Neuro in 5 minutes.
Prerequisites
Ensure you have completed the Installation Guide before proceeding.
Your First Command
Check that the compiler is installed:
cargo run -p neurc -- --versionOr if you installed it globally:
neurc --versionChecking a Program
Neuro can validate syntax and types without compiling:
cargo run -p neurc -- check examples/basics/hello.nrExpected output:
Type checking passed for "examples/basics/hello.nr" (1 module(s), 19 HIR items)Compiling a Program
Compile a Neuro program to a native executable:
cargo run -p neurc -- compile examples/basics/hello.nrThe compiler prints the paths it produced:
Successfully compiled examples/basics/hello.nr -> examples/basics/helloOn Windows the executable is examples\basics\hello.exe; on Unix it is examples/basics/hello.
Running the Executable
Execute the compiled program:
# Windows
.\examples\basics\hello.exe
# Unix
./examples/basics/helloCheck the exit code:
# Windows (PowerShell)
echo $LASTEXITCODE
# Unix
echo $?The hello.nr program prints two lines and exits with 26.
A program reports a result two ways, and every example in this repository is verified
on both. main's i32 becomes the exit code, pinned in
examples/expected.txt; whatever the program writes to
standard output is pinned byte for byte in a sibling .out file. For text, print and
println write to standard output:
func main() -> i32 {
val name: string = "Neuro"
print("hello from ")
println(name)
return 0
}hello from NeuroEach takes one string, and interpolation renders the holes before the call, so
println("phase {n} of {total}") needs no format arguments. See
examples/basics/greeting.nr for a runnable version
and the functions reference
for the full contract.
Understanding the Examples
hello.nr
The source of examples/basics/hello.nr:
func add(a: i32, b: i32) -> i32 {
return a + b
}
func calculate(x: i32) -> i32 {
val doubled: i32 = x * 2
val result: i32 = doubled + 10
return result
}
func main() -> i32 {
val x: i32 = 5
val y: i32 = 3
val sum: i32 = add(x, y)
println("add({x}, {y}) = {sum}")
val calculated: i32 = calculate(sum)
println("calculate({sum}) = {calculated}")
return calculated
}Features demonstrated:
- Function definitions with parameters and return types
- Calling functions and chaining their results
- Immutable variables (
val) - Integer arithmetic
- String interpolation with
println returnstatements (the program exits with the valuemainreturns, here26)
function_call.nr
The source of examples/basics/function_call.nr:
func add(a: i32, b: i32) -> i32 {
return a + b
}
func main() -> i32 {
val result = add(5, 3)
println("add(5, 3) = {result}")
return result
}Features demonstrated:
- Multiple functions in one file
- Function calls with arguments
- Type inference:
resultgets its type from the call's return type
Compile and run:
cargo run -p neurc -- compile examples/basics/function_call.nr
# Windows
.\examples\basics\function_call.exe
# Unix
./examples/basics/function_callPrints add(5, 3) = 8 and exits with 8.
CLI Options
Check Command
neurc check <file.nr>Validates syntax and types without generating code. Fast feedback for development.
Compile Command
neurc compile <file.nr> [options]Options:
-o, --output <FILE>: output path (default: the input filename without its extension,.exeon Windows)-O, --optimization <0-3>: optimization level (default:0)--emit <exe|obj|llvm-ir>: what to write, a linked executable (default), an unlinked object file, or textual LLVM IR. See the CLI guide
Examples:
# Default output (same name as source)
neurc compile examples/basics/hello.nr
# Custom output path
neurc compile examples/basics/hello.nr -o bin/my_program
# Optimized build
neurc compile -O2 examples/basics/hello.nr
# Compile from a different directory
neurc compile ../path/to/program.nrRun Command
neurc run <file.nr> [options]Compiles into a temporary directory, runs the program, and exits with the program's own
status. Nothing is written beside the source, so this is the command to reach for while
iterating; use compile when you want to keep the binary.
Options:
-O, --optimization <0-3>: optimization level (default:0)
neurc run examples/basics/hello.nrError Messages
Errors print to stderr and the compiler exits with code 1.
Syntax Error Example
Source (bad.nr):
func main() -> i32 {
val x: i32 =
}Error output:
error: unexpected token RightBrace, expected expression --> bad.nr:3:1 |3 | } | ^ Error: Parsing failedType Error Example
Source (mismatch.nr):
func main() -> i32 {
val x: i32 = true
return x
}Error output:
Type errors found in "mismatch.nr":error: type mismatch: expected i32, found bool --> mismatch.nr:2:5 |2 | val x: i32 = true | ^^^^^^^^^^^^^^^^^ Error: 1 type error(s) foundDevelopment Workflow
- Write your Neuro code in a
.nrfile - Check syntax and types:
neurc check program.nr - Run it:
neurc run program.nr - Ship a binary when you want one:
neurc compile program.nr - Iterate: fix errors and repeat
Recommended Workflow
For faster iteration during development:
# Check only (faster, no code generation)
neurc check program.nr
# Compile and run in one step, leaving no binary behind
neurc run program.nr
# When you want to keep the executable
neurc compile program.nr && ./programDebug Logging
Enable debug output to see compilation stages:
# Windows (PowerShell)
$env:RUST_LOG="debug"
neurc compile examples/basics/hello.nr
# Unix
RUST_LOG=debug neurc compile examples/basics/hello.nrThis shows each stage as it runs: module resolution and parsing, type checking, HIR lowering, LLVM IR and object-code generation, and linking.
What the Language Covers
The capability table lists what the compiler supports today, and the Quick Roadmap what is planned. Each feature is defined once, in the language reference.
Common Issues
Compilation succeeds but linking fails
Problem: Missing C toolchain.
Solution: Install C compiler (MSVC on Windows, GCC/Clang on Unix).
"Permission denied" when running executable
Problem: Execute permission not set (Unix).
Solution:
chmod +x ./program
./programSlow compilation
Problem: Building from source in debug mode.
Solution: Use release build for better performance:
cargo build --release -p neurc
cargo run --release -p neurc -- compile program.nrNext Steps
- Your First Program: a detailed tutorial
- Language Reference: the full language
- CLI Usage Guide: every command and flag
- Troubleshooting: common problems and solutions
Getting Help
- Check Troubleshooting Guide
- Read Language Reference
- Report issues: https://github.com/PanzerPeter/Neuro/issues
- Read CONTRIBUTING.md for development guidelines