Hello world teaches you nothing. It has no state, no decisions, no loops, no bugs. It's a greeting card, not a program.
Chapter 2 is where RUDRA gets real. We build a Number Summarizer: feed it 1..n, it prints each number's even/odd status, totals them up, and classifies the sum. Small enough to fit in your head. Real enough to teach you everything.
The program
fn sum_to(n: int) -> int { let mut total = 0; for i in 1..(n + 1) { total = total + i; } return total; } fn is_even(x: int) -> bool { return x % 2 == 0; } fn main() { let n = 5; print("RUDRA number summary"); for i in 1..(n + 1) { if is_even(i) { print("{i} is even"); } else { print("{i} is odd"); } } let s = sum_to(n); print("sum: {s}"); if is_even(s) { print("the sum is even"); } else { print("the sum is odd"); } } The ideas that do all the work
-
letvslet mut— variables are immutable by default. Reassign a plainletand the compiler stops you with the exact line number. Mutability is opt-in, which means every mutation in your code is a deliberate decision. - Ranges end exclusive —
1..6means 1 through 5. This WILL bite you exactly once; after that you'll never forget. The idiom for "1 through n" is1..(n + 1). - The accumulator —
total = total + i;inside the loop. (No+=in RUDRA's book — the explicit form keeps beginners honest about what's happening.) - Functions with types —
fn sum_to(n: int) -> int. Parameters and return types are written out. The compiler checks every call.
The honest workflow
There's no keyboard-input API in the book at this stage — so n lives in the source. Change it and re-run:
rudrac summary.rux --run Edit → run → read output → repeat. n = 5, 10, 20… each run teaches you something.
The 3 bugs you will definitely write
Debugging method: problem → behavior → reason → fix → retest.
- Off-by-one — you write
1..nand n silently vanishes from the sum. Runs fine. Wrong answer. The exclusive end strikes. - Missing
mut— you reassign a plainlet. Compiler error, exact line given. Addmut, move on. -
=vs==— assignment inside a condition. Compiler error; conditions need comparison.
Every one of these has bitten a professional this month. You're in good company.
Refactor like you mean it
Repeated logic becomes a function (is_even, sum_to). Names say what they mean. One idea per function. And the rule that keeps you honest: refactor only with features you've already learned — no cleverness debt.
Proof it works
| n | sum | parity |
|---|---|---|
| 1 | 1 | odd |
| 5 | 15 | odd |
| 10 | 55 | odd |
| 20 | 210 | even |
Real runs, real numbers.
Keep going
🎥 Start the course — Chapter 1 video: https://www.youtube.com/watch?v=-adNF7Fi0Pg
📥 Download RUDRA (free): https://github.com/rakshanex/rudra
💬 WhatsApp channel: https://whatsapp.com/channel/0029Vb8hknnGE56kO24pbq47
Next chapters build on this foundation — the course follows the official book, chapter by chapter.
Question: which of the 3 bugs has bitten YOU most recently — off-by-one, missing mut, or = vs ==? Confess in the comments.
Piyush Kumar — Founder & Director, RAKSHANEX TECHNOLOGIES. Cybersecurity specialist (pentesting, red teaming, SOC, DFIR). Builder of RUDRA, OmniCore OS, AgentTrace. Author of "The RUDRA Programming Language" and four cybersecurity books.
