Skip to main content

Nexa — The AI-Native Programming Language. Modern, expressive, with built-in model/train/predict keywords.

Project description

Nexa v27

⚡ Nexa Programming Language

Modern · AI-Native · Expressive · Safe

The language where AI is a first-class citizen.
Blending the clarity of Python, the safety of Rust, and built-in AI primitives — in one clean syntax.

Build Version License Python Discord Stars


import "agent"

// Build an AI chatbot in 10 lines 🤖
let bot = agent.create("groq", model="llama-3.3-70b")
var history = []

loop {
    let input = read("You: ")
    if input == "quit" { break }
    append(history, {"role": "user", "content": input})
    let reply = await bot.chat(history)
    print(f"Bot: {reply}")
}

👆 That's it. An AI chatbot with memory. In Nexa.

📖 Documentation · 🚀 Quick Start · 💬 Community · 🗺️ Roadmap


✨ Why Nexa?

Feature Python Rust Go Nexa
Easy syntax
Type safety ⚠️
AI keywords built-in
Pattern matching ⚠️
Async/await
REPL
Built-in test framework
Pipe operators
Package manager

🚀 Quick Start

Install

pip install nexa-lang

Run your first Nexa program

echo 'print("Hello, Nexa!")' > hello.nexa
nexa run hello.nexa

Or use the REPL

nexa repl

🌟 Core Features

🔒 Immutable by Default

let name = "Nexa"   // immutable — safe
var count = 0       // explicit mutability
count += 1

🤖 AI as a First-Class Citizen

// Train an ML model with language-level keywords
model Classifier {
    layer Dense(128, activation="relu")
    layer Dense(64,  activation="relu")
    layer Dense(10,  activation="softmax")
}

let clf = new Classifier()
train clf on training_data {
    epochs    = 10
    optimizer = "adam"
    loss      = "crossentropy"
}

let output = predict clf(input_features)

🔀 Pipe Operators

// Chain transformations elegantly
let result = [1, 2, 3, 4, 5]
    |> map(fn(x) => x * 2)
    |> filter(fn(x) => x > 4)
    |> sum()
// result = 24

🎯 Pattern Matching

match response {
    case {"ok": true,  "data": d} { process(d) }
    case {"ok": false, "error": e} { log_error(e) }
    default { print("unexpected response") }
}

⚡ Async / Concurrent

async def fetch_all(urls) {
    for url in urls {
        spawn fetch(url)   // concurrent tasks
    }
}

🧪 Built-in Testing

test "addition works" {
    assert 2 + 2 == 4
}

bench "list append x1000" {
    var l = []
    for i in 0..1000 { append(l, i) }
}

Run with:

nexa test myfile.nexa
nexa bench myfile.nexa

🌐 Generics (Templates)

template Stack<T> {
    var items: List = []
    def push(item: T)  { append(items, item) }
    def pop()  -> T    { return items[len(items)-1] }
    def size() -> Int  { return len(items) }
}

let s = new Stack<Int>()
s.push(42)
s.pop()   // 42

📦 Package Manager

# Install a package
nexa pkg install nexa_http

# Search packages
nexa pkg search ai

# Publish your package
nexa pkg publish

🛠️ CLI Reference

Command Description
nexa run file.nexa Execute a Nexa script
nexa repl Start the interactive REPL
nexa test file.nexa Run all tests
nexa check file.nexa Static type checking
nexa fmt file.nexa Format code
nexa bench file.nexa Run benchmarks
nexa doc file.nexa Generate documentation
nexa pkg install <pkg> Install a package
nexa pkg publish Publish a package

📚 Documentation

Resource Description
📖 The Nexa Book Complete language reference (Ch 1–20)
⚡ Nexa by Example Quick copy-paste examples
🤖 AI Tutorial Build AI apps with Nexa
🌐 Web Tutorial REST APIs and web servers
🔐 Security Guide Nexa for cybersecurity

🏗️ Real-World Examples

🌐 REST API Server
import "http"

def handle_hello(req) {
    return {"message": f"Hello, {req.params.name}!"}
}

let app = http.server()
app.get("/hello/:name", handle_hello)
app.listen(8080)
print("Server running on http://localhost:8080")
🤖 AI Agent with Memory
import "agent"

let bot = agent.create("groq", model="llama-3.3-70b")
var history = []

loop {
    let user_input = read("You: ")
    if user_input == "quit" { break }

    append(history, {"role": "user", "content": user_input})
    let reply = await bot.chat(history)
    print(f"Bot: {reply}")
    append(history, {"role": "assistant", "content": reply})
}
🧠 ML Classifier
// AutoML — Nexa picks the best model automatically
automl target=labels from features {
    task       = "classification"
    time_limit = 60
}

🗺️ Roadmap

  • Lexer, Parser, Interpreter (v1–v14)
  • Type checker (nexa check)
  • Async/await, concurrency (spawn)
  • Generics / Templates, Structs, Enums, Newtypes
  • Package manager + registry
  • LSP server (VSCode extension)
  • AI keywords (model, train, predict, automl)
  • WASM bridge
  • LLVM native compilation
  • Nexa Playground (browser IDE)
  • awesome-nexa community list
  • Official nexa-lang.org website

🤝 Contributing

We love contributions! See CONTRIBUTING.md to get started.

# Clone and set up
git clone https://github.com/nexa-lang/nexa.git
cd nexa
pip install -e .

# Run the test suite
python -m pytest tests/

# Try a Nexa file
nexa run examples/hello.nexa

Good first issues are tagged good first issue.


🌍 Community


📄 License

Nexa is open-source under the MIT License.


Built with ❤️ for the future of programming.

If Nexa helps you, give it a ⭐ — it helps the project grow!

Star History

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexa_lang-27.0.1.tar.gz (403.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexa_lang-27.0.1-py3-none-any.whl (467.3 kB view details)

Uploaded Python 3

File details

Details for the file nexa_lang-27.0.1.tar.gz.

File metadata

  • Download URL: nexa_lang-27.0.1.tar.gz
  • Upload date:
  • Size: 403.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for nexa_lang-27.0.1.tar.gz
Algorithm Hash digest
SHA256 5b48563ef8a8f6e2ab03e13ccec7cb9a03ad0c895d7bc552bad72bcfec7422fd
MD5 21a21d9315ce1e9e14341828d5a2bc5c
BLAKE2b-256 4159006e95aa5b207db3bfccb7c93b0ca7eb2c9dba424b2594ece1a0b1c96e31

See more details on using hashes here.

File details

Details for the file nexa_lang-27.0.1-py3-none-any.whl.

File metadata

  • Download URL: nexa_lang-27.0.1-py3-none-any.whl
  • Upload date:
  • Size: 467.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for nexa_lang-27.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e6db3782dc2b1e93b5ee919471f4436aa4c2b7e6519281447828b92a55633af1
MD5 bab0698d2666971950b6d03550e6033b
BLAKE2b-256 e126de7abc465fd8ea9ba6d0f2d9e8c7f8699ca8d359095ed8ec20959e7ec7bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page