Home Download Docs Discord Server

H20 H20

Basic Syntax

1. Variables and Mutability

In H20, variables are immutable by default. This means you can't easily change the value of the variable or change its memory address. To make it mutable, you must use the mut keyword

2. Comparison and Logical Operators

H20 uses clean, text-based operators to make logic easy to read:

Example:


        if (not isGameOver and playerHealth isnot 0) {
            print("The fight continues!")
        }
    

3. Class Structure

Every H20 file is a class. You dont need boilerplate "public static void main" for everything, but your mainclass's main() is required for the entry point.


        public class Main { // Class name must match file name
            func main() { // main() is hardcoded to be public, static and returns int no matter what
                print("Hello from H20!")
            }
        }
    

4. Built-in Constants

H20 provides high precision math constants. No more typing 3.14 manually! Sadly x64 hardware had a limit how many decimals it could store.

Example:


    float radius = 5.0
    float area = PI * (radius * radius)
    print("The area is: " + area)