NAIDE-X (.nx) Syntax

NAIDE-X is an ultra-compact syntax optimized for AI token efficiency. Files use the .nx extension and compile through a preprocessor into standard NAIDE before transpilation.

When to use NX? Use .nx when you're generating code with AI and want minimal tokens. Use .naide for human-readable code.

Variables

NAIDENX
str name = "World"s:name="World"
int count = 42i:count=42
num price = 9.99n:price=9.99
bool active = trueb:active=true
any data = nulla:data=null
list items = []l:items=[]
map config = {}m:config={}

Functions

NAIDENX
fn greet(name):f greet(name)
fn.async fetch():~f fetch()
ret value>value
pub fn add(a, b):+f add(a,b)

Return Type Annotations

f greet(s:who)s     # fn greet(who) -> str
  >"Hello, {who}!"

~f load(s:url)a    # async fn load(url) -> any
  a:res=~fetch(url)
  >~res.json()

Server & Routes

NAIDENX
server app port 3000:$app:3000
get "/":G"/"
post "/api":P"/api"
put "/api/:id":U"/api/:id"
del "/api/:id":D"/api/:id"
patch "/api/:id":X"/api/:id"

Response Shorthands

NAIDENX
ret.html "...">.h "..."
ret.redirect "/new">.r "/new"
ret.text "...">.t "..."
ret.file "path">.f "path"
ret.render "view" {}>.v "view" {}
ret.download "path">.d "path"

Control Flow

NAIDENX
if condition:?condition
elif condition:??condition
else:??
each item in list:@item in list
for i in 0..10:#i 0..10
while cond:&cond

Error Handling

!                  # try:
  risky()
!!e                # fail e:
  log e.message
!!!                # ensure:
  cleanup()

Logging

NAIDENX
log "msg"log"msg"
log.warn "msg"log.w"msg"
log.error "msg"log.e"msg"
log.info "msg"log.i"msg"
log.debug "msg"log.d"msg"

Complete Example

# NX: Todo API in minimal tokens
$app:3000
  G"/"
    >{msg:"Todo API"}
  G"/api/todos"
    l:todos=[{id:1,title:"Learn NAIDE",done:false}]
    >todos
  P"/api/todos"(req,res)
    a:todo=req.body
    >{created:true}

Converting NAIDE to NX

$ naide convert app.naide    # outputs app.nx