Draft:NURL (programming language)

You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed arti

Draft:NURL (programming language)
  • Comment: Interesting programming language, I hope it takes off. From a glance it'll solve people's headaches with token consumption. But for now, the page requires significant coverage in reliable, independent sources. EatingCarBatteries (contribs | talk) 07:09, 17 May 2026 (UTC)

NURL
NURL programming language logo
Paradigms
Designed byThe NURL Project Developers
DeveloperThe NURL Project Developers, open-source community
First appearedMay 14, 2026; 2 months ago (2026-05-14)
Stable release
Grammar v2.0 / May 14, 2026; 2 months ago (2026-05-14)
Typing discipline
Implementation languageNURL (self-hosted), Python (reference compiler)
PlatformLLVM IRnative code
OSLinux, Windows, macOS, WebAssembly (wasm32-wasi)
LicenseMIT, Apache 2.0
Filename extensions.nu
Websitenurl-lang.org
Influenced by

NURL (an acronym for Neural Unified Representation Language, also Non-hUman Readable Language) is a programming language designed exclusively for use by large language models (LLMs).[1] The language is not intended to be easily human-readable; its design principle is the highest possible token density, meaning every syntactic construct minimizes the number of tokens used without information loss.[1] The source-code file extension of NURL is .nu.

Unlike traditional programming languages, in which keywords (such as function, return, class) consume tokens without adding new information, NURL uses prefix notation and the semantic meaning of single characters. For example, a function is declared with the character @, the return statement is ^, and variable binding is denoted with the character :.[1] The grammar of the language is regular and has no exceptions—the same construct always behaves the same way—which facilitates code generation by language models.[1]

NURL is a compiled language whose compiler (nurlc) produces LLVM intermediate representation. The final machine code is generated by the Clang compiler, which in principle makes all platforms supported by LLVM available as targets.[1] The compiler is self-hosting: it is written in NURL, and its bootstrap process requires that two consecutive self-compilation rounds produce byte-for-byte identical LLVM IR, which serves as a determinism check for the compiler.[1]

Design principles

Five principles are central to NURL's design: token efficiency above all, regular grammar, local semantics, a deterministic compiler, and support for all platforms.[1]

Because of token efficiency, writing a simple sum of two integers function requires about fifteen tokens in Python, about twelve in C and about four in NURL.[1] A regular grammar means that a language model can predict the next token with high reliability, with no long-range dependencies: according to the language, the meaning of every token can be inferred from a context of at most eight tokens.[1] A deterministic compiler always produces the same output for the same source code, with no undefined behavior.[1]

Features

Syntax and prefix notation

NURL uses prefix notation of the form OP ARG1 ARG2 ... ARGN, i.e. the operator always precedes its arguments. Types are denoted by single letters: i (signed 64-bit integer), u (unsigned integer), f (floating-point), b (Boolean truth value), s (UTF-8 string) and v (void).[1] Since version 1.8, fixed-width types are also supported, such as i8, i16, i32, u16, u32, u64 and f32.[2]

The most common operator characters are[1]

  • : – binding of a variable, struct, enum or constant
  • = – assignment
  • @ – function definition or struct literal
  • – return type or arrow
  • ^ – explicit return value
  • ? – conditional expression; ?T Option type
  • ?? – exhaustive pattern matching
  • ~ – loop, for-each or mutability prefix
  • ! – logical NOT or Result type prefix in the form ! T E
  • \try-propagate operator and closures (lambdas)
  • % – trait or trait implementation definition
  • $ – import statement
  • # – type coercion
  • ` – string literal

For example, a function defining the sum of two integers is of the form @ add i a i b → i { ^ + a b }.[1]

Memory management

NURL's memory management is designed to be simple and predictable. Bindings are immutable by default: the expression : i x 0 binds the name x to the value 0, so that reassignment is a compile-time error. If mutability is desired, the prefix ~ is used in the form : ~ i x 0.[1] NURL has no garbage collection; instead, values reside by default on the stack, and heap allocations are made through the malloc and free interfaces of the C runtime library.[1]

Unlike Rust, NURL has no borrow checker. Instead, the compiler implements a single-owner model and itself inserts automatic release (auto-drop) for heap-allocated slices and strings when a binding goes out of scope. Automatic release is implemented in stages: stage 1 covers slice literals when leaving a function, stage 2A covers ownership transfer to the caller for functions returning slices, stage 2B covers heap-allocating runtime calls such as nurl_str_cat, and stage 2C covers automatic release of struct fields.[1]

A slice of type [T compiles at the LLVM level into a fat pointer, that is, a struct { T*, i64 } (pointer + length). The string type s is currently a C-style i8* pointer, but user code can wrap it into its own struct for bounds-checked operations.[1]

Type system

NURL's type system is static and strong: all types are known at compile time. Types are inferred automatically, but annotations are optional. The system is algebraic: it supports sum types (enums, denoted with |) and product types (records, i.e. structs). There are no implicit conversions or subtyping; all type coercions are made explicitly with the # operator.[1]

NURL's data types include, among others[1]

  • Integers i, u (default 64-bit) and fixed-width i8, i16, i32, u16, u32, u64
  • Floating-point numbers f and f32
  • Boolean type b
  • String s and its literals between backticks, e.g. `Hello, Wikipedia!`
  • Slice [T (fixed-length or dynamic)
  • Record or struct : Point { i x i y }, instance @ Point { x 3 y 4 }
  • Enum : | Json { JNull JBool b JNum i JStr s }
  • Option ?T, with syntactic variants None and Some
  • Result ! T E, with variants Ok and Err
  • Generic types, e.g. Vec[T]

Modules and visibility

NURL programs are divided into files, which can be imported into one another with the expression $ `path/to/file.nu`. In version 2.0 (May 2026) visibility control was added to the language: the keyword pub marks a top-level definition as public.[2] Per-file strict visibility is activated optionally whenever a file contains at least one pub annotation. In strict mode, every unmarked @ function is private to its file and cannot be called from other files. Files without pub annotations remain in the legacy permissive mode, which guarantees backward compatibility with the existing standard library and test corpus.[2]

Functional programming and closures

Closures are NURL's anonymous functions, defined using the backslash operator, e.g. \ i x → i { * x x }. A closure can be bound to a variable like any other value, and its type is a function type of the form (@ i i), meaning "takes a parameter of type i and returns a value of type i".[1] Values in the closed-over environment are captured by value by default (i.e. copied), whereas multi-field structs can be captured by reference if the binding is marked mutable with the prefix ~.[2]

Pattern matching is implemented at two levels. The simple conditional expression ? predicate value1 value2 returns one of its two values depending on the predicate, and exhaustive pattern matching is done with the ?? operator, which requires covering all variants of a sum type.[1]

Error handling

In NURL, errors are handled mainly via the enum type ! T E { Ok(T) Err(E) } and ?T. The try-propagate operator \ unwraps an Ok value or propagates an Err value, so that the programmer does not have to handle the error locally.[1] For example, parsing two strings into integers and summing them produces either the sum or propagates an error:

@ sum_two s a s b → ! i ParseErr {
  : i x \ ( parse a )       // `\` unwraps Ok and propagates Err
  : i y \ ( parse b )
  ^ @ ! i ParseErr { + x y }
}

In May 2026, a bug was fixed in the compiler that had prevented multi-field Result and Option values from being handled correctly: multi-field payloads are now stored in a heap box at construction time and unboxed at lookup and propagation points.[2]

Traits and generics

Traits are NURL's way of organizing collections of methods into interfaces. They are defined with the % operator and may have default implementations.[1] Generic functions, structs, enums and methods are supported, and the code is expanded at compile time to specific types (monomorphization).

Example of a trait and its implementation:

% Shape [T] {
  @ area T obj → i                 // required method
  @ describe T obj → i {           // default implementation
    ( nurl_print ( nurl_str_int ( area obj ) ) )
    ^ 0
  }
}

% Shape Rect { @ area Rect r → i { ^ * . r w . r h } }

Variadic FFI functions

NURL communicates with the C language through a Foreign function interface (FFI), denoted by the & operator. In version 1.9 (May 2026), FFI declarations may end with the literal ..., in which case they support variadic (variable-argument) functions. The compiler applies the default argument promotions of ISO C §6.5.2.2, i.e. it converts float values to double and narrow integers to int. This makes it possible, among other things, to call the printf family of functions directly from NURL.[2]

Standard library

NURL's standard library resides in the directory stdlib/ and consists of both a C runtime layer (stdlib/runtime.c) and modules written purely in NURL (subdirectories std/ and ext/).[1] The library contains, among others, modules for the following purposes:[2]

Environment and tools

Compiler and building

The compiler toolchain produces LLVM IR (a .ll file) from the source code, after which Clang compiles it into a native binary for the target environment. The bootstrap process has three stages: first compiler/nurlc.py (the Python reference compiler) compiles compiler/nurlc.nu into a stage-0 binary, which compiles itself into a stage-1 binary, which compiles itself into a stage-2 binary. The LLVM IR produced by stage 1 and stage 2 must be byte-for-byte identical, which is the fixed-point requirement of the bootstrap process.[1]

Supported target platforms are[1]

  • Linux x86_64 – the primary development environment
  • Windows x86_64 – fully supported, with the same bootstrap and test software as Linux
  • macOS x86_64 – supported via cross-compilation through zig cc; on Apple silicon via Rosetta 2 translation
  • WebAssembly (wasm32-wasi) – compiled with WASI SDK 24.0, run in a browser or with wasmtime
  • Planned: Android, iOS, embedded systems (no_std), JVM and .NET CLR

Source code formatter

The NURL distribution includes nurlfmt, a deterministic source-code formatter that imposes a canonical style, analogous to Go's gofmt or Rust's rustfmt. The formatter is itself written in NURL, and its requirements include that formatting be idempotent: fmt(fmt(x)) == fmt(x), and that the LLVM IR produced by the compiler be byte-for-byte the same regardless of whether the source has been formatted or not.[2]

Testing

The compiler package contains over 80 NURL test files in the compiler/tests/ directory. The tests are run with the command ./build.sh (Linux/macOS) or build.bat (Windows), and their results are compared against the golden reference output in the file correct.txt. Snapshot testing is also provided, in which the test outputs are stored for comparison.[1]

MCP server and playground

The NURL project provides a browser-based playground at play.nurl-lang.org, which compiles NURL code in real time into a WebAssembly binary and runs it in the browser. The same server also exposes a public MCP endpoint, which language models can use to browse, compile, and explore the libraries without a local toolchain installation.[1]

Example

A Hello world program in NURL:

// main.nu
// Execution begins at the main function.
@ main → i {
  // nurl_print writes to stdout.
  ( nurl_print `Hello, Wikipedia!` )
  ^ 0
}
// $ ./nurlc main.nu > main.ll
// $ clang main.ll stdlib/runtime.o -o main
// $ ./main
// > Hello, Wikipedia!

The sum of the numbers 1–100, used to demonstrate NURL's token efficiency compared to Python:[1]

@ sumto i n → i {
  : i acc 0
  : i k   1
  ~ <= k n { = acc + acc k  = k + k 1 }
  ^ acc
}

A corresponding Python implementation requires about 46 tokens, whereas the NURL version requires about 13 tokens.[1]

History

The starting point for the NURL project is the observation that existing programming languages are designed for humans: keywords, syntactic noise and grammar models are built on the terms of human readers, even though large language models generate and consume code one token at a time. NURL was created to address this challenge.[1]

During the development of the language's earliest versions (Grammar v0.1 → v1.7), the basic syntax, type system and memory-management model were built. In version v1.7 the self-hosting compiler became stable, and subsequent versions focused on language extensions and fixes. Version 1.8 (May 2026) added fixed-width integer and floating-point types, unsigned arithmetic and fpext/fptrunc coercion. Version 1.9 (May 2026) implemented variadic FFI functions and automatic argument promotion, making the C library's printf family directly callable.[2]

Version 2.0 was released on 14 May 2026. Its most significant addition was visibility control via the pub keyword—a necessary foundation for later package management, since a package system requires a clearly defined surface of public interfaces.[2]

Community and use cases

NURL is primarily designed for working with language models. Its most typical use cases are:[1]

  • Backend language for LLM applications: NURL's regular grammar and local semantics improve the reliability of language-model-generated code and reduce hallucinations.
  • AI agents: because NURL is designed to perform well both natively and as WebAssembly, agent code can be sandboxed and run in the browser as well.
  • HTTP servers and API gateways: from version 2.0, the stdlib HTTP server stack supports persistent connections, static file serving, Prometheus metrics, and a reverse proxy (including streaming responses from language models).
  • Games, simulations and cellular automata: the included examples comprise, among others, Conway's Game of Life, Wolfram's Rule 30, the Collatz sequence and simple visualizations on an HTML5 canvas as a WebAssembly target.

NURL is dual-licensed under the MIT License and the Apache License 2.0 (SPDX: MIT OR Apache-2.0).[1]

See also

References

  1. ^ a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag "NURL — Neural Unified Representation Language". NURL Project. Retrieved May 15, 2026.
  2. ^ a b c d e f g h i j "NURL Development Roadmap". NURL Project. Retrieved May 15, 2026.

Category:2026 software Category:Statically typed programming languages Category:Systems programming languages

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.