1 Hello World

Let's start with the classic "Hello World" program. In Whisper, you use the whisper command to output text.

whisper "Hello, World!"
Hello, World!

You can also use other output commands:

show "This also works!"
tell me "So does this!"
just say "And this too!"
Create a file called hello.wsp and write a program that displays your name!

2 Variables

Variables in Whisper use natural language. There are multiple ways to create them:

# Method 1: Using "let"
let name be "Alice"
let age be 25

# Method 2: Using "remember that"
remember that score is 100

# Method 3: Using "set"
set level to 5

# Method 4: Using "so"
so points is 50

Display variables:

whisper "My name is " + name
show "I am " + age + " years old"
All these methods do the same thing - choose the one that reads most naturally to you!

3 User Input

Get input from users with the ask command:

ask "What is your name?" into username
whisper "Hello, " + username + "!"

ask "How old are you?" into user_age
whisper "You are " + user_age + " years old"
Create a program that asks for someone's favorite color and displays a personalized message!

4 Conditionals

Whisper has two styles of conditionals:

Style 1: When/Or When/Otherwise

let age be 20

when age greater than 18:
    whisper "You are an adult"
or when age equals 18:
    whisper "Just turned 18!"
otherwise:
    whisper "You are a minor"

Style 2: Question Format

let score be 85

is score greater than 60?
    yes:
        whisper "You passed!"
    no:
        whisper "Try again"

Comparison operators you can use:

5 Loops

Whisper offers multiple loop styles:

While Loop

let count be 1

while count less than 6:
    whisper "Count: " + count
    increase count by 1

Repeat Loop

repeat 5:
    whisper "Hello!"

# or
do 3 times:
    whisper "Hi there!"

For Each Loop

make fruits with ["apple", "banana", "orange"]

for each fruit in fruits:
    whisper "I like " + fruit

Loop control:

6 Functions

Create reusable code with functions:

# Define a simple function
define greet:
    whisper "Hello from function!"

# Call the function
call greet

# Function with parameters
define greet_person with name:
    whisper "Hello, " + name + "!"

call greet_person with "Alice"

# Function that returns a value
define add with a, b:
    give back a + b

call add with 5, 3
whisper "Sum: " + __last_result__

7 Story Objects

Create game characters and objects with natural syntax:

# Create a hero character
there is a hero with health 100, power 50

# Access properties
show hero health
show "Power: " + hero power

# Modify properties
the hero loses 20 health
the hero gains 10 power

show "Health: " + hero health
show "Power: " + hero power
Create a simple RPG character with stats like health, attack, and defense. Make them gain and lose stats!

8 Lists & Arrays

Work with collections of data:

# Create a list
make tasks with ["Buy milk", "Call mom"]

# Add items
add "Study Whisper" to tasks
add "Exercise" to tasks

# Display all items
for each task in tasks:
    whisper task

# Remove an item
remove "Call mom" from tasks

9 Math Operations

Whisper supports all basic math and advanced functions:

# Basic operations
let sum be 10 + 5
let diff be 10 - 5
let product be 10 * 5
let quotient be 10 / 5

# Math functions
let root be sqrt(16)
let power be pow(2, 3)
let absolute be abs(-10)
let rounded be round(3.7)
let biggest be max(5, 10, 3)
let smallest be min(5, 10, 3)

10 What's Next?

Congratulations! You've learned the basics of Whisper. Here's what to explore next:

The best way to learn is by doing! Try modifying the examples and creating your own programs.