Get Started
Introduction
Nature is a general-purpose open source programming language and compiler that aspires to provide developers with a simple and elegant development experience that can simply and efficiently build secure and reliable cross-platform software.
Features
- ✓ Simple, natural, consistent syntax design, even programming beginners can easily grasp, quickly get started!
- ✓ No dependency on llvm and VM, compiles directly to target platform machine code and supports cross-compilation
- ✓ Simple deployment, purely static linking based on musl libc, no additional dependencies, good cross-platform characteristics
- ✓ Comprehensive type system with support for generics, union types, interfaces, null-value safety, etc.
- ✓ Same high-performance GC implementation as go, with very short STW (Stop The World)
- ✓ High-performance memory allocator implementation like go, similar to google/tcmalloc
- ✓ High-performance shared-stack Coroutine implementation, capable of millions of Coroutine switches per second
- ✓ Built-in libuv to handle IO event loops in collaboration with the concatenators
- ✓ High-performance runtime and compiler based on a pure C implementation
- ✓ Modularity and package management system npkg
- ✓ Built-in implementations of common data structures and standard libraries
- ✓ Use try+catch for error handling, match for pattern matching, channel for concurrent communication, select for concurrent processing
- ✓ Follow the system ABI, built-in libc, you can directly call the C language standard library functions to accelerate code development
- ✓ editor lsp support
- ○ High-performance memory management to assist in automatic GC
- ○ Testing DSL in hopes of utilizing AI coding efficiently and consistently
- ○ macho cross-platform linker (lack of macho linker currently prevents cross-compilation on darwin platform)
- ○ Collaborative scheduling system
- ○ Cross-platform compilation support for wasm and risc64 platforms
- ○ Compile to readable go programming language
Project Overview
The nature programming language has reached an early usable version, and the syntax API is basically stable and will not change significantly before version 1.0.
The current version of nature source code supports compilation on the following target platforms
- linux/amd64
- linux/arm64
- darwin/amd64
- darwin/arm64
nature includes a set of test cases and standard libraries to test the usability of basic functionality and syntax, and a small set of projects to test overall usability, but has not yet been tested in medium to large scale projects.
The core work that followed was to improve the usability of the nature programming language, including standard library refinement, performance optimization, user feedback collection, and bug fixes.
Design Philosophy
Go is the programming language I use in my daily work. Its syntax is simple, and it offers very convenient cross-compilation and deployment, a highly efficient and high-performance runtime implementation, and an advanced concurrent design style. However, it also has some inconvenient aspects:
- The overly simplistic syntax leads to insufficient expressive power.
- The type system is not sufficiently comprehensive.
- The error handling mechanism is cumbersome.
- Although the automatic GC and preemptive scheduling designs are excellent, they also limit the application scope of Go.
- Package management methods.
interface{}
- ...
nature is designed to be a continuation and improvement of the go programming language, and pursues certain differences. While improving the above problems, nature has runtime, GMP model, allocator, collector, coroutine, channel, std, etc. similar to go. nature also has no dependency on llvm, high compilation speed, and easy cross-compilation and deployment.
Based on the existing features of the nature programming language, it is suitable for game engines and game development, scientific computing and AI, operating systems and the Internet of Things, the command line, and web development.
Recommendations for Use
As an early programming language, it is currently suitable for the following types of developers
- Technical explorers - people who are willing to try new things, are comfortable with the bugs that existed in earlier versions, and are interested in participating in discussions about language design and improvement.
- Language developers and researchers - developers interested in programming language design and implementation, learning about compilation principles, and learning how to implement a programming language.
- Feedback Contributors - developers who are willing to provide feedback on their use of the language, are able to submit bug reports and suggestions for improvements, and are interested in participating in the project and in improving the standard library.
Not for the following types of developers
- Enterprise users who need to use the language in production environments
- Project developers with high stability requirements
- Beginners looking for a programming related job
- Developers who need a lot of third-party library support
Installation
1️⃣ Download the binary zip for your system at 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, manually set the NATURE_ROOT environment variable to point to the nature directory.
/usr/local/nature/
├── LICENSE-APACHE
├── LICENSE-MIT
├── VERSION
├── bin
├── lib
└── std
└── std
3️⃣ Add the /usr/local/nature/bin
directory to the system environment variables, e.g. cat ~/.zshrc
...
export PATH="/usr/local/nature/bin:$PATH"
...
4️⃣ Run the command nature --version
to view the current version
> nature --version
nature v0.5.0-beta - release build 2025-02-22
5️⃣ Run the command nature -h
to see the available commands
> nature -h
Nature Programming Language Compiler vx.x.x
Usage.
nature [command] [flags] [arguments]
...
Hello Nature
Create the main.n file
import fmt
fn main() {
fmt.printf('hello nature')
}
Compile and run the binary main
> nature build main.n && . /main
hello nature
Specify the target platform and architecture
> nature build --target darwin_amd64 main.n
Specify that the output binary is called hello
> nature build -o hello main.n
Example project
parker lightweight packaging tool
llama.n Llama2 nature language implementation
tetris Tetris based on raylib, macos only.
playground playground server api implementation
Editor support
The lsp server nls
has been installed in the /usr/local/nature/bin directory along with the nature installer.
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 store and download it.
Learn more
Syntax documentation - A detailed description of the syntax of the Nature language.
Standard Library Documentation - Nature Standard Library API reference.
Contribution Guidelines - How to get involved in Nature language development.