Back to Examples

Navi Language

Discover Navi Language, a high-performance programming language in Rust, ideal for complex computing tasks and seamless integration in financial systems.

Lines
13,458
Sections
299

Want your own llms.txt file?

Generate a professional, AI-friendly file for your website in minutes!

llms.txt Preview

<script setup>
import Versions from './versions.vue'
</script>

<Versions />

::: details Table of Contents
[[toc]]
:::

## Introduction

Navi (/ˈnævi/) is a high-performance programming and stream computing language developed in Rust, originally designed for complex and high-performance computing tasks. It is also suited as a glue language embedded within heterogeneous services in financial systems.

In addition to its capabilities as a statically typed, compiled language, Navi offers the convenience of script-like execution. It can compile source code into Bytecode (without JIT) or Machine Code (with JIT), providing a flexible development workflow. Theoretically, Navi delivers competitive performance on par with Go, Rust, and C.

### Language Design Philosophy

- **Simple and Clean Syntax**

  Designed with a straightforward and clean syntax.

- **Modern Optional-Type and Error-Handling Design**

  With a modern design of optional types and error handling, Navi allows developers to gracefully manage exceptional cases and abnormal data.

- **No NULL Pointer Panic, Safe Runtime**

  No NULL pointer exceptions. Once your code passed compiles, you can expect consistent and reliable execution.

- **Scripted Execution**

  Supports script-like execution, but offers the same performance comparable to compiled languages like Go.

### Functionalities

- **Dual-Domain Programming**

  Serves as a dual-purpose language, functioning as both a general-purpose programming language and a domain-specific language optimized for incremental computation.

- **High Performance**

  As a statically typed, compiled language, which is comparable to Go, Rust, and C.

- **Cross-platform**

  Running on Linux, Windows, macOS, and through WebAssembly (WASM), it extends its reach to iOS, Android, and Web Browsers.

- **Native Cloud Support (WIP)**

  With its standard library, Navi enables seamless manipulation of cloud computing resources as if they were local.

- **Native Financial Support (WIP)**

  Navi is equipped with native support for incremental financial data computation, making it ideal for real-time calculation and analysis of stock market data.
  It boasts a rich set of scientific computing capabilities, including built-in functions for technical stock market indicators, and standard library support for
  LongPort OpenAPI, significantly reducing development costs for programmatic trading.

## Standard Library

The [Navi Standard Library](/stdlib/) has its own documentation.

## Getting Started

Write a `main.nv`, `.nv` is the file extension of the Navi language.

```nv
fn main() throws {
    let name = "World";
    let message = `Hello ${name}!\n`;
    println(message);
}
```

Output:

```shell
$ navi run
Hello World!
```

> NOTE: If the file name is `main.nv` and it has the `main` function. The `navi run` will use it as the program entry.
> You also can execute with `navi run main.nv`.

This code sample demonstrates the basic syntax of Navi.

- The `use` keyword is used to import the `io` module from the standard library.
- The `//` is used to comment a line.
- The `fn` keyword is used to define a function.
- The `main` function is the entry point of the program, the `main` function must have the `throws` keyword, and it can throw an error.
- The `throws` keyword is used to declare a function that can throw an error.
- The `let` keyword is used to declare a variable.
- The `name` variable is a string type, or you can use `let name: string = "World";` to declare it.
- The `message` variable is defined by a string interpolation (Like JavaScript) by using "``", and the `${name}` is a variable reference.
- The `println` function is used to print a string to the console, the `println` and `print` function is default imported from the `std.io` module.
- Use `;` to end a statement.
- Finally, the Code style uses 4 spaces for indentation.\

## Comments
Preview of Navi Language's llms.txt file. View complete file (13,458 lines) →

Ready to create yours?

Generate a professional llms.txt file for your website in minutes with our AI-powered tool.

Generate Your llms.txt File