Light Dark

Data Literals

Hot uses JavaScript-like syntax for data literals, making it instantly familiar if you've worked with JSON. There are a few important differences to be aware of.

Strings

Double-quoted strings, just like JSON:

greeting "Hello, world!"
path "/api/users"
empty-str ""

Template Literals

Use backticks for string interpolation:

name-tpl "Alice"
message `Hello, ${name-tpl}!`              // "Hello, Alice!"
calculation `2 + 2 = ${add(2, 2)}`         // "2 + 2 = 4"
`Hello, ${name}!`        → "Hello, Alice!"
`2 + 2 = ${add(2, 2)}`   → "2 + 2 = 4"

Any expression can go inside ${}.

Numbers

Hot has two number types: Int and Dec.

Int (Integers)

Whole numbers without decimal points:

count-num 42
negative -17
zero-num 0

Dec (Decimals)

Numbers with decimal points. Hot uses Dec instead of floating-point:

price 19.99
rate 0.05
pi 3.14159265358979323846

Why Dec instead of Float?

Floating-point math has precision issues:

// In JavaScript: 0.1 + 0.2 = 0.30000000000000004

Hot's Dec type uses 256-bit decimal arithmetic (via fastnum D256) providing up to 76 digits of precision. This means exact decimal arithmetic—critical for money, percentages, scientific calculations, and anywhere precision matters.

// These are exact in Hot, no floating-point errors
total-dec add(0.1, 0.2)   // Exactly 0.3
add(0.1, 0.2) → 0.3  // Exact, no floating-point error!

Booleans

active true
disabled false

Null

The absence of a value:

nothing null
user-avatar null

Vectors

Ordered collections using square brackets:

numbers [1, 2, 3]
names ["Alice", "Bob", "Carol"]
mixed ["text", 42, true, null]
empty-vec []

Nested vectors:

matrix [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]

Access elements with first(), last(), or index notation:

numbers-access [10, 20, 30]
first-num first(numbers-access)   // 10
last-num last(numbers-access)     // 30

Note: Hot uses Vec (vector) where other languages use "array". Same concept, different name.

Maps (like Objects)

Key-value collections using curly braces:

user-map {name: "Alice", age: 30}
config-map {debug: true, port: 8080}
empty-map {}

Nested maps:

settings {
  database: {
    host: "localhost",
    port: 5432
  },
  cache: {
    enabled: true,
    ttl: 3600
  }
}

Access properties with dot notation:

user-access {name: "Alice", email: "alice@example.com"}
name-access user-access.name     // "Alice"
email-access user-access.email   // "alice@example.com"
user.name  → "Alice"
user.email → "alice@example.com"

Map vs Object: Hot calls these Map instead of Object. Keys are always strings.

Comparison to JavaScript/JSON

ConceptJavaScript/JSONHot
Array[1, 2, 3][1, 2, 3] (same syntax, called Vec)
Object{"a": 1}{a: 1} (unquoted keys, called Map)
String"hello""hello" (same!)
Template`Hi ${name}``Hi ${name}` (same!)
Integer4242 (same!)
Float3.143.14 (but it's Dec!)
Booleantrue/falsetrue/false (same!)
Nullnullnull (same!)

Type Annotations on Literals

You can add types to your data for documentation and type checking:

// Simple types
count-typed: Int 42
price-typed: Dec 19.99
name-str: Str "Alice"

// Generic types
numbers-typed: Vec<Int> [1, 2, 3]
prices-typed: Vec<Dec> [9.99, 19.99]
user-typed: Map<Str, Any> {name: "Alice", age: 30}

Summary

  • Hot's data literals are nearly identical to JSON
  • Vec (vector) for ordered collections, Map for key-value collections
  • Use Dec for decimals (not floating-point) — exact precision
  • Template literals use backticks with ${expression} interpolation
  • Access vectors with [index], maps with .property