Language Basics
Nubo is a simple, expressive, real-time language with a syntax inspired by Go and JavaScript. This guide walks you through the basic constructs.
Variables
Section titled “Variables”Use let
or const
to declare variables:
let name = "Martin"const age = 18 // not mutable
Functions
Section titled “Functions”Functions are declared with the fn
keyword:
fn greet(name) { return <h1>Hello, {name}!</h1>}
Control Flow
Section titled “Control Flow”If Statement
Section titled “If Statement”if age >= 18 { return <p>Adult</p>} else { return <p>Minor</p>}
While Cycle
Section titled “While Cycle”let inx = 0
while inx < 10 { println(inx+1) inx++}
For Loop
Section titled “For Loop”Supports both item-only and index+item syntax:
for item in range(3) { println(item)}
for i, item in list { println(i, item)}
HTML Templates
Section titled “HTML Templates”Nubo lets you embed HTML natively:
let name = "World"return <h1>Hello, {name}!</h1>
To render raw HTML (not escaped), prefix with @
:
let html = <b>bold</b>return <div>@{html}</div>
Components (Preview)
Section titled “Components (Preview)”You can use built-in components like this:
import styled from "@std/styled"
let user = nubo.User{ Name: "Martin" }
return <styled.AdminDashboard :user="user"> <styled.H1>Hello, {user.Name}!</styled.H1></styled.AdminDashboard>
More advanced features are covered in later sections.