neyuki 0.3.0

A small Lua-like scripting language implemented in Rust
Documentation

Neyuki

/neˈjuːki/ — neh-yoo-kee. From 根雪, the base layer of snow that settles early and stays all winter.

Neyuki is a small scripting language for everyday programs: automation, command-line tools, little servers, quick windows and games. It reads like Lua, ships as one executable with no dependencies, and comes with the libraries those jobs need.

local fs = require("@neyuki/fs")

-- count the lines in every Neyuki file under src/
local total = 0
for _, path in fs.walk("src") do
    if fs.extension(path) == ".nyk" then
        local lines = 0
        for _ in fs.lines(fs.join("src", path)) do lines += 1 end
        print(`{path}: {lines}`)
        total += lines
    end
end
print(`total: {total}`)

What it gives you

  • A familiar language. Lua's tables, closures, metatables and coroutines, a Luau-style task scheduler, plus !=, ??, +=, continue, `{interpolation}` and function T:method().
  • Exact integers. Integers never overflow or lose precision; 2 ^ 100 is exact.
  • Optional types, checked before running. local n: number = "x" is reported with its line before anything executes, and neyuki lint shows the same diagnostics in your editor.
  • Batteries for daily work. Files and paths, JSON, dates, running programs, HTTP client and server, PostgreSQL and MySQL, hashing and encryption, windows with 2D drawing and animation, and keyboard and mouse automation.
  • One executable. Pure Rust, no C toolchain, no runtime to install. Scripts can also be compiled to verified bytecode.

Install

Build from source with a recent stable Rust:

git clone https://github.com/neyuki-lang/neyuki
cd neyuki
cargo build --release

The executable is target/release/neyuki (neyuki.exe on Windows); put it on your PATH.

Use

neyuki hello.nyk            # run a script
neyuki lint hello.nyk       # check it without running
neyuki repl                 # try things interactively
neyuki help                 # every command

Documentation

The VS Code extension in the sibling editor-extensions/vscode folder adds highlighting, completion with documentation, live diagnostics, snippets and debugging.

Project layout

src/
├── main.rs            the command-line interface
├── parser/, lexer.rs  tokenizer and parser
├── ast/               syntax tree, spans and visitors
├── sema/              scopes, const and type checks
├── lint/              `neyuki lint`
├── compiler/          constant folding, SSA IR, optimization passes, register allocation, codegen
├── bytecode/          instruction format, serializer, verifier, disassembler
├── vm/                register VM, garbage collector
│   └── libs/          standard libraries and the natives behind lib/*.nyk
├── repl.rs, dap.rs    REPL and debug adapter
└── diagnostics/
lib/                   bundled @neyuki/* modules written in Neyuki
tests/                 .nyk test scripts (`neyuki test`)
bench/, fuzz/          `neyuki bench` and `neyuki fuzz`
docs/

cargo test runs the Rust tests and every script in tests/.

Community

Contributions are welcome; see CONTRIBUTING.md. To report a security vulnerability, follow SECURITY.md instead of opening a public issue.

License

MIT. See LICENSE.