nilang

Crates.ionilang
lib.rsnilang
version0.3.0
created_at2025-11-18 03:11:00.507172+00
updated_at2025-12-03 05:03:57.278436+00
descriptionA scripting language interpreter for Advent of Code
homepagehttps://github.com/Nilando/nilang
repositoryhttps://github.com/Nilando/nilang
max_upload_size
id1937835
size1,869,639
Niland Schumacher (Nilando)

documentation

https://docs.rs/nilang

README

Nilang

A scripting language interpreter designed for Advent of Code 2025!

Overview

Nilang is a dynamically-typed scripting language with a focus on simplicity and expressiveness. It features a custom bytecode compiler with an optimizing IR, register allocation, and a trace and sweep garbage-collected runtime.

Features

  • Dynamic typing - Variables can hold any type
  • First-class functions - Functions as values, closures, partial functions
  • Lists and maps - Built-in collection types
  • For/while loops - Standard control flow
  • REPL - Interactive development
  • And much much more!

Installation

Quick Install (Recommended)

  1. First, install Rust and cargo
  2. Run the installation script:
curl -sSf https://raw.githubusercontent.com/Nilando/nilang/main/install.sh | bash

This will install nilang via cargo, download the standard library, and place it in ~/.nilang/std/.

Building from Source

git clone https://github.com/Nilando/nilang
cd nilang
cargo build --release
./install.sh

Usage

Run a Nilang program:

nilang program.nl

Start the REPL:

nilang

Pipe input to the interpreter:

echo 'print(1 + 2);' | nilang -s

Quick Start

🏗️ Tutorial document is in progress! 🏗️

Check out the examples/ directory for code samples:

  • fibonacci.nl - Fibonacci sequence generator
  • fizzbuzz.nl - FizzBuzz implementation
  • quicksort.nl - Quicksort algorithm
  • game_of_life.nl - Conway's Game of Life
  • eratosthenes_sieve.nl - Prime number sieve
  • And many more!

Try running an example:

nilang examples/fibonacci.nl

Project Status

Nilang is currently in early development (v0.1.0), and may not be maintained/updated any further. The language is functional but may have rough edges. Future features of interest include FFI through standard C bindings and compilation to WebAssembly, though these may not be implemented in the near future.

Known Limitations

  • Error messages need improvement, particularly for parser errors
  • Limited standard library
  • Performance optimizations ongoing
  • No FFI support

Architecture

Nilang uses a multi-stage compilation pipeline:

  1. Lexer → Tokens
  2. Parser → AST
  3. IR Lowering → Three-address code with SSA
  4. Optimization → GVN, constant folding, DCE
  5. Codegen → Register allocation and bytecode emission
  6. VM → Bytecode interpretation with garbage collection

Contributing

Issues and pull requests are welcome! This is a learning project and a work in progress.

License

MIT License - see LICENSE-MIT for details.

Author

Niland Schumacher

Commit count: 0

cargo fmt