Write code in Portuguese. Run it instantly in your browser.
Install via npm — the easiest way to get started.
Requires Node.js. Works on Windows, Linux, and macOS.
npm install -g xanascript xs run app.xs
Syntax highlight, snippets, integrated LSP. See on GitHub.
git clone https://github.com/xanascr/xs-vscode.git cd xs-vscode npm install -g vsce vsce package code --install-extension xanascript-*.vsix
Sample code in 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.xsRunxs check app.xsCheck syntaxxs build app.xsBuild JSxs build --optOptimized JSxs build --wasmWebAssemblyxs build --standaloneSingle JS + runtimexs test .Run testsxs dev app.xsHot reloadxs replInteractivexs lspLanguage Serverxs fmt app.xsFormatxs docs src/ docs/Docs HTMLxs init my-appNew projectxs install pkgInstall packagexs publishPublishxs benchBenchmarkEvery keyword is clear Portuguese. The code explains itself.
CRIA x = 10 // mutable CRIA name: TEXTO = "John" // type hint CRIA active: BOOLEANO = VERDADEIRO x += 5 // += -= *= /= %=
| Type | Example |
|---|---|
NUMERO | 42, 3.14 |
TEXTO | "hello" |
BOOLEANO | VERDADEIRO/FALSO |
NULO | NULO |
[ ] | [1, 2, 3] |
{ } | { name: "John" } |
CHAMA ESSE CARA sum(a, b) { VOLTA a + b } CRIA square = (x) => x * x CRIA fetch = ASSINCRONO (url) => { VOLTA AGORA VAI(url) } CRIA r = sum(3, 4) // r = 7
CHAMA ESSE CARA declares functions. VOLTA returns. Arrow functions with =>. ASSINCRONO for async.
EXPORTA makes functions available to other modules via IMPORTA.
SE LIGA SO (age >= 18) { SOLTA O GRITO("Adult") } SENAO SE LIGA SO (age >= 12) { SOLTA O GRITO("Teen") } SENAO { SOLTA O GRITO("Child") } REPETE NA MORAL (CRIA i = 0; i < 5; i++) { SOLTA O GRITO(i) } REPETE AI (condition) { ... } VOA() // break CONTINUA() // continue
SE LIGA SO / SENAO SE LIGA SO / SENAO for conditionals.
REPETE NA MORAL = for. REPETE AI = while.
VOA() = break. CONTINUA() = continue.
CLASSE Animal { CONSTRUTOR(name) { CRIA ISTO.name = name } METODO speak() { SOLTA O GRITO(ISTO.name + " makes noise") } } CLASSE Dog HERDA Animal { METODO speak() { SOLTA O GRITO(ISTO.name + " says: Woof!") } } CRIA rex = NOVA Dog("Rex") rex.speak()
CLASSE, HERDA, CONSTRUTOR, METODO, ISTO (this), NOVA (new).
Simple inheritance with HERDA. Methods declared with METODO.
ESCOLHE (day) { CASO 1: SOLTA O GRITO("Sunday") CASO 2: CASO 3: SOLTA O GRITO("Week start") PADRAO: SOLTA O GRITO("Other") } CRIA res = COMBINA (value) { CASO 0 => "zero" CASO [a, b] => "array of 2" CASO { name } => name CASO _ => "other" }
ESCOLHE/CASO/PADRAO — traditional switch with fallthrough.
COMBINA — Rust-style pattern matching. Destructures arrays, objects. _ is wildcard.
CRIA name = "XanaScript" SOLTA O GRITO(`Welcome to ${name}!`)
TENTA { CRIA r = PARSEIA("json") } PEGA (err) { SOLTA O GRITO("Error:", err) }
CRIA [a, b] = [1, 2] CRIA clone = [...list, 6] CRIA r = person?.address ?? "N/A"
// math.xs EXPORTA sum CHAMA ESSE CARA sum(a, b) { VOLTA a + b } // main.xs IMPORTA "./math.xs" SOLTA O GRITO(sum(2, 3)) IMPORTA "./math.xs" as m SOLTA O GRITO(m.sum(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 // ternary "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) // random PARSEIA(json) // JSON.parse TAMANHO(array) // length CRIA SERVIDOR(3000, handler) // HTTP server
A language that is not afraid to be different — and extremely capable.
CRIA, SE LIGA SO, REPETE NA MORAL — code any Brazilian understands at first glance.
Automatic TypedArrays, integer hints, loop unrolling, constant folding. Generates JS faster than hand-written code.
Compiles directly to .wasm — no Emscripten, no wabt.js. Own binary emitter.
TABELA User { name: TEXTO } → automatic CRUD. Zero config, zero dependencies.
MACRO square(x) { x * x } — expanded at compile time. Zero runtime cost.
TESTE "desc" { AFIRMA(x == 5) }. Automatic discovery, colored output, CI-ready exit codes.
Autocomplete, real-time errors, hover, go-to-definition. VS Code, Neovim, any LSP editor.
xs install, xs publish. Packages via GitHub with npm fallback.
Errors with highlighted source code, arrow to exact location, hints and suggestions.
Syntax highlight, 18 snippets, integrated LSP, Run (Ctrl+Alt+X), Build, Test, Format.
REPL, formatter, watcher with hot reload, bytecode VM, benchmark, docs generator. 20+ commands.
TAREFA build { } in tarefas.xs. Run with xs build. No Makefile needed.
XanaScript is the only language that compiles directly to .wasm with no external dependencies.
CHAMA ESSE CARA sum(a, b) { VOLTA a + b } CHAMA ESSE CARA main() { VOLTA sum(10, 20) }
The src/wasm_binary.js module contains a proprietary Wasm binary emitter that:
Zero dependencies. No Emscripten, no wabt.js, no AssemblyScript.
i3232-bit integers+ - * / %Arithmeticif/elseConditionalsloopsFor / WhilecallFunction callsDeclare a table, get automatic CRUD with local JSON storage.
TABELA Product { name: TEXTO, price: NUMERO, stock: NUMERO } CRIA repo = Product repo.create({ name: "Keyboard", price: 250, stock: 10 }) repo.create({ name: "Mouse", price: 120, stock: 25 }) SOLTA O GRITO(repo.list()) // all SOLTA O GRITO(repo.find(1)) // by ID CRIA expensive = repo.findWhere({ price: 250 }) repo.update(1, { name: "RGB Keyboard" }) repo.delete(2)
| Type | Description |
|---|---|
TEXTO | string |
NUMERO | number |
BOOLEANO | boolean |
DATA | ISO string |
QUALQUER | any |
.create(data)CREATE.list()READ ALL.find(id)READ BY ID.update(id, data)UPDATE.delete(id)DELETE.findWhere(filter)FILTER.count()COUNTEach table becomes a JSON file. Auto-incrementing IDs with automatic timestamps.
Code that generates code — expanded during compilation, zero runtime cost.
MACRO square(x) { x * x } MACRO cube(x) { x * square(x) } MACRO max(a, b) { SE LIGA SO (a > b) { a } SENAO { b } } CRIA r1 = square(5) // -> 5*5 = 25 CRIA r2 = cube(3) // -> 27 CRIA r3 = max(10, 20) // -> 20 CRIA r4 = max(square(4), cube(2))
Macros work like C #define, but with XanaScript syntax:
MACRO declarationsMACRO declarations disappear from the ASTThe result is literal code — no call overhead, no closure.
Integrated test framework — no Jest, no Mocha, zero dependencies.
TESTE "sum of two numbers" { CRIA r = 2 + 3 AFIRMA(r == 5) ASSUNTO(r, 5) } TESTE "multiplication" { CRIA r = 3 * 4 ASSUNTO(r, 12) }
Files with test in the name are discovered recursively. AFIRMA for truthy assert, ASSUNTO for equality.
Colored output with pass/fail, execution time, exit code 1 on failure (CI/CD ready).
PASS sum of two numbers PASS multiplication FAIL division by zero 2 passed 1 failed 0.01s
Autocomplete, real-time errors, hover and go-to-definition for any compatible editor.
Start the server with xs lsp and connect your editor. Communication via stdin/stdout using JSON-RPC.
xs lsp
vim.api.nvim_create_autocmd("FileType", { pattern = "xs", callback = function() vim.lsp.start({ name = "xanascript", cmd = { "xs", "lsp" }, }) end, })
The vscode-xs/ extension already integrates LSP automatically when opening a .xs file.
Ctrl+Alt+XRunCtrl+Alt+BBuildCtrl+Shift+FFormatHighlighted source code, arrow to exact location, hint and help with fix suggestions.
CRIA x = 10 CRIA y = z // z was not defined
ERROR: Variable `z` was not defined
Code: E002
--> input.xs:2:11
1 | CRIA x = 10
> 2 | CRIA y = z
| ^
Hint: Forgot to declare "z" with CRIA?
Help: Add `CRIA z = value` before using it
| Code | Meaning |
|---|---|
E001 | Unexpected token |
E002 | Variable not defined |
E003 | Not a function |
E004 | Incompatible type |
E005 | Invalid syntax |
E100 | HTTP failure |
E999 | Internal error |
A language that delivers what JS/TS promise — and much more.
| Feature | XanaScript | JavaScript | TypeScript |
|---|---|---|---|
| PT-BR Syntax | Yes | No | No |
| Direct Wasm compilation | Yes | Emscripten | AssemblyScript |
| Built-in ORM | Yes | No | No |
| Compile-time Macros | Yes | No | No |
| Pattern Matching | Yes | No | No |
| Loop Unrolling | Yes | No | No |
| Auto TypedArrays | Yes | No | No |
| Integer Math Hints | Yes | No | No |
| Constant Folding | Yes | No | No |
| Rust-Style Errors | Yes | No | No |
| LSP | Yes | No | Yes |
| Native Test Runner | Yes | No | No |
| Native Task Runner | Yes | No | No |
| Classes/OOP | Yes | Yes | Yes |
| Template Strings | Yes | Yes | Yes |
| Complete CLI | 20+ cmd | Node.js | tsc |
| Hot Reload | Yes | nodemon | ts-node |
| Standalone Binary | Yes | pkg/bun | pkg/bun |
| Bytecode VM | Yes | No | No |
| Native Built-ins | Yes | No | No |
How Portuguese code becomes high-performance executables.
What we have implemented and what is coming next.