Complete guide to the Bloa programming language
Bloa uses a clean, readable syntax inspired by modern programming languages. Statements end with newlines, and blocks are enclosed in curly braces {}.
# Comments start with hash
say("Hello, World!") # Print to console
Variables are dynamically typed and declared using the assignment operator =.
x = 42
name = "Bloa"
is_active = true
list = [1, 2, 3]
pi = 3.14159
if x > 10 {
say("x is greater than 10")
} else if x == 10 {
say("x is 10")
} else {
say("x is less than 10")
}
i = 0
while i < 5 {
say("i = " + str(i))
i = i + 1
}
for i = 0; i < 5; i = i + 1 {
say("i = " + str(i))
}
function greet(name) {
say("Hello, " + name + "!")
}
function add(a, b) {
return a + b
}
greet("Bloa")
result = add(5, 3)
say("5 + 3 = " + str(result))
class Person {
function __init__(self, name, age) {
self.name = name
self.age = age
}
function greet(self) {
say("Hi, I'm " + self.name)
}
}
person = Person("Alice", 30)
person.greet()
Import external modules with the import keyword:
import math
import utils.helpers
result = math.sqrt(16)
say("sqrt(16) = " + str(result))