Escribe codigo en portugues. Ejecuta en tu navegador.
Instala via npm — la forma mas facil de empezar.
Requiere Node.js. Funciona en Windows, Linux y macOS.
npm install -g xanascript xs run app.xs
Syntax highlight, snippets, LSP integrado. Mira en GitHub.
git clone https://github.com/xanascr/xs-vscode.git cd xs-vscode npm install -g vsce vsce package code --install-extension xanascript-*.vsix
Codigos de ejemplo en xs-examples.
git clone https://github.com/xanascr/xs-examples.git cd xs-examples xs run hello.xs xs run server.xs
xs run app.xsEjecutarxs check app.xsVerificarxs build app.xsBuild JSxs build --optJS optimizadoxs build --wasmWebAssemblyxs build --standaloneJS unico + runtimexs test .Ejecutar testsxs dev app.xsHot reloadxs replInteractivoxs lspLanguage Serverxs fmt app.xsFormatearxs docs src/ docs/Docs HTMLxs init mi-appNuevo proyectoxs install paqueteInstalar paquetexs publishPublicarxs benchBenchmarkCada keyword es portugues claro. El codigo se explica solo.
CRIA x = 10 // mutable CRIA nombre: TEXTO = "Juan" // type hint CRIA activo: BOOLEANO = VERDADEIRO x += 5 // += -= *= /= %=
| Tipo | Ejemplo |
|---|---|
NUMERO | 42, 3.14 |
TEXTO | "hola" |
BOOLEANO | VERDADEIRO/FALSO |
NULO | NULO |
[ ] | [1, 2, 3] |
{ } | { nombre: "Juan" } |
CHAMA ESSE CARA suma(a, b) { VOLTA a + b } CRIA cuadrado = (x) => x * x CRIA fetch = ASSINCRONO (url) => { VOLTA AGORA VAI(url) } CRIA r = suma(3, 4) // r = 7
CHAMA ESSE CARA declara funciones. VOLTA retorna. Arrow functions con =>. ASSINCRONO para async.
EXPORTA hace disponible la funcion para otros modulos via IMPORTA.
SE LIGA SO (edad >= 18) { SOLTA O GRITO("Adulto") } SENAO SE LIGA SO (edad >= 12) { SOLTA O GRITO("Adolescente") } SENAO { SOLTA O GRITO("Nino") } REPETE NA MORAL (CRIA i = 0; i < 5; i++) { SOLTA O GRITO(i) } REPETE AI (condicion) { ... } VOA() // break CONTINUA() // continue
SE LIGA SO / SENAO SE LIGA SO / SENAO para condicionales.
REPETE NA MORAL = for. REPETE AI = while.
VOA() = break. CONTINUA() = continue.
CLASSE Animal { CONSTRUTOR(nombre) { CRIA ISTO.nombre = nombre } METODO hablar() { SOLTA O GRITO(ISTO.nombre + " hace ruido") } } CLASSE Perro HERDA Animal { METODO hablar() { SOLTA O GRITO(ISTO.nombre + " dice: Guau!") } } CRIA rex = NOVA Perro("Rex") rex.hablar()
CLASSE, HERDA, CONSTRUTOR, METODO, ISTO (this), NOVA (new).
Herencia simple con HERDA. Metodos declarados con METODO.
ESCOLHE (dia) { CASO 1: SOLTA O GRITO("Domingo") CASO 2: CASO 3: SOLTA O GRITO("Inicio de semana") PADRAO: SOLTA O GRITO("Otro") } CRIA res = COMBINA (valor) { CASO 0 => "cero" CASO [a, b] => "array de 2" CASO { nombre } => nombre CASO _ => "otro" }
ESCOLHE/CASO/PADRAO — switch tradicional con fallthrough.
COMBINA — pattern matching estilo Rust. Desestructura arrays, objetos. _ es wildcard.
CRIA nombre = "XanaScript" SOLTA O GRITO(`Bienvenido a ${nombre}!`)
TENTA { CRIA r = PARSEIA("json") } PEGA (error) { SOLTA O GRITO("Fallo:", error) }
CRIA [a, b] = [1, 2] CRIA clone = [...lista, 6] CRIA r = persona?.direccion ?? "N/A"
// math.xs EXPORTA suma CHAMA ESSE CARA suma(a, b) { VOLTA a + b } // main.xs IMPORTA "./math.xs" SOLTA O GRITO(suma(2, 3)) IMPORTA "./math.xs" as m SOLTA O GRITO(m.suma(2, 3))
a + b a - b a * b a / b a % b a == b a != b a > b a < b a >= b a <= b a && b a || b !a a ? b : c // ternario "hello" ~= "^h.*o$" // regex x += 1 x -= 1 x *= 2
SOLTA O GRITO("log") // console.log AGORA VAI(url) // HTTP GET ESPERA AI(1000) // sleep SORTEIA(1, 10) // aleatorio PARSEIA(json) // JSON.parse TAMANHO(array) // length CRIA SERVIDOR(3000, handler) // HTTP server
Un lenguaje que no tiene miedo de ser diferente — y extremadamente capaz.
CRIA, SE LIGA SO, REPETE NA MORAL — codigo que cualquier brasileiro entiende a primera vista.
TypedArrays automaticos, integer hints, loop unrolling, constant folding. Genera JS mas rapido que codigo manual.
Compila directo a .wasm — sin Emscripten, sin wabt.js. Emisor binario propio.
TABELA Usuario { nome: TEXTO } → CRUD automatico. Zero configuracion, zero dependencias.
MACRO quadrado(x) { x * x } — expandido en tiempo de compilacion. Zero costo en runtime.
TESTE "desc" { AFIRMA(x == 5) }. Descubrimiento automatico, output colorido, exit code para CI.
Autocomplete, errores en tiempo real, hover, go-to-definition. VS Code, Neovim, cualquier editor LSP.
xs install, xs publish. Paquetes via GitHub con fallback a npm.
Errores con codigo fuente destacado, flecha apuntando al lugar exacto, hint y help con sugerencias.
Syntax highlight, 18 snippets, LSP integrado, comandos Run (Ctrl+Alt+X), Build, Test, Format.
REPL, formateador, watcher con hot reload, bytecode VM, benchmark, docs generator. 20+ comandos.
TAREFA build { } en tarefas.xs. Ejecuta con xs build. Sin Makefile.
XanaScript es el unico lenguaje que compila directo a .wasm sin dependencias externas.
CHAMA ESSE CARA suma(a, b) { VOLTA a + b } CHAMA ESSE CARA main() { VOLTA suma(10, 20) }
El modulo src/wasm_binary.js contiene un emisor Wasm binario propio que:
Zero dependencias. Sin Emscripten, sin wabt.js, sin AssemblyScript.
i32Enteros 32-bit+ - * / %Aritmeticaif/elseCondicionalesloopsFor / WhilecallLlamadasDeclara una tabla, obten CRUD automatico con almacenamiento JSON local.
TABELA Producto { nombre: TEXTO, precio: NUMERO, stock: NUMERO } CRIA repo = Producto repo.crear({ nombre: "Teclado", precio: 250, stock: 10 }) repo.crear({ nombre: "Raton", precio: 120, stock: 25 }) SOLTA O GRITO(repo.listar()) // todos SOLTA O GRITO(repo.buscar(1)) // por ID CRIA caros = repo.buscarOnde({ precio: 250 }) repo.atualizar(1, { nombre: "Teclado RGB" }) repo.deletar(2)
| Tipo | Descripcion |
|---|---|
TEXTO | string |
NUMERO | number |
BOOLEANO | boolean |
DATA | string ISO |
QUALQUER | any |
.criar(datos)CREATE.listar()READ ALL.buscar(id)READ BY ID.atualizar(id, datos)UPDATE.deletar(id)DELETE.buscarOnde(filtro)FILTER.contar()COUNTCada tabla se convierte en un archivo JSON. IDs auto-incrementados con timestamps automaticos.
Codigo que genera codigo — expandido durante la compilacion, zero costo en runtime.
MACRO cuadrado(x) { x * x } MACRO cubo(x) { x * cuadrado(x) } MACRO mayor(a, b) { SE LIGA SO (a > b) { a } SENAO { b } } CRIA r1 = cuadrado(5) // -> 5*5 = 25 CRIA r2 = cubo(3) // -> 27 CRIA r3 = mayor(10, 20) // -> 20 CRIA r4 = mayor(cuadrado(4), cubo(2))
Los macros funcionan como #define en C, pero con sintaxis XanaScript:
MACROMACRO desaparecen de la ASTEl resultado es codigo literal — sin overhead de llamada, sin closure.
Framework de tests integrado — sin Jest, sin Mocha, zero dependencias.
TESTE "suma de dos numeros" { CRIA r = 2 + 3 AFIRMA(r == 5) ASSUNTO(r, 5) } TESTE "multiplicacion" { CRIA r = 3 * 4 ASSUNTO(r, 12) }
Archivos con test en el nombre se detectan recursivamente. AFIRMA para assert truthy, ASSUNTO para equal.
Output colorido con paso/fallo, tiempo de ejecucion, exit code 1 en fallo (CI/CD ready).
PASS suma de dos numeros PASS multiplicacion FAIL division por cero 2 pasaron 1 fallo 0.01s
Autocomplete, errores en tiempo real, hover y go-to-definition para cualquier editor compatible.
Inicia el servidor con xs lsp y conecta tu editor. Comunicacion via stdin/stdout usando JSON-RPC.
xs lsp
vim.api.nvim_create_autocmd("FileType", { pattern = "xs", callback = function() vim.lsp.start({ name = "xanascript", cmd = { "xs", "lsp" }, }) end, })
La extension vscode-xs/ ya integra LSP automaticamente al abrir un archivo .xs.
Ctrl+Alt+XRunCtrl+Alt+BBuildCtrl+Shift+FFormatCodigo fuente destacado, flecha apuntando al lugar exacto, hint y help con sugerencias.
CRIA x = 10 CRIA y = z // z no fue definido
ERROR: Variable `z` no fue definida
Code: E002
--> input.xs:2:11
1 | CRIA x = 10
> 2 | CRIA y = z
| ^
Hint: Olvidaste declarar "z" con CRIA?
Help: Agrega `CRIA z = valor` antes de usar
| Codigo | Significado |
|---|---|
E001 | Token inesperado |
E002 | Variable no definida |
E003 | No es una funcion |
E004 | Tipo incompatible |
E005 | Sintaxis invalida |
E100 | Fallo HTTP |
E999 | Error interno |
Un lenguaje que entrega lo que JS/TS prometen — y mucho mas.
| Caracteristica | XanaScript | JavaScript | TypeScript |
|---|---|---|---|
| Sintaxis en PT-BR | Si | No | No |
| Compilacion Wasm directa | Si | Emscripten | AssemblyScript |
| ORM incorporado | Si | No | No |
| Macros compile-time | Si | No | No |
| Pattern Matching | Si | No | No |
| Loop Unrolling | Si | No | No |
| TypedArrays automaticos | Si | No | No |
| Integer Math Hints | Si | No | No |
| Constant Folding | Si | No | No |
| Errores estilo Rust | Si | No | No |
| LSP | Si | No | Si |
| Test Runner nativo | Si | No | No |
| Task Runner nativo | Si | No | No |
| Classes/OOP | Si | Si | Si |
| Template Strings | Si | Si | Si |
| CLI Completa | 20+ cmd | Node.js | tsc |
| Hot Reload | Si | nodemon | ts-node |
| Standalone Binary | Si | pkg/bun | pkg/bun |
| Bytecode VM | Si | No | No |
| Built-ins nativas | Si | No | No |
Como el codigo en portugues se convierte en ejecutable de alta performance.
Lo que ya implementamos y lo que esta por venir.