Teacup #2: Variables, Conditions, Loops, and Functions tutorial

Variables, Conditions, Loops, and Functions


Programming is just telling stories to a computer

In Part 1, you wrote your first GTLang program and learned that:

  • $ means data

  • @ means action

  • Indentation means structure

Now we move one step further.

At this stage, you are not “coding” yet.
You are simply explaining your thoughts to a machine.

And like every explanation, we start with memory.


1. Variables – Let the computer remember things

Humans remember names, numbers, and ideas.
Computers remember them using variables.

In GTLang, variables always start with a dollar sign $.

Creating a variable

$name : John
unctions2$age : 24

Read it like this:

“Name is John.”
“Age is 24.”

No complicated keywords.
Just assignment.


Using variables

@echo $name
@echo $age

Output:

John
24

Variables help you:

  • Avoid repeating values

  • Change data easily

  • Make programs flexible


Multiple assignments (because life is short)

$name, $city : John, Moscow

Simple. Clean. Human-friendly.


2. Conditions – Teaching the computer how to decide

Real life is full of choices.

  • If it rains, take an umbrella

  • If battery is low, charge the phone

  • If user is wrong, show a message

Programming is the same.


Basic if / else

$age : 20

if $age >= 18
@echo “You are an adult”
else
@echo “You are under 18”

Read it slowly:

If age is greater than or equal to 18
→ say “You are an adult”
Otherwise
→ say “You are under 18”

That’s it.

No parentheses.
No braces.
No noise.


Multiple conditions with elif

$score : 85

if $score >= 90
@echo “Excellent”
elif $score >= 70
@echo “Good”
else
@echo “Try again”

This feels close to natural thinking, not machine thinking.


3. Loops – When one time is not enough

Sometimes you don’t want to do something once.
You want to do it many times.

That’s what loops are for.


Simple loop: for ... times

for 3 times
@echo "Welcome to GTLang"

Output:

Welcome to GTLang
Welcome to GTLang
Welcome to GTLang

Behind the scenes, GTLang creates a counter called $_time.

You can use it:

for 3 times
@echo $_time ". Hello"

Output:

1. Hello
2. Hello
3. Hello

Simple loops are perfect for beginners.


Looping through a list (arrays)

$names : ["Annie", "Bob", "John"]

foreach $names
@echo $_value

Output:

Annie
Bob
John

No indexes.
No complex syntax.
Just values.


4. Functions – Teaching the computer new skills

Functions are reusable ideas.

Instead of writing the same logic again and again, you:

  1. Give it a name

  2. Describe what it does

  3. Call it when needed


A simple function

@say_hello:
@echo "Hello from GTLang"

Call it:

@say_hello

Output:

Hello from GTLang

Functions with parameters

@greet $name:
@echo "Hello " $name

Call it:

@greet John
@greet Annie

Output:

Hello John
Hello Annie

Now your program can adapt, not just repeat.


Functions that return values

@sum $a, $b:
return $a + $b

Use it like this:

$total : (@sum 3, 4)
@echo $total

Output:

7

This is where programming starts to feel powerful.


5. Why GTLang feels easy (on purpose)

Many languages force beginners to learn:

  • Types

  • Syntax rules

  • Compilers

  • Hidden errors

GTLang avoids that early pressure.

Instead, it teaches:

  • Thinking

  • Flow

  • Structure

  • Expression

Once you understand these ideas, any language becomes easier later.


Final thoughts – You are already programming

If you can:

  • Store values

  • Make decisions

  • Repeat actions

  • Create functions

Then you are already programming.

Not “almost”.
Not “beginner”.
Already.

GTLang just removes the fear, so you can focus on ideas first — syntax later.

In the next part, you can explore:

  • Arrays and objects

  • Working with files

  • Small real-world scripts

  • Writing clean, readable GTLang code

Take it slow.
Like green tea ☕🌱