Get Started
Features
- ✓ Lightweight, concise, and consistent syntax design, easy to master and quick to get started
- ✓ Strong typing, static analysis and compilation, memory safety, exception handling, easily write safe and reliable software
- ✓ Built-in concurrency primitives: go/future/channel/select
- ✓ Directly compiles to target platform machine code with cross-compilation and linking support, no third-party libraries like llvm required
- ✓ Simple deployment, efficient compilation, static linking based on musl libc with excellent cross-platform characteristics
- ✓ Complete type system supporting generics, union types, interface, 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
- ✓ Pure C implementation of high-performance runtime and compiler
- ✓ Built-in data structures vec/map/set/tup and common standard library implementations
- ✓ Function calls follow system ABI, built-in libc, convenient for calling C standard library functions
- ✓ Centralized package management system npkg
- ✓ Editor LSP support
- ○ More controllable GC implementation, such as gc switch, fast free obj, etc.
- ○ Cross-linker based on zig build source code and refactoring
- ○ Cooperative scheduling system improvements
- ○ Compilation target support for golang, wasm
Project Overview
The Nature programming language has reached an early usable version with stable syntax APIs. There will be no major changes before version 1.0, and subsequent versions will add some necessary and commonly used syntax features such as enum, ternary operators, struct labels, etc.
The current version compilation target architectures include linux_amd64, linux_arm64, linux_riscv64, darwin_amd64, darwin_arm64. Future versions will compile to Windows platform using zig ld.
Nature includes a set of test cases and standard libraries to test basic functionality and syntax availability, contains a set of small to medium projects to test overall availability, but has not yet been tested with large-scale projects.
Installation
1️⃣ Download the binary package suitable for your system from https://github.com/nature-lang/nature/releases and extract it.
2️⃣ Move the nature folder to the /usr/local
directory. If you need to install nature in another directory, please manually set the NATURE_ROOT environment variable to point to the nature directory.
/usr/local/nature/
├── LICENSE-APACHE
├── LICENSE-MIT
├── VERSION
├── bin
├── lib
└── std
3️⃣ Add the /usr/local/nature/bin
directory to your system environment variables, for example cat ~/.zshrc
...
export PATH="/usr/local/nature/bin:$PATH"
...
4️⃣ Run the command nature --version
to check the current version
> nature --version
nature vx.x.x - release build 1970-01-01
5️⃣ Run the command nature -h
to view help
> nature -h
Nature Programming Language Compiler vx.x.x
Usage:
nature [command] [flags] [arguments]
...
Hello World
Create a main.n file
import fmt
fn main() {
fmt.printf('hello nature')
}
Compile and run the binary file main
> nature build main.n && ./main
hello nature
Specify compilation target platform and architecture
> nature build --target darwin_amd64 main.n
Specify output binary file name as hello
> nature 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/nature-lang/nature/tree/master/tests/features/cases
Editor Support
The LSP server nls
is already installed with the nature installation package in the /usr/local/nature/bin directory.
ls -lh /usr/local/nature/bin
total 44696
-rwxr-xr-x@ 1 root wheel 764K Feb 24 13:18 nature
-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 "nature language" in the VSCode extension marketplace to download the LSP client and start using it.
Learn More
Syntax documentation https://nature-lang.org/docs/syntax
Standard library documentation https://nature-lang.org/stds
Online playground https://nature-lang.org/playground
Contribution guide https://nature-lang.org/docs/contribute