Note
Noa is currently a heavily work-in-progress project. The current state of the project does not fully represent what the final result is meant to look like.
Noa is a dynamically typed, imperative, compiled programming language. The language features a familiar C/JS/Rust-like syntax with static variable resolution (so no "variable is not defined" errors!) and a lightweight featureset. Jump down to the samples section for some code samples!
Noa compiles to its own cross-platform bytecode format Ark which in turn can be run through the Noa runtime.
In addition to the language itself, Noa also features a VSCode extension with full(-ish) language support! The extension currently supports basic syntax highlighting, error messages, basic intellisense, go to definition, find all references, and renaming symbols!
This merely a passion project of mine and is not meant to be taken seriously! It's not meant to be a "production-ready" language, but I hope to one day be able to write some somewhat useful programs in it.
Note
Noa can currently only be compiled from source.
Compile from source
To compile and install Noa from source, you need the .NET 8 SDK and runtime and Cargo to compile the compiler and runtime respectively. Once you have .NET and Cargo installed, follow these instructions:
- Clone the repo using
git clone https://github.com/thinker227/noa.git
. cd
into the root of the project (the folder which contains this readme file).- Run the
update-tool.sh
script (or the commands therein, they're all just .NET commands) which will compile and install the complier as a .NET tool. Worry not, you can easily uninstall it usingdotnet tool uninstall noa --global
. cd
intosrc/runtime
and runcargo build -r
which will compile the runtime.- Locate the produced executable (which should be in
target/release
namednoa_runtime
ornoa_runtime.exe
on Windows). - Create an environment variable named
NOA_RUNTIME
containing the file path to the runtime executable. Alternatively you can specify the--runtime <path>
command-line option when runningnoa run
to manually specify the path to the runtime executable, however it's much simpler to use an environment variable. - You'll usually have to restart your terminal and/or pc for the environment variable and .NET tool to be available.
After everything has been installed, you can invoke the Noa CLI using the noa
command from your terminal!
Compile from source
To compile and install the VSCode extension from source, you need Node.js and vsce. Also make sure you have code
available from the command line.
cd
intosrc/vscode-extension
and runnpm install
followed bynpm run compile
.- Run
vsce package
. If it warns you that a license file cannot be found, typey
and enter to continue. - Run
code --install-extension <path>
, replacing<path>
with the file path to the.vsix
file whichvsce
generated.
- AST
- Lexer
- Parser
- Scope/symbol resolution
- Flow analysis
- Optimization
- Bytecode
- Runtime
- CLI
- Language server
Warning
Some of these samples may currently not work.
print("Hello world!");
let x = 0;
x = 1; // ERROR: x is immutable
let mut y = 2;
y = 3; // fine
let x = { // Block expression
let a = 1;
let b = 2;
a + b // Implicit return from block
};
func add(a, b) => a + b;
let num = add(1, 2);
func greet(name) {
print("Hello, " + name + "!");
};
let name = readLine();
greet(name);
func createCounter() {
let mut x = 0;
() => {
x += 1;
x
}
}
let counter = createCounter();
print(counter()); // 1
print(counter()); // 2
print(counter()); // 3
// Import module
import "module.noa" (foo, bar, baz);
// Export stuff
export (val, hello);
let val = 69;
let hello = () => print("Hello!!!");