A JtV program consists of Control Language statements that may contain Data Language expressions.
// Comments use double-slash
/* Or block comments */
// Variable declarations and assignments
x = 42
y = 3.14
name = "Julia"
// Control flow
if condition {
// statements
}
while condition {
// statements
}
for i in 0..10 {
// statements
}
Identifiers start with a letter or underscore, followed by letters, digits, or underscores:
myVariable
_private
camelCase
snake_case
PascalCase
42 // Decimal
0x2A // Hexadecimal
0b101010 // Binary
0o52 // Octal
3.14
2.5e10
1.0e-5
1/2 // One half
3/4 // Three quarters
22/7 // Approximation of π
3 + 4i // 3 + 4i
2i // Pure imaginary
1 + 0i // Real as complex
"Hello, World!"
"Line 1\nLine 2"
"Tab\there"
if else while for in
fn return
let mut
true false
print
reverse // v2
@pure @total // Function annotations
// The ONLY arithmetic operator in Data Language
a + b // Addition
a + -b // Subtraction via additive inverse
// Assignment
x = expr
// Comparison (in conditions)
a == b
a != b
a < b
a > b
a <= b
a >= b
// Logical
!a
a && b
a || b
variable = expression
The assignment is the sole join point between Data and Control languages.
if condition {
// then branch
}
if condition {
// then branch
} else {
// else branch
}
// While loop (may not terminate)
while condition {
// body
}
// For loop (bounded iteration)
for i in start..end {
// body using i
}
for item in collection {
// body using item
}
fn name(param1: Type1, param2: Type2): ReturnType {
// body
return value
}
// Pure function (callable from Data Language)
@pure fn add(a: Int, b: Int): Int {
return a + b
}
// Total function (guaranteed to halt)
@total fn square(x: Int): Int {
return x + x // Conceptually x * x via repeated addition
}
print(expression)
print("Hello")
print(x + y)
Data expressions are guaranteed to terminate:
// Literals
42
3.14
1/2
3 + 4i
// Variables
x
counter
// Addition (the only operator)
a + b
x + y + z
// Function calls (pure functions only)
sqrt(x)
abs(y)
// Calculate sum using repeated addition
@pure fn multiply(a: Int, b: Int): Int {
result = 0
for i in 0..b {
result = result + a
}
return result
}
// Safe user input handling
user_value = parseInput(input)
total = base + user_value
// Complex number arithmetic
z1 = 3 + 4i
z2 = 1 + 2i
sum = z1 + z2 // 4 + 6i
// Rational arithmetic (exact)
half = 1/2
third = 1/3
sum = half + third // 5/6 (exact, no floating-point error)