Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Language Reference

Pith is designed to be simple and natural to read.

There are no curly braces {} and no semicolons ;. Each line is its own statement, and code blocks simply finish with the word end.


Quick Cheat Sheet

What you want to doExampleDescription
Create a variablename = "Alex"Stores a value that won’t change
Create a changeable variablemut score = 0Stores a value you can change later
Print somethingprint "Hello!"Shows text or numbers in the terminal
If / else decisionif score > 10 ... endRuns code only when something is true
Repeat codewhile score < 10 ... endRepeats code in a loop
Break out of a loopbreakStops a loop immediately
Skip to next loop stepcontinueJumps to the next turn of the loop
Check two thingsif logged_in and is_adminTrue only if both conditions are true
Check either thingif is_weekend or on_vacationTrue if at least one condition is true
Invert a conditionif not finishedTrue if finished is false
Create a functionfn add(a, b) ... endReusable block of code
Return from functionreturn a + bSends a value back to whoever called it

The Basic Rules

1. One Statement Per Line

You don’t need semicolons. Just write one command per line:

x = 10
y = 20
print x + y

2. Comments Start with #

Use # to write notes in your code that the computer ignores:

# This is a helpful comment
score = 100  # You can also add comments at the end of a line

3. Strings Use Double Quotes

Text is written inside double quotes:

message = "Hello, World!"

To include special characters:

  • \n creates a new line
  • \t creates a tab space
  • \" includes a quote inside the text

Detailed Chapters