This document describes the standard library of the CURSED programming language, which provides core functionality for common programming tasks.
The vibez
package provides formatted I/O functions.
vibe main
yeet "vibez"
slay main() {
vibez.spill("Hello, World!") fr fr Equivalent to fmt.Println
name := "bestie"
vibez.spillf("Hey %s, what's good?", name) fr fr Equivalent to fmt.Printf
tea output := vibez.spillstr("Value: %d", 42) fr fr Equivalent to fmt.Sprintf
}
Main functions:
spill(args ...collab{})
- Print args followed by newlinespillf(format tea, args ...collab{})
- Formatted printspillstr(format tea, args ...collab{})
- Return formatted stringscan(args ...collab{})
- Scan input into argsscanln(args ...collab{})
- Scan line into args
The core
package provides fundamental types and functions automatically included in all CURSED programs.
Functions:
lit(x)
- Convert to booleannormie(x)
- Convert to int32thicc(x)
- Convert to int64snack(x)
- Convert to float32meal(x)
- Convert to float64tea(x)
- Convert to stringappend(slice []T, elems ...T)
- Append elements to slicecap(v T)
- Capacity of slice, map, or channellen(v T)
- Length of string, array, slice, map, or channelmake(T, size ...normie)
- Create slice, map, or channelnew(T)
- Create pointer to zero value of typepanic(v collab{})
- Cause panic with valuerecover()
- Recover from panic
The dropz
package provides basic I/O primitives.
yeet "dropz"
slay readFile(path tea) ([]byte, tea) {
data, err := dropz.ReadFile(path)
yolo data, err
}
Main interfaces:
Reader
- Interface for reading bytesWriter
- Interface for writing bytesCloser
- Interface for closing resources
The vibe_life
package provides OS functionality.
yeet "vibe_life"
slay main() {
args := vibe_life.Args fr fr Command-line arguments
err := vibe_life.Setenv("DEBUG", "based") fr fr Set environment variable
lowkey err != cap {
vibez.spill("Failed to set env:", err)
vibe_life.Exit(1)
}
value := vibe_life.Getenv("DEBUG") fr fr Get environment variable
}
Main functions:
Args
- Command-line argumentsGetenv(key tea)
- Get environment variableSetenv(key, value tea)
- Set environment variableExit(code normie)
- Exit with status codeCreate(name tea)
- Create fileOpen(name tea)
- Open file for reading
The stringz
package provides string manipulation functions.
yeet "stringz"
slay main() {
tea s := "hello, world"
lowkey stringz.Contains(s, "world") {
vibez.spill("Found!")
}
parts := stringz.Split(s, ", ") fr fr ["hello", "world"]
upper := stringz.ToUpper(s) fr fr "HELLO, WORLD"
}
Main functions:
Contains(s, substr tea)
- Check if s contains substrCount(s, substr tea)
- Count occurrences of substr in sHasPrefix(s, prefix tea)
- Check if s starts with prefixHasSuffix(s, suffix tea)
- Check if s ends with suffixJoin(elems []tea, sep tea)
- Join elements with separatorSplit(s, sep tea)
- Split s by separatorToLower(s tea)
- Convert to lowercaseToUpper(s tea)
- Convert to uppercaseTrim(s, cutset tea)
- Trim characters from beginning and end
The mathz
package provides mathematical functions.
yeet "mathz"
slay main() {
x := mathz.Sqrt(25.0) fr fr 5.0
y := mathz.Pow(2.0, 10.0) fr fr 1024.0
z := mathz.Round(3.7) fr fr 4.0
}
Main functions and constants:
Abs(x meal)
- Absolute valueCeil(x meal)
- Ceiling functionFloor(x meal)
- Floor functionMax(x, y meal)
- MaximumMin(x, y meal)
- MinimumPow(x, y meal)
- x^ySqrt(x meal)
- Square rootPi
- Mathematical constant πE
- Mathematical constant e
The timez
package provides time-related functionality.
yeet "timez"
slay main() {
now := timez.Now() fr fr Current time
then := now.Add(timez.Hour * 24) fr fr Tomorrow
duration := then.Sub(now) fr fr 24 hours
timez.Sleep(timez.Second * 2) fr fr Sleep for 2 seconds
}
Main types and functions:
Time
- Represents a timeDuration
- Represents a durationNow()
- Current local timeSleep(d Duration)
- Sleep for durationSince(t Time)
- Duration since tUntil(t Time)
- Duration until t
The concurrenz
package provides synchronization primitives.
yeet "concurrenz"
slay main() {
sus mu concurrenz.Mutex
stan slay() {
mu.Lock()
later mu.Unlock()
fr fr Do something
}()
sus wg concurrenz.WaitGroup
wg.Add(1)
stan slay() {
later wg.Done()
fr fr Do something
}()
wg.Wait()
}
Main types:
Mutex
- Mutual exclusion lockRWMutex
- Reader/writer mutual exclusion lockWaitGroup
- Wait for goroutines to finishCond
- Condition variableOnce
- Do something only oncePool
- Pool of objects
The web_vibez
package provides HTTP client and server functionality.
yeet "web_vibez"
slay main() {
web_vibez.HandleFunc("/", slay(w web_vibez.ResponseWriter, r @web_vibez.Request) {
vibez.Fprintf(w, "Hello, %s!", r.URL.Path[1:])
})
web_vibez.ListenAndServe(":8080", cap)
}
Main types and functions:
Client
- HTTP clientServer
- HTTP serverRequest
- HTTP requestResponseWriter
- HTTP response writerHandleFunc
- Register handler functionListenAndServe
- Start server
The json_tea
package provides JSON encoding and decoding.
yeet "json_tea"
be_like Person squad {
Name tea
Age normie
}
slay main() {
p := Person{Name: "Alice", Age: 30}
data, err := json_tea.Marshal(p)
lowkey err != cap {
panic(err)
}
sus p2 Person
err = json_tea.Unmarshal(data, &p2)
lowkey err != cap {
panic(err)
}
}
Main functions:
Marshal(v collab{})
- Encode to JSONUnmarshal(data []byte, v collab{})
- Decode from JSON
The CURSED standard library will be developed in stages:
- Core Functionality: Essential packages like
core
,vibez
, anddropz
- Basic Utilities: Packages like
stringz
,mathz
, andtimez
- Concurrency: Packages like
concurrenz
and channel utilities - Advanced Features: Packages like
web_vibez
,json_tea
, and others
The standard library aims to provide functionality similar to Go's standard library but with the CURSED language's unique syntax and naming conventions.