Skip to content

Core Fundamentals

“Learn the rules like a pro, so you can break them like an artist. But today, we learn the rules.”

In the :core profile, we strip away the noise. We are left with the Atoms of Computation.

Data is not abstract. It consumes bytes.

Mathematically pure.

let atoms = 42
let big = 1000000
let pi = 3.14159

Truth or Falsehood. There is no “maybe”.

let is_sovereign = true

Code flows like water. You dig the canals.

if atoms > 0 do
println("Matter exists.")
else
println("Void.")
end

Iterate over known bounds.

for i in 0..10 do
print_int(i)
end

Iterate until a condition breaks.

var power = 1
while power < 1000 do
power = power * 2
end

::: tip SPEC-017 Law 2 match, enum, struct use { }. Control flow (func, if, for, while) uses do..end. This is law. :::

Encapsulate logic. Input goes in, output comes out.

func calculate_force(mass: i64, accel: i64) -> i64 do
return mass * accel
end

All function signatures MUST have explicit types. No exceptions.

Janus uses error unions — errors as values, not exceptions:

func divide(a: i64, b: i64) !i64 do
if b == 0 do
fail DivisionByZero
end
return a / b
end
func main() do
let result = divide(10, 0) catch |err| do
println("Error: division by zero")
0
end
print_int(result)
end

Keywords:

  • !T — error union return type
  • fail — return an error
  • catch — handle an error
  • try / ? — propagate an error

5. The Exercise: FizzBuzz (The Gatekeeper)

Section titled “5. The Exercise: FizzBuzz (The Gatekeeper)”

Write a program that prints numbers 1 to 100.

  • If divisible by 3, print “Fizz”.
  • If divisible by 5, print “Buzz”.
  • If both, print “FizzBuzz”.

Why? Because if you can control flow and logic, you can build anything.

func fizzbuzz(n: i64) do
for i in 1..n do
if i % 15 == 0 do
println("FizzBuzz")
else if i % 3 == 0 do
println("Fizz")
else if i % 5 == 0 do
println("Buzz")
else
print_int(i)
end
end
end

This is the foundation. Master it.

  • [Quick Start]/learn/getting-started/ — Full quick start guide
  • [Profiles System]/learn/profiles/ — Understand the capability ladder