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.2.tar.gz (151.7 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.2-py3-none-any.whl (175.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nexa_lang-27.0.2.tar.gz
  • Upload date:
  • Size: 151.7 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.2.tar.gz
Algorithm Hash digest
SHA256 11c3987c9e878fae9b7f2d0f3dff37ce5409fb4c17d02b63cb8b731b09a24d29
MD5 69dc25a87da9137892a91670191951e6
BLAKE2b-256 14bdd4633be4496e7c857f7bc6f543a086f71fba3b4319c0c4efddc23eeb46e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nexa_lang-27.0.2-py3-none-any.whl
  • Upload date:
  • Size: 175.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c012208c86fe9d24da95110fa786f83f4af3dac02bead5167613ff962db9796
MD5 6643345fc629280220dbadea5f87008a
BLAKE2b-256 67d18b92c7980327ebdb24ff6fd2dc44a11166372cf5b711bf4a54563628f3e0

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