alzscript
v0.6.4
Published
ALZ — A beginner-friendly programming language. Write plain English, compiles to Node.js.
Downloads
678
Maintainers
Readme
ALZ Programming Language
Write plain English. Runs on Node.js.
Install
npm install -g alz-langThe install package is called alz-lang but the command you use is just alz.
alz versionThat's it. You're ready.
Run a file
alz myapp.alzOr with the explicit keyword:
alz run myapp.alzInteractive shell
alzOpens the ALZ shell where you can type code line by line.
alz › name = "Sara"
alz › print "Hello {name}"
Hello Sara
alz › exitOther commands
alz build myapp.alz # compile to myapp.js
alz check myapp.alz # check for errors without running
alz version # show version
alz help # show helpThe language
Variables
name = "Sara"
age = 25
price = 9.99
active = true
empty = nullOutput
print "Hello"
print "Hello {name}"
print "Name: {name}, Age: {age}"
printInput
name = ask "What is your name? "
print "Hello {name}"Conditions
if age > 18:
print "Adult"
else if age == 18:
print "Just 18"
else:
print "Minor"if name is "Sara":
print "Found her"
if name isnt "Bob":
print "Not Bob"Loops
repeat 5:
print "Hello"
repeat 5 as i:
print "Step {i}"
each item in items:
print item
repeat until score > 100:
score = score + 10Functions
define greet(name):
print "Hello {name}"
define add(a, b):
return a + b
greet("World")
result = add(10, 5)
print resultLists
fruits = ["apple", "mango", "banana"]
fruits.add("grape")
fruits.remove("mango")
fruits.sort()
print fruits.length
print fruits.has("apple")Objects
user = { name: "Sara", age: 25 }
print user.name
user.age = 26Math
x = round(3.7)
x = floor(9.9)
x = sqrt(16)
x = abs(-5)
x = max(3, 7)
x = min(3, 7)
x = power(2, 8)
x = random()Files
content = read "notes.txt"
write "notes.txt" "Hello World"
add to "notes.txt" "New line"
delete "notes.txt"
exists = file exists "notes.txt"HTTP
data = fetch "https://api.example.com/users"
print dataWeb server
serve on 3000:
route "/":
respond "Hello World"
route "/greet" method="POST":
name = request.name
respond "Hello {name}"Database
No SQL. No setup. Just works.
db.save("users", { name: "Sara", age: 25 })
all = db.all("users")
one = db.find("users", { name: "Sara" })
db.update("users", { name: "Sara" }, { age: 26 })
db.remove("users", { name: "Sara" })Data is stored in .alzdata/ folder as JSON files.
Error handling
try:
data = fetch "https://api.example.com"
print data
catch err:
print "Failed: {err}"Comments
// single line
# single line
/* multi
line */How it works
your .alz file
↓
Lexer reads your code, produces tokens
↓
Parser turns tokens into a tree (AST)
↓
Codegen converts the tree to JavaScript
↓
Node.js runs the JavaScriptYou never see the JavaScript. You just write ALZ.
License
MIT — ALZ TECH
