nexa-lang 27.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nexa_lang-27.0.0/LICENSE +21 -0
- nexa_lang-27.0.0/PKG-INFO +388 -0
- nexa_lang-27.0.0/README.md +336 -0
- nexa_lang-27.0.0/pyproject.toml +52 -0
- nexa_lang-27.0.0/setup.cfg +4 -0
nexa_lang-27.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yuvaraj
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nexa-lang
|
|
3
|
+
Version: 27.0.0
|
|
4
|
+
Summary: Nexa — The AI-Native Programming Language. Modern, expressive, with built-in model/train/predict keywords.
|
|
5
|
+
Author-email: Yuvaraj <yuvaraj030@github.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Yuvaraj
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/yuvaraj030/nexa-lang
|
|
29
|
+
Project-URL: Repository, https://github.com/yuvaraj030/nexa-lang
|
|
30
|
+
Project-URL: Documentation, https://github.com/yuvaraj030/nexa-lang#readme
|
|
31
|
+
Project-URL: Bug Tracker, https://github.com/yuvaraj030/nexa-lang/issues
|
|
32
|
+
Keywords: programming-language,ai,interpreter,nexa,compiler
|
|
33
|
+
Classifier: Development Status :: 4 - Beta
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: Intended Audience :: Education
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
42
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
43
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
44
|
+
Classifier: Environment :: Console
|
|
45
|
+
Requires-Python: >=3.10
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
License-File: LICENSE
|
|
48
|
+
Provides-Extra: dev
|
|
49
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
50
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
<div align="center">
|
|
54
|
+
|
|
55
|
+
<h1>
|
|
56
|
+
<img src="https://img.shields.io/badge/NEXA-v27-blueviolet?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyTDIgN2wxMCA1IDEwLTV6TTIgMTdsIDEwIDUgMTAtNXYtN2wtMTAgNUwyIDEweiIvPjwvc3ZnPg==" alt="Nexa v27" />
|
|
57
|
+
</h1>
|
|
58
|
+
|
|
59
|
+
<h2>⚡ Nexa Programming Language</h2>
|
|
60
|
+
|
|
61
|
+
<p><strong>Modern · AI-Native · Expressive · Safe</strong></p>
|
|
62
|
+
|
|
63
|
+
<p>
|
|
64
|
+
<em>The language where AI is a first-class citizen.</em><br/>
|
|
65
|
+
Blending the clarity of Python, the safety of Rust, and built-in AI primitives — in one clean syntax.
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
[](https://github.com/nexa-lang/nexa)
|
|
69
|
+
[](https://github.com/nexa-lang/nexa/releases)
|
|
70
|
+
[](LICENSE.md)
|
|
71
|
+
[](https://python.org)
|
|
72
|
+
[](https://discord.gg/nexa-lang)
|
|
73
|
+
[](https://github.com/nexa-lang/nexa/stargazers)
|
|
74
|
+
|
|
75
|
+
<br/>
|
|
76
|
+
|
|
77
|
+
```nexa
|
|
78
|
+
import "agent"
|
|
79
|
+
|
|
80
|
+
// Build an AI chatbot in 10 lines 🤖
|
|
81
|
+
let bot = agent.create("groq", model="llama-3.3-70b")
|
|
82
|
+
var history = []
|
|
83
|
+
|
|
84
|
+
loop {
|
|
85
|
+
let input = read("You: ")
|
|
86
|
+
if input == "quit" { break }
|
|
87
|
+
append(history, {"role": "user", "content": input})
|
|
88
|
+
let reply = await bot.chat(history)
|
|
89
|
+
print(f"Bot: {reply}")
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**👆 That's it. An AI chatbot with memory. In Nexa.**
|
|
94
|
+
|
|
95
|
+
[📖 Documentation](#documentation) · [🚀 Quick Start](#quick-start) · [💬 Community](https://discord.gg/nexa-lang) · [🗺️ Roadmap](ROADMAP.md)
|
|
96
|
+
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## ✨ Why Nexa?
|
|
102
|
+
|
|
103
|
+
| Feature | Python | Rust | Go | **Nexa** |
|
|
104
|
+
|---------|--------|------|----|----------|
|
|
105
|
+
| Easy syntax | ✅ | ❌ | ✅ | ✅ |
|
|
106
|
+
| Type safety | ⚠️ | ✅ | ✅ | ✅ |
|
|
107
|
+
| AI keywords built-in | ❌ | ❌ | ❌ | **✅** |
|
|
108
|
+
| Pattern matching | ⚠️ | ✅ | ❌ | **✅** |
|
|
109
|
+
| Async/await | ✅ | ✅ | ✅ | **✅** |
|
|
110
|
+
| REPL | ✅ | ❌ | ❌ | **✅** |
|
|
111
|
+
| Built-in test framework | ❌ | ✅ | ✅ | **✅** |
|
|
112
|
+
| Pipe operators | ❌ | ❌ | ❌ | **✅** |
|
|
113
|
+
| Package manager | ✅ | ✅ | ✅ | **✅** |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## 🚀 Quick Start
|
|
118
|
+
|
|
119
|
+
### Install
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pip install nexa-lang
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Run your first Nexa program
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
echo 'print("Hello, Nexa!")' > hello.nexa
|
|
129
|
+
nexa run hello.nexa
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Or use the REPL
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
nexa repl
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 🌟 Core Features
|
|
141
|
+
|
|
142
|
+
### 🔒 Immutable by Default
|
|
143
|
+
```nexa
|
|
144
|
+
let name = "Nexa" // immutable — safe
|
|
145
|
+
var count = 0 // explicit mutability
|
|
146
|
+
count += 1
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 🤖 AI as a First-Class Citizen
|
|
150
|
+
```nexa
|
|
151
|
+
// Train an ML model with language-level keywords
|
|
152
|
+
model Classifier {
|
|
153
|
+
layer Dense(128, activation="relu")
|
|
154
|
+
layer Dense(64, activation="relu")
|
|
155
|
+
layer Dense(10, activation="softmax")
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let clf = new Classifier()
|
|
159
|
+
train clf on training_data {
|
|
160
|
+
epochs = 10
|
|
161
|
+
optimizer = "adam"
|
|
162
|
+
loss = "crossentropy"
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let output = predict clf(input_features)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 🔀 Pipe Operators
|
|
169
|
+
```nexa
|
|
170
|
+
// Chain transformations elegantly
|
|
171
|
+
let result = [1, 2, 3, 4, 5]
|
|
172
|
+
|> map(fn(x) => x * 2)
|
|
173
|
+
|> filter(fn(x) => x > 4)
|
|
174
|
+
|> sum()
|
|
175
|
+
// result = 24
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 🎯 Pattern Matching
|
|
179
|
+
```nexa
|
|
180
|
+
match response {
|
|
181
|
+
case {"ok": true, "data": d} { process(d) }
|
|
182
|
+
case {"ok": false, "error": e} { log_error(e) }
|
|
183
|
+
default { print("unexpected response") }
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### ⚡ Async / Concurrent
|
|
188
|
+
```nexa
|
|
189
|
+
async def fetch_all(urls) {
|
|
190
|
+
for url in urls {
|
|
191
|
+
spawn fetch(url) // concurrent tasks
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 🧪 Built-in Testing
|
|
197
|
+
```nexa
|
|
198
|
+
test "addition works" {
|
|
199
|
+
assert 2 + 2 == 4
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
bench "list append x1000" {
|
|
203
|
+
var l = []
|
|
204
|
+
for i in 0..1000 { append(l, i) }
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Run with:
|
|
209
|
+
```bash
|
|
210
|
+
nexa test myfile.nexa
|
|
211
|
+
nexa bench myfile.nexa
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 🌐 Generics (Templates)
|
|
215
|
+
```nexa
|
|
216
|
+
template Stack<T> {
|
|
217
|
+
var items: List = []
|
|
218
|
+
def push(item: T) { append(items, item) }
|
|
219
|
+
def pop() -> T { return items[len(items)-1] }
|
|
220
|
+
def size() -> Int { return len(items) }
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let s = new Stack<Int>()
|
|
224
|
+
s.push(42)
|
|
225
|
+
s.pop() // 42
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 📦 Package Manager
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Install a package
|
|
234
|
+
nexa pkg install nexa_http
|
|
235
|
+
|
|
236
|
+
# Search packages
|
|
237
|
+
nexa pkg search ai
|
|
238
|
+
|
|
239
|
+
# Publish your package
|
|
240
|
+
nexa pkg publish
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 🛠️ CLI Reference
|
|
246
|
+
|
|
247
|
+
| Command | Description |
|
|
248
|
+
|---------|-------------|
|
|
249
|
+
| `nexa run file.nexa` | Execute a Nexa script |
|
|
250
|
+
| `nexa repl` | Start the interactive REPL |
|
|
251
|
+
| `nexa test file.nexa` | Run all tests |
|
|
252
|
+
| `nexa check file.nexa` | Static type checking |
|
|
253
|
+
| `nexa fmt file.nexa` | Format code |
|
|
254
|
+
| `nexa bench file.nexa` | Run benchmarks |
|
|
255
|
+
| `nexa doc file.nexa` | Generate documentation |
|
|
256
|
+
| `nexa pkg install <pkg>` | Install a package |
|
|
257
|
+
| `nexa pkg publish` | Publish a package |
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 📚 Documentation
|
|
262
|
+
|
|
263
|
+
| Resource | Description |
|
|
264
|
+
|----------|-------------|
|
|
265
|
+
| [📖 The Nexa Book](docs/) | Complete language reference (Ch 1–20) |
|
|
266
|
+
| [⚡ Nexa by Example](examples/) | Quick copy-paste examples |
|
|
267
|
+
| [🤖 AI Tutorial](docs/ai-tutorial.md) | Build AI apps with Nexa |
|
|
268
|
+
| [🌐 Web Tutorial](docs/web-tutorial.md) | REST APIs and web servers |
|
|
269
|
+
| [🔐 Security Guide](docs/security.md) | Nexa for cybersecurity |
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## 🏗️ Real-World Examples
|
|
274
|
+
|
|
275
|
+
<details>
|
|
276
|
+
<summary>🌐 <strong>REST API Server</strong></summary>
|
|
277
|
+
|
|
278
|
+
```nexa
|
|
279
|
+
import "http"
|
|
280
|
+
|
|
281
|
+
def handle_hello(req) {
|
|
282
|
+
return {"message": f"Hello, {req.params.name}!"}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
let app = http.server()
|
|
286
|
+
app.get("/hello/:name", handle_hello)
|
|
287
|
+
app.listen(8080)
|
|
288
|
+
print("Server running on http://localhost:8080")
|
|
289
|
+
```
|
|
290
|
+
</details>
|
|
291
|
+
|
|
292
|
+
<details>
|
|
293
|
+
<summary>🤖 <strong>AI Agent with Memory</strong></summary>
|
|
294
|
+
|
|
295
|
+
```nexa
|
|
296
|
+
import "agent"
|
|
297
|
+
|
|
298
|
+
let bot = agent.create("groq", model="llama-3.3-70b")
|
|
299
|
+
var history = []
|
|
300
|
+
|
|
301
|
+
loop {
|
|
302
|
+
let user_input = read("You: ")
|
|
303
|
+
if user_input == "quit" { break }
|
|
304
|
+
|
|
305
|
+
append(history, {"role": "user", "content": user_input})
|
|
306
|
+
let reply = await bot.chat(history)
|
|
307
|
+
print(f"Bot: {reply}")
|
|
308
|
+
append(history, {"role": "assistant", "content": reply})
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
</details>
|
|
312
|
+
|
|
313
|
+
<details>
|
|
314
|
+
<summary>🧠 <strong>ML Classifier</strong></summary>
|
|
315
|
+
|
|
316
|
+
```nexa
|
|
317
|
+
// AutoML — Nexa picks the best model automatically
|
|
318
|
+
automl target=labels from features {
|
|
319
|
+
task = "classification"
|
|
320
|
+
time_limit = 60
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
</details>
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## 🗺️ Roadmap
|
|
328
|
+
|
|
329
|
+
- [x] Lexer, Parser, Interpreter (v1–v14)
|
|
330
|
+
- [x] Type checker (`nexa check`)
|
|
331
|
+
- [x] Async/await, concurrency (`spawn`)
|
|
332
|
+
- [x] Generics / Templates, Structs, Enums, Newtypes
|
|
333
|
+
- [x] Package manager + registry
|
|
334
|
+
- [x] LSP server (VSCode extension)
|
|
335
|
+
- [x] AI keywords (`model`, `train`, `predict`, `automl`)
|
|
336
|
+
- [x] WASM bridge
|
|
337
|
+
- [ ] LLVM native compilation
|
|
338
|
+
- [ ] Nexa Playground (browser IDE)
|
|
339
|
+
- [ ] `awesome-nexa` community list
|
|
340
|
+
- [ ] Official nexa-lang.org website
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## 🤝 Contributing
|
|
345
|
+
|
|
346
|
+
We love contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) to get started.
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
# Clone and set up
|
|
350
|
+
git clone https://github.com/nexa-lang/nexa.git
|
|
351
|
+
cd nexa
|
|
352
|
+
pip install -e .
|
|
353
|
+
|
|
354
|
+
# Run the test suite
|
|
355
|
+
python -m pytest tests/
|
|
356
|
+
|
|
357
|
+
# Try a Nexa file
|
|
358
|
+
nexa run examples/hello.nexa
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Good first issues are tagged [`good first issue`](https://github.com/nexa-lang/nexa/issues?q=is%3Aissue+label%3A%22good+first+issue%22).
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## 🌍 Community
|
|
366
|
+
|
|
367
|
+
- 💬 **Discord**: [discord.gg/nexa-lang](https://discord.gg/nexa-lang)
|
|
368
|
+
- 📣 **Reddit**: [r/nexalang](https://reddit.com/r/nexalang)
|
|
369
|
+
- 🐦 **Twitter**: [@nexalang](https://twitter.com/nexalang)
|
|
370
|
+
- 🌐 **Website**: [nexa-lang.org](https://nexa-lang.org)
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## 📄 License
|
|
375
|
+
|
|
376
|
+
Nexa is open-source under the [MIT License](LICENSE.md).
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
<div align="center">
|
|
381
|
+
|
|
382
|
+
**Built with ❤️ for the future of programming.**
|
|
383
|
+
|
|
384
|
+
*If Nexa helps you, give it a ⭐ — it helps the project grow!*
|
|
385
|
+
|
|
386
|
+
[](https://github.com/nexa-lang/nexa)
|
|
387
|
+
|
|
388
|
+
</div>
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<h1>
|
|
4
|
+
<img src="https://img.shields.io/badge/NEXA-v27-blueviolet?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0xMiAyTDIgN2wxMCA1IDEwLTV6TTIgMTdsIDEwIDUgMTAtNXYtN2wtMTAgNUwyIDEweiIvPjwvc3ZnPg==" alt="Nexa v27" />
|
|
5
|
+
</h1>
|
|
6
|
+
|
|
7
|
+
<h2>⚡ Nexa Programming Language</h2>
|
|
8
|
+
|
|
9
|
+
<p><strong>Modern · AI-Native · Expressive · Safe</strong></p>
|
|
10
|
+
|
|
11
|
+
<p>
|
|
12
|
+
<em>The language where AI is a first-class citizen.</em><br/>
|
|
13
|
+
Blending the clarity of Python, the safety of Rust, and built-in AI primitives — in one clean syntax.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
[](https://github.com/nexa-lang/nexa)
|
|
17
|
+
[](https://github.com/nexa-lang/nexa/releases)
|
|
18
|
+
[](LICENSE.md)
|
|
19
|
+
[](https://python.org)
|
|
20
|
+
[](https://discord.gg/nexa-lang)
|
|
21
|
+
[](https://github.com/nexa-lang/nexa/stargazers)
|
|
22
|
+
|
|
23
|
+
<br/>
|
|
24
|
+
|
|
25
|
+
```nexa
|
|
26
|
+
import "agent"
|
|
27
|
+
|
|
28
|
+
// Build an AI chatbot in 10 lines 🤖
|
|
29
|
+
let bot = agent.create("groq", model="llama-3.3-70b")
|
|
30
|
+
var history = []
|
|
31
|
+
|
|
32
|
+
loop {
|
|
33
|
+
let input = read("You: ")
|
|
34
|
+
if input == "quit" { break }
|
|
35
|
+
append(history, {"role": "user", "content": input})
|
|
36
|
+
let reply = await bot.chat(history)
|
|
37
|
+
print(f"Bot: {reply}")
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**👆 That's it. An AI chatbot with memory. In Nexa.**
|
|
42
|
+
|
|
43
|
+
[📖 Documentation](#documentation) · [🚀 Quick Start](#quick-start) · [💬 Community](https://discord.gg/nexa-lang) · [🗺️ Roadmap](ROADMAP.md)
|
|
44
|
+
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## ✨ Why Nexa?
|
|
50
|
+
|
|
51
|
+
| Feature | Python | Rust | Go | **Nexa** |
|
|
52
|
+
|---------|--------|------|----|----------|
|
|
53
|
+
| Easy syntax | ✅ | ❌ | ✅ | ✅ |
|
|
54
|
+
| Type safety | ⚠️ | ✅ | ✅ | ✅ |
|
|
55
|
+
| AI keywords built-in | ❌ | ❌ | ❌ | **✅** |
|
|
56
|
+
| Pattern matching | ⚠️ | ✅ | ❌ | **✅** |
|
|
57
|
+
| Async/await | ✅ | ✅ | ✅ | **✅** |
|
|
58
|
+
| REPL | ✅ | ❌ | ❌ | **✅** |
|
|
59
|
+
| Built-in test framework | ❌ | ✅ | ✅ | **✅** |
|
|
60
|
+
| Pipe operators | ❌ | ❌ | ❌ | **✅** |
|
|
61
|
+
| Package manager | ✅ | ✅ | ✅ | **✅** |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 🚀 Quick Start
|
|
66
|
+
|
|
67
|
+
### Install
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install nexa-lang
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Run your first Nexa program
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
echo 'print("Hello, Nexa!")' > hello.nexa
|
|
77
|
+
nexa run hello.nexa
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Or use the REPL
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
nexa repl
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## 🌟 Core Features
|
|
89
|
+
|
|
90
|
+
### 🔒 Immutable by Default
|
|
91
|
+
```nexa
|
|
92
|
+
let name = "Nexa" // immutable — safe
|
|
93
|
+
var count = 0 // explicit mutability
|
|
94
|
+
count += 1
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 🤖 AI as a First-Class Citizen
|
|
98
|
+
```nexa
|
|
99
|
+
// Train an ML model with language-level keywords
|
|
100
|
+
model Classifier {
|
|
101
|
+
layer Dense(128, activation="relu")
|
|
102
|
+
layer Dense(64, activation="relu")
|
|
103
|
+
layer Dense(10, activation="softmax")
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let clf = new Classifier()
|
|
107
|
+
train clf on training_data {
|
|
108
|
+
epochs = 10
|
|
109
|
+
optimizer = "adam"
|
|
110
|
+
loss = "crossentropy"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let output = predict clf(input_features)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 🔀 Pipe Operators
|
|
117
|
+
```nexa
|
|
118
|
+
// Chain transformations elegantly
|
|
119
|
+
let result = [1, 2, 3, 4, 5]
|
|
120
|
+
|> map(fn(x) => x * 2)
|
|
121
|
+
|> filter(fn(x) => x > 4)
|
|
122
|
+
|> sum()
|
|
123
|
+
// result = 24
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 🎯 Pattern Matching
|
|
127
|
+
```nexa
|
|
128
|
+
match response {
|
|
129
|
+
case {"ok": true, "data": d} { process(d) }
|
|
130
|
+
case {"ok": false, "error": e} { log_error(e) }
|
|
131
|
+
default { print("unexpected response") }
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### ⚡ Async / Concurrent
|
|
136
|
+
```nexa
|
|
137
|
+
async def fetch_all(urls) {
|
|
138
|
+
for url in urls {
|
|
139
|
+
spawn fetch(url) // concurrent tasks
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 🧪 Built-in Testing
|
|
145
|
+
```nexa
|
|
146
|
+
test "addition works" {
|
|
147
|
+
assert 2 + 2 == 4
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
bench "list append x1000" {
|
|
151
|
+
var l = []
|
|
152
|
+
for i in 0..1000 { append(l, i) }
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Run with:
|
|
157
|
+
```bash
|
|
158
|
+
nexa test myfile.nexa
|
|
159
|
+
nexa bench myfile.nexa
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 🌐 Generics (Templates)
|
|
163
|
+
```nexa
|
|
164
|
+
template Stack<T> {
|
|
165
|
+
var items: List = []
|
|
166
|
+
def push(item: T) { append(items, item) }
|
|
167
|
+
def pop() -> T { return items[len(items)-1] }
|
|
168
|
+
def size() -> Int { return len(items) }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
let s = new Stack<Int>()
|
|
172
|
+
s.push(42)
|
|
173
|
+
s.pop() // 42
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 📦 Package Manager
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Install a package
|
|
182
|
+
nexa pkg install nexa_http
|
|
183
|
+
|
|
184
|
+
# Search packages
|
|
185
|
+
nexa pkg search ai
|
|
186
|
+
|
|
187
|
+
# Publish your package
|
|
188
|
+
nexa pkg publish
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 🛠️ CLI Reference
|
|
194
|
+
|
|
195
|
+
| Command | Description |
|
|
196
|
+
|---------|-------------|
|
|
197
|
+
| `nexa run file.nexa` | Execute a Nexa script |
|
|
198
|
+
| `nexa repl` | Start the interactive REPL |
|
|
199
|
+
| `nexa test file.nexa` | Run all tests |
|
|
200
|
+
| `nexa check file.nexa` | Static type checking |
|
|
201
|
+
| `nexa fmt file.nexa` | Format code |
|
|
202
|
+
| `nexa bench file.nexa` | Run benchmarks |
|
|
203
|
+
| `nexa doc file.nexa` | Generate documentation |
|
|
204
|
+
| `nexa pkg install <pkg>` | Install a package |
|
|
205
|
+
| `nexa pkg publish` | Publish a package |
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 📚 Documentation
|
|
210
|
+
|
|
211
|
+
| Resource | Description |
|
|
212
|
+
|----------|-------------|
|
|
213
|
+
| [📖 The Nexa Book](docs/) | Complete language reference (Ch 1–20) |
|
|
214
|
+
| [⚡ Nexa by Example](examples/) | Quick copy-paste examples |
|
|
215
|
+
| [🤖 AI Tutorial](docs/ai-tutorial.md) | Build AI apps with Nexa |
|
|
216
|
+
| [🌐 Web Tutorial](docs/web-tutorial.md) | REST APIs and web servers |
|
|
217
|
+
| [🔐 Security Guide](docs/security.md) | Nexa for cybersecurity |
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 🏗️ Real-World Examples
|
|
222
|
+
|
|
223
|
+
<details>
|
|
224
|
+
<summary>🌐 <strong>REST API Server</strong></summary>
|
|
225
|
+
|
|
226
|
+
```nexa
|
|
227
|
+
import "http"
|
|
228
|
+
|
|
229
|
+
def handle_hello(req) {
|
|
230
|
+
return {"message": f"Hello, {req.params.name}!"}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
let app = http.server()
|
|
234
|
+
app.get("/hello/:name", handle_hello)
|
|
235
|
+
app.listen(8080)
|
|
236
|
+
print("Server running on http://localhost:8080")
|
|
237
|
+
```
|
|
238
|
+
</details>
|
|
239
|
+
|
|
240
|
+
<details>
|
|
241
|
+
<summary>🤖 <strong>AI Agent with Memory</strong></summary>
|
|
242
|
+
|
|
243
|
+
```nexa
|
|
244
|
+
import "agent"
|
|
245
|
+
|
|
246
|
+
let bot = agent.create("groq", model="llama-3.3-70b")
|
|
247
|
+
var history = []
|
|
248
|
+
|
|
249
|
+
loop {
|
|
250
|
+
let user_input = read("You: ")
|
|
251
|
+
if user_input == "quit" { break }
|
|
252
|
+
|
|
253
|
+
append(history, {"role": "user", "content": user_input})
|
|
254
|
+
let reply = await bot.chat(history)
|
|
255
|
+
print(f"Bot: {reply}")
|
|
256
|
+
append(history, {"role": "assistant", "content": reply})
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
</details>
|
|
260
|
+
|
|
261
|
+
<details>
|
|
262
|
+
<summary>🧠 <strong>ML Classifier</strong></summary>
|
|
263
|
+
|
|
264
|
+
```nexa
|
|
265
|
+
// AutoML — Nexa picks the best model automatically
|
|
266
|
+
automl target=labels from features {
|
|
267
|
+
task = "classification"
|
|
268
|
+
time_limit = 60
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
</details>
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## 🗺️ Roadmap
|
|
276
|
+
|
|
277
|
+
- [x] Lexer, Parser, Interpreter (v1–v14)
|
|
278
|
+
- [x] Type checker (`nexa check`)
|
|
279
|
+
- [x] Async/await, concurrency (`spawn`)
|
|
280
|
+
- [x] Generics / Templates, Structs, Enums, Newtypes
|
|
281
|
+
- [x] Package manager + registry
|
|
282
|
+
- [x] LSP server (VSCode extension)
|
|
283
|
+
- [x] AI keywords (`model`, `train`, `predict`, `automl`)
|
|
284
|
+
- [x] WASM bridge
|
|
285
|
+
- [ ] LLVM native compilation
|
|
286
|
+
- [ ] Nexa Playground (browser IDE)
|
|
287
|
+
- [ ] `awesome-nexa` community list
|
|
288
|
+
- [ ] Official nexa-lang.org website
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## 🤝 Contributing
|
|
293
|
+
|
|
294
|
+
We love contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) to get started.
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# Clone and set up
|
|
298
|
+
git clone https://github.com/nexa-lang/nexa.git
|
|
299
|
+
cd nexa
|
|
300
|
+
pip install -e .
|
|
301
|
+
|
|
302
|
+
# Run the test suite
|
|
303
|
+
python -m pytest tests/
|
|
304
|
+
|
|
305
|
+
# Try a Nexa file
|
|
306
|
+
nexa run examples/hello.nexa
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Good first issues are tagged [`good first issue`](https://github.com/nexa-lang/nexa/issues?q=is%3Aissue+label%3A%22good+first+issue%22).
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 🌍 Community
|
|
314
|
+
|
|
315
|
+
- 💬 **Discord**: [discord.gg/nexa-lang](https://discord.gg/nexa-lang)
|
|
316
|
+
- 📣 **Reddit**: [r/nexalang](https://reddit.com/r/nexalang)
|
|
317
|
+
- 🐦 **Twitter**: [@nexalang](https://twitter.com/nexalang)
|
|
318
|
+
- 🌐 **Website**: [nexa-lang.org](https://nexa-lang.org)
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## 📄 License
|
|
323
|
+
|
|
324
|
+
Nexa is open-source under the [MIT License](LICENSE.md).
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
<div align="center">
|
|
329
|
+
|
|
330
|
+
**Built with ❤️ for the future of programming.**
|
|
331
|
+
|
|
332
|
+
*If Nexa helps you, give it a ⭐ — it helps the project grow!*
|
|
333
|
+
|
|
334
|
+
[](https://github.com/nexa-lang/nexa)
|
|
335
|
+
|
|
336
|
+
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "nexa-lang"
|
|
7
|
+
version = "27.0.0"
|
|
8
|
+
description = "Nexa — The AI-Native Programming Language. Modern, expressive, with built-in model/train/predict keywords."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Yuvaraj", email = "yuvaraj030@github.com" }
|
|
13
|
+
]
|
|
14
|
+
keywords = ["programming-language", "ai", "interpreter", "nexa", "compiler"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Education",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development :: Interpreters",
|
|
25
|
+
"Topic :: Software Development :: Compilers",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
"Environment :: Console",
|
|
28
|
+
]
|
|
29
|
+
requires-python = ">=3.10"
|
|
30
|
+
dependencies = []
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = [
|
|
34
|
+
"pytest>=7.0",
|
|
35
|
+
"pytest-cov",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/yuvaraj030/nexa-lang"
|
|
40
|
+
Repository = "https://github.com/yuvaraj030/nexa-lang"
|
|
41
|
+
Documentation = "https://github.com/yuvaraj030/nexa-lang#readme"
|
|
42
|
+
"Bug Tracker" = "https://github.com/yuvaraj030/nexa-lang/issues"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
nexa = "nexa_lang.__main__:main"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.packages.find]
|
|
48
|
+
where = [".."]
|
|
49
|
+
include = ["nexa_lang*"]
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.package-data]
|
|
52
|
+
"nexa_lang" = ["templates/**/*.nexa", "examples/*.nexa"]
|