Standard Library
When you install EZ, it comes with a set of ready-to-use tools called the standard library (or “stdlib” for short). These are modules that handle common tasks so you don’t have to write everything from scratch.
Think of it like a toolbox that comes with your house — you didn’t have to buy the hammer and screwdriver separately, they’re just there when you need them.
What’s a Module?
A module is a collection of related functions grouped together. For example, all the math-related functions live in the @math module, and all the text-related functions live in the @strings module.
The @ symbol tells EZ “this is a built-in module” (as opposed to a file you created yourself).
How to Use a Module
Step 1: Import at the Top
Imports must go at the top of your file, before any other code:
import @std
import @math
do main() {
// your code here
}
Step 2: Use with the Module Prefix
Once imported, use functions with the module name as a prefix:
math.sqrt(16.0) // 4.0
std.println("Hi") // prints "Hi"
The math. and std. prefixes tell EZ which module each function, variable, or type comes from. This prevents confusion when two modules have functions with the same name.
Import Options
Import multiple modules on one line or separate lines:
import @std, @math, @arrays
import @std
import @math
import @arrays
For beginners, stick with the basic import @std + std.println() style. The prefix makes it clear where each function comes from.
Click Here For Advanced Import Styles
Aliasing (Shorter Names)
Give a module a shorter name:
import s@strings
import m@math
do main() {
s.upper("hello") // instead of strings.upper()
m.sqrt(16.0) // instead of math.sqrt()
}
Using (Drop the Prefix)
The using keyword brings a module’s contents into scope, so you can call functions without the prefix:
import @std
do main() {
using std
println("No prefix needed!")
}
Important: using only applies to the scope where it’s declared:
import @std
do main() {
using std
println("Works here!") // No prefix needed
}
do helper() {
std.println("Need prefix here") // Different function, no 'using'
}
To use without prefix in multiple functions, add using to each one, or use the file-level approach below.
Import & Use (File-Level Scope)
Combines import and using in one line, making the module available everywhere in the file:
import & use @std
do main() {
println("No prefix!")
}
do helper() {
println("Works here too!") // No prefix needed anywhere
}
You can also combine with aliasing:
import & use S@std
do main() {
S.println("Short prefix everywhere!")
}
do helper() {
S.println("Same alias works here!")
}
When to Use What
| Style | Syntax | Best For |
|---|---|---|
| Basic | import @std | Most code — prefix makes origin clear |
| Alias | import m@math | Long module names you use frequently |
| Function-scoped using | using std inside function | One function that heavily uses a module |
| File-scoped | import & use @std | Small scripts, less typing |
| File-scoped + alias | import & use S@std | Short prefix everywhere |
Available Modules
EZ includes ten built-in modules:
| Module | What it’s for |
|---|---|
| @std | Basic input/output — printing text, getting user input |
| @math | Math operations — square roots, powers, logarithms |
| @random | Random generation — numbers, choices, shuffling |
| @arrays | Working with lists — sorting, filtering, finding items |
| @strings | Working with text — uppercase, splitting, trimming |
| @maps | Key-value storage — like a dictionary or phonebook |
| @time | Dates and time — current time, formatting, delays |
| @bytes | Binary data — encoding, decoding, byte manipulation |
| @io | File system — reading, writing, paths, directories |
| @os | Operating system — environment, platform detection, commands |
Quick Example
Here’s a small program that uses three different modules:
import @std
import @math
import @strings
do main() {
// @std for printing
std.println("Welcome!")
// @math for calculations
temp radius float = 5.0
temp area float = math.PI * math.pow(radius, 2.0)
std.println("Circle area:", area)
// @strings for text manipulation
temp name string = " alice "
temp clean string = strings.trim(name)
temp upper string = strings.upper(clean)
std.println("Hello,", upper) // "ALICE"
}
Tips for Beginners
Start with @std — You’ll use std.println() in almost every program. It’s how you see output from your code.
You don’t need to memorize everything — Bookmark this page. When you need to do something with arrays, check the @arrays page. Need to format a date? Check @time. The docs are here for reference.
Import only what you need — If your program only prints text, you only need import @std. No need to import @math if you’re not doing math.
Next Steps
Pick a module and explore what it can do:
- @std — Start here, it’s the most common
- @math — For calculations and logarithms
- @random — For random numbers and shuffling
- @arrays — For working with lists of things
- @strings — For manipulating text
- @maps — For key-value data
- @time — For dates, times, and delays
- @bytes — For binary data and encoding
- @io — For file and directory operations
- @os — For system info, environment, and commands