AztecInstitute
Iniciar sesión
AztecInstitute · Xcojo’s own language

AClang — Advanced Connect Language

One readable file for a whole app. AClang mixes the best of HTML, CSS, JavaScript, Rust, PHP, SQL and Python, and connects to Xcojo services with a single keyword.

Playground

Edit the code and press Run (⌘/Ctrl + Enter). The playground runs the browser side of AClang — @state, @page, @style and @client. @data, @server and route run on a server.

See the generated JavaScript

Language reference

Files and blocks

An AClang file (.acl) is a list of blocks. Each starts with @kind and a { … } body.

BlockPurposeCompiles to
@page Name(params)Markup with {expr}, for x in list { }, if cond { } else { }, on:event={fn}HTML + render code
@style [Name]Scoped CSS; $accent, $radius, $text, $surface, $muted tokensCSS
@statename: Type = start — reactive valuesJavaScript store
@clientfn functions that run in the browserJavaScript
@data ModelTyped models: Int, Float, Text(n), Bool, Money(XCJ), Time, Ref<Model>, @auto, @now, @index(…)SQL tables + migrations
@serverServer functions, @cache(…), @allow(…)PHP
route METHOD "/path/{x: Type}"URLs → Page or Json; private unless @public; CSRF-checkedPHP router
connect servicexcojo.signin, astromark, pay, verification, aiTyped API clients

Types and values

let name: Text = "Selam"          // immutable
var total: Money(XCJ) = 0 XCJ     // mutable
let tags: List<Text> = ["new", "sale"]
let maybe: Option<Product> = find first Product where id == 7
enum Status { Draft, Paid, Shipped(Time) }

match status {
  Draft      => "Not paid yet"
  Paid       => "Packing"
  Shipped(t) => "Shipped on " + t.date()
}

Queries

find Product where price < 5 XCJ and stock > 0 order by price limit 20
find first User where email == input
insert Order { product: p, buyer: me }
update Product where id == p.id set stock = stock - 1
delete Session where created < now() - 30 days
transaction { … }

Errors

fn charge(o: Order) -> Result<Receipt, Text> {
  let r = pay.charge(me, o.total, "Order " + o.id)?   // ? passes failures up
  return ok(r)
}

Security defaults

  • Everything in { } is escaped; raw HTML needs {raw …}.
  • Queries always use parameters.
  • POST routes check a CSRF token; routes are private unless @public.
  • Password values are hashed and can never be printed or logged.
  • Secrets come from env. only.

AClang is taught at AztecInstitute. The playground compiles the browser side so you can learn by doing; the server toolchain is introduced in AClang 2.