Nexa — The AI-Native Programming Language. Modern, expressive, with built-in model/train/predict keywords.
Project description
⚡ 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.
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.
✨ 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-nexacommunity 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
- 💬 Discord: discord.gg/fYWWpnkjgn
- 📣 Reddit: r/nexalang
- 🐦 Twitter: @nexalang
📄 License
Nexa is open-source under the MIT License.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11c3987c9e878fae9b7f2d0f3dff37ce5409fb4c17d02b63cb8b731b09a24d29
|
|
| MD5 |
69dc25a87da9137892a91670191951e6
|
|
| BLAKE2b-256 |
14bdd4633be4496e7c857f7bc6f543a086f71fba3b4319c0c4efddc23eeb46e2
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c012208c86fe9d24da95110fa786f83f4af3dac02bead5167613ff962db9796
|
|
| MD5 |
6643345fc629280220dbadea5f87008a
|
|
| BLAKE2b-256 |
67d18b92c7980327ebdb24ff6fd2dc44a11166372cf5b711bf4a54563628f3e0
|