nuxScript v4
Linguagem de programação tipada, expression-oriented, com funcionalidades exclusivas
Quick Start
npm i -g nuxscript-lib
# hello.nux
print("Hello, nuxScript!")
nux run hello.nux
⭐ Features v4
🔌 Trait System
Interfaces com dispatch dinâmico
trait Show
fn to_string(self) -> String
end
impl Show for Point
fn to_string(self) -> String
"Point({self.x}, {self.y})"
end
end
📦 Module System
Import seletivo com use/from
use std::json
use { read, write } from "fs"
🔗 FFI (Extern)
Chamar JS nativamente
extern js readFileSync(path) -> String
let data = readFileSync("file.txt")
🧵 Fibers
Multitarefa cooperativa
let gen = fiber {
yield 1; yield 2; yield 3
}
match resume(gen) {
{status: "running", value: v} -> v
}
✅ Exhaustiveness
Verificação de match completo
match color
Red -> "red"
Green -> "green"
# warning: missing Blue
end
📦 Package Registry
15 pacotes std no GitHub
nux pkg install std::json
nux pkg install std::http
nux pkg registry
🖥️ LSP
IDE support completo
nux lsp
# go-to-definition, hover,
# completions, diagnostics
🔍 Regex Engine
Regex nativo com sintaxe única
let r = r"/(\w+)@(\w+)/"
r ~/r email
📊 Query System
SQL-like queries para dados
users |> where(.age > 18)
|> order_by("name")
|> select("name")
⚡ Concurrency
Actors, Channels, CSP
let counter = actor(fn(state, msg) => ...)
send_to(counter, "inc")
🔧 Meta-programming
Macros, AST manipulation
macro_define("assert", ...)
ast_parse("let x = 1")
🏷️ Type System
Refinements, Brands, Newtypes
let positive = pos()
let valid_email = email()
Exemplos Completos
# Trait + Struct + Pipe
trait Show
fn to_string(self) -> String
end
struct User
name :: String
age :: Int
end
impl Show for User
fn to_string(self) -> String
"{self.name} ({self.age})"
end
end
let users = [
User("Alice", 30)
User("Bob", 25)
User("Charlie", 35)
]
let result = users
|> filter(fn(u) => u.age > 25)
|> map(fn(u) => u.to_string())
|> join(", ")
print("Active: {result}")