Get Started

Features

  • Lightweight, concise, and consistent syntax design, easy to master and get started quickly
  • Strong type system, static analysis and compilation, memory safety, exception handling, making it easy to write secure and reliable software
  • Built-in concurrency primitives: go/future/channel/select
  • Compiles directly to machine code for the target platform, does not rely on LLVM, and supports cross-compilation.
  • Simple deployment, efficient compilation, static linking based on musl libc with good cross-platform characteristics
  • Comprehensive type system supporting generics, union types, interfaces, nullable(?), errable(!)
  • High-performance GC implementation with very short STW (Stop The World)
  • High-performance memory allocator implementation, referencing tcmalloc
  • High-performance shared-stack coroutine implementation, capable of millions of coroutine switches per second
  • High-performance IO based on libuv implementation
  • High-performance runtime and compiler based on pure C implementation
  • Built-in data structures vec/map/set/tup and common standard library implementations
  • Function calls follow system ABI, built-in libc, c std functions are called without performance loss.
  • Centralized package management system npkg
  • Editor LSP support

Overview

The nax programming language has reached an early usable version, with a basically stable syntax API that will not change significantly before version 1.0. Future versions will add some necessary and commonly used syntax features such as enum, ternary operators, struct labels, etc.

Key features to be completed include controllable memory allocator, LLM coding adaptation, DSL test framework, GUI adaptation, and WASM3.0 adaptation.

The current version supports compilation for the following target architectures: linux_amd64, linux_arm64, linux_riscv64, darwin_amd64, darwin_arm64.

Nax includes a set of test cases and standard libraries to test the usability of basic functionality and syntax, includes a set of small to medium-sized projects to test overall usability, but has not yet been tested in large-scale projects.

Installation

1️⃣ Download the binary package suitable for your system from https://github.com/naxlang/nax/releases and extract it.

2️⃣ Move the nax folder to the /usr/local directory. If you need to install nax in another directory, please manually set the NAX_ROOT environment variable to point to the nax directory.

/usr/local/nax/
├── LICENSE-APACHE
├── LICENSE-MIT
├── VERSION
├── bin
├── lib
└── std

3️⃣ Add the /usr/local/nax/bin directory to your system environment variables, for example cat ~/.zshrc

...
export PATH="/usr/local/nax/bin:$PATH"
...

4️⃣ Run the command nax --version to check the current version

> nax --version
nax vx.x.x - release build 1970-01-01

5️⃣ Run the command nax -h to view help

> nax -h
Nax Programming Language Compiler vx.x.x
 
Usage:
  nax [command] [flags] [arguments]
...

Hello World

Create a main.n file

import fmt  
  
fn main() {  
    fmt.printf('hello nax')
}  

Compile and run the binary file main

> nax build main.n && ./main
hello nax

Specify compilation target platform and architecture

> nax build --target darwin_amd64 main.n

Specify output binary file name as hello

> nax build -o hello main.n

Project Examples

mysql/postgresql/redis drivers https://github.com/weiwenhao/dbdriver

sqlite driver https://github.com/weiwenhao/nature-sqlite

RESTful API example https://github.com/weiwenhao/emoji-api

Lightweight container packaging tool and runtime https://github.com/weiwenhao/parker

Llama2 inference model implementation https://github.com/weiwenhao/llama.n

Tetris game based on raylib https://github.com/weiwenhao/tetris

More syntax examples https://github.com/naxlang/nax/tree/master/tests/features/cases

Editor Support

The LSP server nls is already installed with the nax installation package in the /usr/local/nax/bin directory.

ls -lh /usr/local/nax/bin
total 44696
-rwxr-xr-x@ 1 root  wheel   764K Feb 24 13:18 nax
-rwxr-xr-x@ 1 root  wheel   6.1M Feb 24 13:20 nls
-rwxr-xr-x@ 1 root  wheel    15M Feb 24 13:20 npkg

Search for "nax language" in the VSCode extension marketplace to download the LSP client and start using it.

Learn More

Syntax documentation https://naxlang.org/docs/syntax

Standard library documentation https://naxlang.org/stds

Online playground https://naxlang.org/playground

Contribution guide https://naxlang.org/docs/contribute