These snippets are short, copy-ready examples for a blog post about Ze, a trilingual interpreted programming language written in Go. Each example highlights a different part of the language: mixed English/Tagalog/Bisaya keywords, indentation-based blocks, functions, lists, error handling, and web mode.
Run The Snippets
From the project root:
go build -o bin/ze.exe .
./bin/ze examples/blog/blog-01-trilingual-hello.ze
./bin/ze examples/blog/blog-02-grade-checker.ze
./bin/ze examples/blog/blog-03-list-report.ze
./bin/ze examples/blog/blog-04-functions-and-errors.ze
For the web example:
./bin/ze -web -dir examples/blog -addr localhost:8080
Then open:
http://localhost:8080/blog-05-web-greeting?name=Zyron
Snippet 1: Trilingual Hello
Use this near the start of the post to show the main idea: English, Tagalog, and Bisaya keywords can live in one file.
set english = "Hello"
itakda tagalog = "Kamusta"
ibutang bisaya = "Maayong adlaw"
show english + ", World!"
ipakita tagalog + ", mundo!"
ipakita bisaya + ", kalibutan!"
Output:
Hello, World!
Kamusta, mundo!
Maayong adlaw, kalibutan!
Source: blog-01-trilingual-hello.ze
Snippet 2: Readable Control Flow
This example is useful when explaining Ze’s Python-style indentation and natural-language comparison phrases.
set score = 87
if score is at least 90:
show "Excellent"
elif score is at least 75:
ipakita "Passed"
else:
ipakita "Try again"
Output:
Passed
Source: blog-02-grade-checker.ze
Snippet 3: Lists And Loops
Use this to show a small data workflow: collect values, loop through them, and summarize the result.
set scores = [92, 85, 78, 96]
set total = 0
for score in scores:
set total = total + score
show "Score: " + word(score)
set average = total / len(scores)
show "Average: " + word(average)
Output:
Score: 92
Score: 85
Score: 78
Score: 96
Average: 87.75
Source: blog-03-list-report.ze
Snippet 4: Functions And Error Handling
This is a compact example for a section about everyday scripting features.
define divide(a, b):
return a / b
try:
set answer = divide(24, 3)
show "Answer: " + word(answer)
if it fails err:
show "Could not divide: " + word(err)
Output:
Answer: 8
Source: blog-04-functions-and-errors.ze
Snippet 5: Web Mode
This one works well as the blog’s “and it can serve HTTP too” moment.
set name = get_param("name")
if name is empty:
set name = "World"
set page = "<h1>Kamusta, " + name + "!</h1>"
set page = page + "<p>Hello from a Ze web handler.</p>"
respond_html(page)
Output for http://localhost:8080/blog-05-web-greeting?name=Zyron:
<h1>Kamusta, Zyron!</h1><p>Hello from a Ze web handler.</p>
Output for http://localhost:8080/blog-05-web-greeting:
<h1>Kamusta, World!</h1><p>Hello from a Ze web handler.</p>
Source: blog-05-web-greeting.ze