Core Fundamentals
The Fundamentals — :core
Section titled “The Fundamentals — :core”“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.
1. The Atoms (Types)
Section titled “1. The Atoms (Types)”Data is not abstract. It consumes bytes.
i64 (The Integer)
Section titled “i64 (The Integer)”Mathematically pure.
let atoms = 42let big = 1000000f64 (The Float)
Section titled “f64 (The Float)”let pi = 3.14159bool (The Logic)
Section titled “bool (The Logic)”Truth or Falsehood. There is no “maybe”.
let is_sovereign = true2. The Flow (Control)
Section titled “2. The Flow (Control)”Code flows like water. You dig the canals.
if / else (The Fork)
Section titled “if / else (The Fork)”if atoms > 0 do println("Matter exists.")else println("Void.")endfor (The Cycle)
Section titled “for (The Cycle)”Iterate over known bounds.
for i in 0..10 do print_int(i)endwhile (The Siege)
Section titled “while (The Siege)”Iterate until a condition breaks.
var power = 1while power < 1000 do power = power * 2end::: tip SPEC-017 Law 2
match, enum, struct use { }. Control flow (func, if, for, while) uses do..end. This is law.
:::
3. The Verbs (Functions)
Section titled “3. The Verbs (Functions)”Encapsulate logic. Input goes in, output comes out.
func calculate_force(mass: i64, accel: i64) -> i64 do return mass * accelendAll function signatures MUST have explicit types. No exceptions.
4. Error Handling
Section titled “4. Error Handling”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 / bend
func main() do let result = divide(10, 0) catch |err| do println("Error: division by zero") 0 end print_int(result)endKeywords:
!T— error union return typefail— return an errorcatch— handle an errortry/?— 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 endendThis is the foundation. Master it.
Next Steps
Section titled “Next Steps”- [Quick Start]/learn/getting-started/ — Full quick start guide
- [Profiles System]/learn/profiles/ — Understand the capability ladder