Language Guide
A comprehensive guide to Layman's syntax and features
Core Philosophy
Layman programs are written in pure English prose. Every valid program reads like natural text, yet compiles to deterministic, efficient code. There are no special characters—only words, spaces, and standard punctuation.
Variables and Assignment
Variables are declared and assigned using natural English. Type annotations are optional—Layman can infer types from values.
# Simple assignment with type inference
name is 'Layman'
count is 10
is_active is true
# Explicit type annotation
age of type Number is 25
message of type String is 'Hello'
# Multi-word variable names
user name is 'Alice'
total count is 100
# The 'is' keyword is context-aware
# In assignment: assigns value
# In comparison: checks equality
# In object creation: creates new instanceTypes
Primitive Types
Number- integers and floating-point numbersString- text strings (also acceptsText)Bool- boolean values (also acceptsBoolean)Void- no value (also acceptsNothing)
# Type annotations
count of type Number is 5
name of type String is 'Alice'
is_active of type Bool is true
# Optional types with 'maybe'
optional_count of type maybe Number is nothing
optional_count of type maybe Number is 10Functions
Functions are defined using natural English phrases. Parameters and return types are clearly specified.
# Function definition
define function greet that takes name as String and returns Void
greeting is 'Hello, ' plus name
print greeting
# Function with multiple parameters
define function add that takes first as Number and second as Number and returns Number
return first plus second
# Function call
call function greet with argument 'World'
result is call function add with argument 5 and argument 3
# Lambda functions (anonymous functions)
double is function of x returning x times 2Control Flow
Conditional Statements
temperature is 75
if temperature is greater than 70 then
print "it is warm outside"
else if temperature is greater than 50 then
print "it is moderate"
else
print "it is cool outside"
end if
# 'otherwise if' is also supported
if condition then
action
otherwise if other condition then
other action
end ifFor Each Loops
numbers is a list containing 1, 2, 3, 4, 5
# The 'in' keyword is optional
for each num in numbers do
print num
end for
# Can also be written as
for each num numbers do
print num
end forWhile Loops
count is 0
while count is less than 10 do
count is count plus 1
print count
end whileOperators
Comparison Operators
# Equality (context-aware 'is')
if x is 5 then
print "x equals 5"
# Comparisons
if x is greater than 10 then
print "x is large"
if x is less than 5 then
print "x is small"
# Existence check
if value exists then
print "value is not nothing"
end ifArithmetic Operators
# Addition
sum is a plus b
sum is 5 plus 3
# Subtraction
difference is a minus b
# Multiplication
product is a times b
# Division
quotient is a divided by b
# Modulo
remainder is a modulo bLogical Operators
# Logical AND
if condition1 and condition2 then
print "both are true"
end if
# Logical OR
if condition1 or condition2 then
print "at least one is true"
end if
# Logical NOT
if not condition then
print "condition is false"
end ifString Operations
String concatenation uses the plus keyword or the concatenate function.
# String concatenation with 'plus'
greeting is 'Hello, ' plus name
message is prefix plus suffix
# String concatenation with function
greeting is call function concatenate with argument 'Hello, ' and argument name
# Convert to string
text_value is convert number to textClasses and Objects
Object-oriented programming in Layman uses natural English for class definitions and object creation.
# Class definition
define class Person that has
property name of type String
property age of type Number
define function greet that returns Void
greeting is "hello, my name is " plus name
print greeting
# Object creation
alice is a new Person with
name which is 'Alice'
age which is 30
# Call method on object
call function greet on alice
# Class inheritance
define class Student that extends Person
property school of type String
student is a new Student with
name which is 'Bob'
age which is 20
school which is 'University'Collections
# Lists
numbers is a list containing 1, 2, 3, 4, 5
first is item 1 of numbers
# Dictionaries
person is a dictionary containing
name which is 'Alice'
age which is 30
name is get name from personError Handling
# Try-catch blocks
try
result is 10 divided by 0
print result
catch error
print "error occurred: " plus error
end try
# Throwing errors
if count is less than 0 then
throw "count cannot be negative"
end ifImports and Modules
# Import a module
import math from 'std/math'
# Use imported functions
result is call function math.square with 5
# Import without path (searches standard locations)
import collectionsComments
# Comments start with # and continue to end of line
# This is a comment
# Multi-line comments require # on each line
# This is line one of a comment
# This is line two of a comment
name is 'Alice' # inline comment