NTNT

Experimental: NTNT is a research language exploring AI-assisted development. It is not ready for production use.

Installation

1 Install NTNT

Run one command to install NTNT. This automatically installs Rust if needed, clones the repo, and builds NTNT.

macOS / Linux:

curl -sSf https://raw.githubusercontent.com/ntntlang/ntnt/main/install.sh | bash

Windows (PowerShell):

irm https://raw.githubusercontent.com/ntntlang/ntnt/main/install.ps1 | iex
Manual Installation

1. Install Rust via rustup.rs

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"

2. Clone and build:

git clone https://github.com/ntntlang/ntnt.git
cd ntnt
cargo build --release
cargo install --path . --locked
2 Hello World

macOS / Linux:

echo 'print("Hello, World!")' > hello.tnt
ntnt run hello.tnt

Windows (PowerShell):

Set-Content -Path hello.tnt -Value 'print("Hello, World!")' -Encoding UTF8
ntnt run hello.tnt
3 A Web API
// api.tnt
import { json } from "std/http/server"

fn home(req) {
    return json(map { "message": "Hello!" })
}

fn get_user(req) {
    return json(map { "id": req.params["id"] })
}

get("/", home)
get("/users/{id}", get_user)

listen(3000)
ntnt run api.tnt
# Visit http://localhost:3000

Hot-reload: HTTP servers automatically reload when you edit the source file. No restart needed.

Intent-Driven Development

IDD bridges human requirements and AI implementation with verifiable traceability. Write .intent files describing features, link code with @implements, and verify everything matches.

1 Write an intent file
# server.intent

## Glossary

| Term | Means |
|------|-------|
| a user visits the {path} | GET {path} |
| a user visits {path} | GET {path} |
| home page | / |
| page loads successfully | status: 200 |
| they see "{text}" | body contains "{text}" |

---

Feature: User Greeting
  id: feature.greeting
  description: "Display a personalized greeting"

  Scenario: Greet by name
    description: "User provides their name and gets a personal greeting"
    When a user visits /?name=Alice
    → page loads successfully
    → they see "Hello, Alice"

  Scenario: Default greeting
    description: "User visits without a name and gets default greeting"
    When a user visits the home page
    → page loads successfully
    → they see "Hello, World"
2 Annotate your implementation
// server.tnt
import { html } from "std/http/server"

// @implements: feature.greeting
fn home(req) {
    let name = req.query_params["name"] ?? "World"
    return html("<h1>Hello, {name}!</h1>")
}

get("/", home)
listen(8080)
3 Verify with intent check
$ ntnt intent check server.tnt

=== NTNT Intent Check ===

Source: server.tnt
Intent: server.intent

Starting server on port 18081...

=== Test Results ===

✓ Feature: User Greeting
  ✓ Greet by name
  ✓ Default greeting
  ✓ GET /?name=Alice
  ✓ GET /

=== Summary ===
Features: 1 total, 1 passed, 0 failed
Scenarios: 2 passed, 0 failed, 0 skipped
Assertions: 4 passed, 0 failed
4 Visual development with Intent Studio

See live test results as you code:

ntnt intent studio server.intent
# Opens http://127.0.0.1:3001 with live pass/fail indicators

Design by Contract

Contracts are executable specifications. Agents read them as machine-readable specs. Humans read them as documentation.

fn withdraw(amount: Int) -> Int
    requires amount > 0
    requires amount <= self.balance
    ensures result >= 0
{
    self.balance = self.balance - amount
    return self.balance
}

// In HTTP routes, contract violations become proper errors:
// - Failed precondition: 400 Bad Request
// - Failed postcondition: 500 Internal Server Error

Standard Library

Batteries included. No package manager needed.

Web std/http/server, std/http HTTP server with routing, middleware, static files; HTTP client
Data std/json, std/csv, std/db/postgres Parse and stringify; PostgreSQL with transactions
I/O std/fs, std/path, std/env File operations, path manipulation, environment variables
Text std/string, std/url Split, join, trim, replace; URL encode/decode/parse
Redis / KV std/db/redis, std/kv Native Redis client; simple key-value store for lightweight persistence
Auth std/auth OAuth, JWT, session management
Utilities std/time, std/math, std/crypto Timestamps, formatting; trig, log, exp; SHA256, AES-256-GCM, Argon2, UUID
Concurrency std/concurrent Go-style channels: send, recv, try_recv

CLI Commands

ntnt run file.tnt Run a program
ntnt repl Interactive REPL
ntnt lint file.tnt Check for errors and warnings
ntnt lint --warn-untyped file.tnt Warn on untyped values
ntnt lint --strict file.tnt Strict mode: all values must be typed
ntnt validate file.tnt Validate with JSON output
ntnt inspect file.tnt Project structure as JSON
ntnt test file.tnt --get /path Test HTTP endpoints
ntnt intent check file.tnt Verify code matches intent
ntnt intent coverage file.tnt Show feature coverage
ntnt intent init file.intent Generate scaffolding from intent
ntnt intent studio file.intent Launch visual studio with live tests

Type Safety Modes

NTNT has two independent type control axes, both configurable via environment variables. Start untyped and add constraints incrementally as your codebase matures.

NTNT_LINT_MODE default / warn / strict Controls lint strictness. Strict mode errors on untyped values.
NTNT_TYPE_MODE forgiving / warn / strict Controls runtime type behavior. Forgiving returns None on type mismatch; strict raises errors.
# Gradual adoption: start forgiving, add types over time
NTNT_LINT_MODE=warn NTNT_TYPE_MODE=forgiving ntnt run app.tnt

# Fully strict: all values typed, runtime enforces types
NTNT_LINT_MODE=strict NTNT_TYPE_MODE=strict ntnt run app.tnt

# Lint-only checks (no runtime)
ntnt lint --warn-untyped app.tnt
ntnt lint --strict app.tnt

Structured error messages include file, line number, expected type, actual type, and a fix hint.

Editor Support

Install the VS Code extension for syntax highlighting:

cp -r ntnt-src/editors/vscode/intent-lang ~/.vscode/extensions/

Then restart VS Code. The extension provides syntax highlighting, code snippets, and bracket matching for .tnt files.

Examples

After installation, explore the example programs:

ls ntnt-src/examples/

Includes HTTP servers, database examples, JSON/CSV processing, and more.

Documentation