Nova is a memory-safe, ahead-of-time compiled programming language with a Rust-inspired ownership and borrow model and C-level performance.
The compiler (nova) is implemented in Go for fast iteration and compiles Nova
source to optimized native code via C/GCC. Every module of a program is
compiled into its own C translation unit.
Build the compiler:
cd nova
make buildRun a program:
./nova run examples/hello.nvBuild a binary:
./nova build examples/fib.nv -o fib
./fibCheck a file:
./nova check examples/hello.nvRun the test suite:
./nova test tests/specCreate a project:
./nova init my-projectmod util; // load util.nv
use util::parse; // import an item
struct Point { x: i64, y: i64 } // a struct
enum Color { Red, Green } // an enum
trait Shape { fn area(&self) -> i64; }// a trait
fn distance(p: Point) -> i64 { // a function
let mut total = 0;
for i in 0..10 { // a range
total = total + i;
}
return total;
}
fn main() {
let mut numbers: Vec<i64> = Vec::new(); // a generic vector
numbers.push(1);
let text = String::from("hello"); // an owned string
text.push_str(" world");
let value = parse("42"); // a Result
match value {
Result::Ok(v) => println(v),
Result::Err(e) => println(e),
}
return 0;
}
String,Vec<T>andHashMap<K, V>own their memory and release it automatically at the end of their scope.- User defined types keep move semantics: the borrow checker rejects the use of a value after it was moved.
&Tis a shared borrow,&mut Tan exclusive borrow.- Every index is checked at runtime and every panic reports the file, the line and the column.
- Integer arithmetic traps on overflow and on a division by zero.
| Command | Description |
|---|---|
nova run <file> |
compile and run a program |
nova build <file> [-o out] |
compile to a native binary |
nova check <file> |
type check without generating code |
nova test [dir] |
run the in-language test suite |
nova init [dir] |
create a new project |
nova dump ast|types <file> |
print the syntax tree or the resolved types |
nova lsp |
language server (see docs/lsp.md) |
cmd/nova— compiler driver, test runner, project scaffolding, language server.lang/— lexer, parser, AST, prelude and module loader.sema/— type checker, borrow checker, trait resolution.codegen/— C code generation, runtime and ownership helpers.types/— the type system.diag/— structured diagnostics.stdlib/std/— the standard library.tests/— the test suite.bench/— the benchmark suite.docs/— the language reference, the LSP specification and the self hosting plan.
docs/language.md— the language reference.docs/lsp.md— the language server specification.docs/self-hosting.md— the self-hosting plan.docs/roadmap.md— the status of the implementation.