Oxide is a clean, expressive scripting language built for the modern developer. Whether you're transforming data, automating workflows, building APIs, or exploring time-based events, Oxide empowers you with elegant syntax and a practical standard library—designed to make complex operations feel intuitive.
- Why Choose Oxide?
- What Can You Do with Oxide?
- Who Is Oxide For?
- Getting Started
- Operators
- Core/Language examples
- Platform examples
Write less, do more. Concise expressions, intuitive chaining, and minimal boilerplate make Oxide a joy to use.
Built-in modules like cal
, io
, math
, str
, www
, and more cover the essentials—without reaching for external libraries.
Use :::
to build seamless transformation pipelines—perfect for chaining, mapping, filtering, and data shaping.
Call an API, parse the response, and persist results—in a single line of code.
Inspired by functional programming, Oxide is readable, predictable, and powerful enough for real-world use without excess noise.
GET https://api.example.com/users
use arrays
users = [ { name: 'Tom' }, { name: 'Sara' } ]
names = users:::map(u -> u::name)
use cal, durations
cal::plus(now(), 30:::days())
use arrays
let arr = [1, 2, 3, 4]
arr:::filter(x -> (x % 2) == 0):::map(x -> x * 10)
- Data Engineers & Analysts — quick scripting for time and table-based operations.
- Web Developers — seamless API interactions and response transformations.
- Scripters & Hackers — ideal for automation, file operations, and glue code.
- Language Enthusiasts — a functional-style pipeline DSL with just enough structure.
cargo build --release
Artifacts will be in ./target/release/
:
oxide
– Oxide REPL / Server
cargo test
🔬 Over 800 tests (and counting) ensure Oxide's reliability and edge-case coverage.
The remainder of this document showcases categorized usage examples across Oxide's standard modules including:
arrays
,cal
,durations
,io
,math
,os
,oxide
,str
,tools
,util
, andwww
.
To improve navigation, consider splitting the examples into separate markdown files or auto-generating docs from code annotations using a tool like mdBook
, Docusaurus
, or a custom Rust doc generator.
Oxide provides a rich set of binary operators for arithmetic, logic, assignment, comparison, bitwise manipulation, and expressive data flow. This document summarizes the available operators and their intended semantics.
Operator | Meaning |
---|---|
+ |
Addition |
++ |
Concatenation or Join |
- |
Subtraction |
* , × |
Multiplication |
/ , ÷ |
Division |
% |
Modulo |
** |
Power (Exponentiation) |
Operator | Meaning |
---|---|
= |
Assign variable |
+= |
Add and assign |
-= |
Subtract and assign |
*= |
Multiply and assign |
/= |
Divide and assign |
%= |
Modulo and assign |
&= |
Bitwise AND and assign |
⎜= |
Bitwise OR and assign |
^= |
Bitwise XOR and assign |
?= |
Coalesce and assign |
&&= |
Logical AND and assign |
⎜⎜= |
Logical OR and assign |
:= |
Declare and assign expression |
Operator | Meaning |
---|---|
& |
Bitwise AND |
⎜ |
Bitwise OR |
^ |
Bitwise XOR |
<< |
Shift Left |
>> |
Shift Right |
Operator | Meaning |
---|---|
== , is |
Equal |
!= , isnt |
Not Equal |
> |
Greater Than |
>= |
Greater Than or Equal |
< |
Less Than |
<= |
Less Than or Equal |
in |
Value is in Range or Set |
like |
SQL-style pattern match |
matches |
Regular Expression match |
&& |
Logical AND |
⎜⎜ |
Logical OR |
? |
Null⎜Undefined Coalescing |
Operator | Meaning / Use Case |
---|---|
: |
Alias (value name alias) |
:: |
Namespacing or qualified access |
::: |
Extended namespacing or chaining |
<~ |
Curvy arrow (left) |
~> |
Curvy arrow (right) |
-> |
Function application |
.. |
Exclusive Range (a..b ) |
..= |
Inclusive Range (a..=b ) |
Operator | Meaning / Use Case |
---|---|
⎜> |
Pipe Forward (`val |
⎜>> |
Double Pipe Forward (custom logic) |
name: 'Tom'
"Tom"
tools::to_table({ name: 'Tom' })
|-----------| | id | name | |-----------| | 0 | Tom | |-----------|
// Arrays can be defined via ranges1..7
[1, 2, 3, 4, 5, 6]
// Arrays can be created using literals[1, 4, 2, 8, 5, 7]
[1, 4, 2, 8, 5, 7]
// Arrays may be destructured to assign multiple variableslet [a, b, c] = [3, 5, 7] a + b + c
15
// Arrays can be transformed via the 'arrays' packagearrays::reverse([1, 4, 2, 8, 5, 7])
[7, 5, 8, 2, 4, 1]
let arr = [1, 4, 2, 8, 5, 7] arr[3]
8
// Use ":=" to simultaneously assign a value and return the assigned valuelet i = 0 while (i < 5) yield (i := i + 1) * 3
[3, 6, 9, 12, 15]
let a = 3 let b = 5 let c = 7 a + b + c
15
0b1111 & 0b0101
5
0b1010 | 0b0101
15
20 << 3
160
20 >> 3
2
0b1111 ^ 0b0101
10
"Hello" ? "it was null or undefined"
"Hello"
null ? "it was null or undefined"
"it was null or undefined"
undefined ? "it was null or undefined"
"it was null or undefined"
"No problem" !? "An error occurred"
"No problem"
(throw "Boom!") !? "An error occurred"
"An error occurred"
result = { let (a, b) = (5, 9) a + b } result
14
let x = 10 x in 5..=10
true
let x = 10 x in 5..10
false
let x = 1..8 x contains 7
true
stocks = nsd::save( "expressions.read_next_row.stocks", Table::new(symbol: String(8), exchange: String(8), history: Table(last_sale: f64, processed_time: Date)) ) rows = [{ symbol: "BIZ", exchange: "NYSE" }, { symbol: "GOTO", exchange: "OTC" }] rows ~> stocks // read the last row last_row <~ stocks last_row
{"exchange":"OTC","history":[],"symbol":"GOTO"}
stocks = nsd::save( "expressions.into.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) rows = [ { symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 } ] rows ~> stocks
3
let i = 0 do { i = i + 1 yield i * 2 } while (i < 5)
[2, 4, 6, 8, 10]
use tools::reverse result = 'Hello' |> reverse result
"olleH"
// arrays, tuples and structures can be deconstructed into argumentsfn add(a, b) -> a + b fn inverse(a) -> 1.0 / a result = (2, 3) |>> add |> inverse result
0.2
stocks = nsd::save( "readme.www.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) www::serve(8855)
true
POST { url: http://localhost:8855/readme/www/stocks/0 body: { symbol: "ABC", exchange: "AMEX", last_sale: 11.77 } }
0
GET http://localhost:8855/readme/www/stocks/0
{exchange: "AMEX", last_sale: 11.77, symbol: "ABC"}
HEAD http://localhost:8855/readme/www/stocks/0
{content-length: "80", content-type: "application/json", date: "Sun, 15 Jun 2025 01:45:57 GMT"}
PUT { url: http://localhost:8855/readme/www/stocks/0 body: { symbol: "ABC", exchange: "AMEX", last_sale: 11.79 } }
1
GET http://localhost:8855/readme/www/stocks/0
{exchange: "AMEX", last_sale: 11.79, symbol: "ABC"}
PATCH { url: http://localhost:8855/readme/www/stocks/0 body: { last_sale: 11.81 } }
1
GET http://localhost:8855/readme/www/stocks/0
{exchange: "AMEX", last_sale: 11.81, symbol: "ABC"}
DELETE http://localhost:8855/readme/www/stocks/0
1
GET http://localhost:8855/readme/www/stocks/0
{}
// Oxide provides an if-else statementlet x = 4 if(x > 5) "Yes" else if(x < 5) "Maybe" else "No"
"Maybe"
// Oxide also provides if - a ternary-operator-like if functionfact = n -> if(n <= 1, 1, n * fact(n - 1)) fact(6)
720
use durations 8:::hours()
28800000
use tools stocks = to_table([ { symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 } ]) stocks
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | ABC | AMEX | 12.49 | | 1 | BOOM | NYSE | 56.88 | | 2 | JET | NASDAQ | 32.12 | |------------------------------------|
let stock = { symbol: "TED", exchange: "AMEX", last_sale: 13.37 } stock.last_sale
13.37
for row in tools::to_table(['apple', 'berry', 'kiwi', 'lime']) yield row::value
["apple", "berry", "kiwi", "lime"]
let code = 100 match code { 100 => "Accepted" n when n in 101..=104 => "Escalated" n when n < 100 => "Pending" n => "Rejected" }
"Accepted"
let code = 101 match code { 100 => "Accepted" n when n in 101..=104 => "Escalated" n when n < 100 => "Pending" n => "Rejected" }
"Escalated"
let code = 99 match code { 100 => "Accepted" n when n in 101..=104 => "Escalated" n when n < 100 => "Pending" n => "Rejected" }
"Pending"
let code = 110 match code { 100 => "Accepted" n when n in 101..=104 => "Escalated" n when n < 100 => "Pending" n => "Rejected" }
"Rejected"
5 + 6
11
20.0 / 3
6.666666666666667
5 * 6
30
188 - 36
152
tools::to_table([ 'apple', 'berry', 'kiwi', 'lime' ])
|------------| | id | value | |------------| | 0 | apple | | 1 | berry | | 2 | kiwi | | 3 | lime | |------------|
let i = 75 let j = -i j
-75
// Ranges may be exclusiverange = 1..5 tools::reverse(range)
[4, 3, 2, 1]
// Ranges may be inclusiverange = 1..=5 tools::reverse(range)
[5, 4, 3, 2, 1]
Feature "Matches function" { Scenario "Compare Array contents: Equal" { assert( [ 1 "a" "b" "c" ] matches [ 1 "a" "b" "c" ] ) } Scenario "Compare Array contents: Not Equal" { assert(!( [ 1 "a" "b" "c" ] matches [ 0 "x" "y" "z" ] )) } Scenario "Compare JSON contents (in sequence)" { assert( { first: "Tom" last: "Lane" } matches { first: "Tom" last: "Lane" } ) } Scenario "Compare JSON contents (out of sequence)" { assert( { scores: [82 78 99], id: "A1537" } matches { id: "A1537", scores: [82 78 99] } ) } }
|------------------------------------------------------------------------------------------------------------------------| | id | level | item | passed | result | |------------------------------------------------------------------------------------------------------------------------| | 0 | 0 | Matches function | true | true | | 1 | 1 | Compare Array contents: Equal | true | true | | 2 | 2 | assert [1, "a", "b", "c"] matches [1, "a", "b", "c"] | true | true | | 3 | 1 | Compare Array contents: Not Equal | true | true | | 4 | 2 | assert !([1, "a", "b", "c"] matches [0, "x", "y", "z"]) | true | true | | 5 | 1 | Compare JSON contents (in sequence) | true | true | | 6 | 2 | assert {first: "Tom", last: "Lane"} matches {first: "Tom", last: "Lane"} | true | true | | 7 | 1 | Compare JSON contents (out of sequence) | true | true | | 8 | 2 | assert {scores: [82, 78, 99], id: "A1537"} matches {id: "A1537", scores: [82, 78, 99]} | true | true | |------------------------------------------------------------------------------------------------------------------------|
throw("this is an error")
this is an error
// Tuples may be destructured to assign multiple variables(a, b, c) = (3, 5, 7) a + b + c
15
// Tuples support additionlet a = (2, 4, 6) let b = (1, 2, 3) a + b
(3, 6, 9)
// Tuples support subtractionlet a = (3, 5, 7) let b = (1, 0, 1) a - b
(2, 5, 6)
// Tuples support negation-(3, 6, 9)
(-3, -6, -9)
// Tuples support multiplicationlet a = (3, 5, 7) let b = (1, 0, 1) a * b
(3, 0, 7)
// Tuples support divisionlet a = (3.0, 5.0, 9.0) let b = (1.0, 2.0, 1.0) a / b
(3, 2.5, 9)
// Tuples support moduluslet a = (3.0, 5.0, 9.0) let b = (1.0, 2.0, 1.0) a % b
(0.0, 1, 0.0)
// Tuples support exponentslet a = (2, 4, 6) let b = (1, 2, 3) a ** b
(2, 16, 216)
LabelString = typedef(String(80)) LabelString
String(80)
// Executes the block at the moment the condition becomes true. let (x, y) = (1, 0) whenever x == 0 { x = x + 1 y = y + 1 } x = x - 1 x + y
2
// The block will not be executed if the condition is already true. let (x, y) = (1, 0) whenever x == 0 || y == 0 { x = x + 1 y = y + 1 } x + y
1
// The block will be executed after the second assignment. let (x, y) = (1, 0) whenever x == 0 || y == 0 { x = x + 1 y = y + 1 } let (x, y) = (2, 3) x + y
5
let x = 0 while (x < 5) { x = x + 1 yield x * 2 }
[2, 4, 6, 8, 10]
for(i = 0, i < 5, i = i + 1) yield i * 2
[0, 2, 4, 6, 8]
arrays::filter(1..7, n -> (n % 2) == 0)
[2, 4, 6]
arrays::len([1, 5, 2, 4, 6, 0])
6
arrays::map([1, 2, 3], n -> n * 2)
[2, 4, 6]
use arrays stocks = [] stocks:::push({ symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }) stocks:::push({ symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }) stocks
[]
use arrays stocks = [ { symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 } ] stocks:::push({ symbol: "DEX", exchange: "OTC_BB", last_sale: 0.0086 }) tools::to_table(stocks)
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | ABC | AMEX | 12.49 | | 1 | BOOM | NYSE | 56.88 | | 2 | JET | NASDAQ | 32.12 | |------------------------------------|
arrays::reduce(1..=5, 0, (a, b) -> a + b)
15
use arrays::reduce numbers = [1, 2, 3, 4, 5] numbers:::reduce(0, (a, b) -> a + b)
15
arrays::reverse(['cat', 'dog', 'ferret', 'mouse'])
["mouse", "ferret", "dog", "cat"]
arrays::to_array(tools::to_table([ { symbol: "BIZ", exchange: "NYSE", last_sale: 23.66 }, { symbol: "DMX", exchange: "OTC_BB", last_sale: 1.17 } ]))
[{"exchange":"NYSE","last_sale":23.66,"symbol":"BIZ"}, {"exchange":"NYSE","last_sale":23.66,"symbol":"BIZ"}]
use cal now():::day_of()
14
use cal now():::hour12()
6
use cal now():::hour24()
18
use cal now():::minute_of()
46
use cal now():::month_of()
6
use cal now():::second_of()
0
use cal now():::year_of()
2025
use cal, durations cal::minus(now(), 3:::days())
1969-12-29T00:00:00.000Z
cal::now()
2025-06-15T01:46:00.219Z
use cal, durations cal::plus(now(), 30:::days())
1970-01-31T00:00:00.000Z
use durations 3:::days()
259200000
use durations 8:::hours()
28800000
use durations 8:::millis()
8
use durations 30:::minutes()
1800000
use durations 30:::seconds()
30000
io::create_file("quote.json", { symbol: "TRX", exchange: "NYSE", last_sale: 45.32 })
52
io::exists("quote.json")
true
use io, util file = "temp_secret.txt" file:::create_file(md5("**keep**this**secret**")) file:::read_text_file()
0v47338bd5f35bbb239092c36e30775b4a
io::stderr("Goodbye Cruel World")
true
io::stdout("Hello World")
true
math::abs(-81)
81
math::ceil(5.7)
6
math::floor(5.7)
5
math::max(81, 78)
81
math::min(81, 78)
78
math::pow(2, 3)
8
math::round(5.3)
5
math::sqrt(25)
5
nsd::create_event_src( "examples.event_src.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) )
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| |------------------------------------|
nsd::create_fn( "examples.table_fn.stocks", (symbol: String(8), exchange: String(8), last_sale: f64) -> { symbol: symbol, exchange: exchange, last_sale: last_sale * 2.0, event_time: cal::now() })
|-------------------------------------------------| | id | symbol | exchange | last_sale | event_time | |-------------------------------------------------| |-------------------------------------------------|
nsd::save('packages.remove.stocks', Table::new( symbol: String(8), exchange: String(8), last_sale: f64 ))nsd::drop('packages.remove.stocks') nsd::exists('packages.remove.stocks')
false
nsd::save('packages.exists.stocks', Table::new( symbol: String(8), exchange: String(8), last_sale: f64 )) nsd::exists("packages.exists.stocks")
true
nsd::exists("packages.not_exists.stocks")
false
use nsd nsd::drop("examples.journal.stocks"); stocks = nsd::create_fn( "examples.journal.stocks", (symbol: String(8), exchange: String(8), last_sale: f64) -> { symbol: symbol, exchange: exchange, last_sale: last_sale * 2.0, ingest_time: cal::now() }); [{ symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 }] ~> stocks stocks:::journal()
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | ABC | AMEX | 12.49 | | 1 | BOOM | NYSE | 56.88 | | 2 | JET | NASDAQ | 32.12 | |------------------------------------|
let stocks = nsd::save('packages.save_load.stocks', Table::new( symbol: String(8), exchange: String(8), last_sale: f64 ))let rows = [{ symbol: "CAZ", exchange: "AMEX", last_sale: 65.13 }, { symbol: "BAL", exchange: "NYSE", last_sale: 82.78 }, { symbol: "RCE", exchange: "NASDAQ", last_sale: 124.09 }]
rows ~> stocks
nsd::load('packages.save_load.stocks')
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | CAZ | AMEX | 65.13 | | 1 | BAL | NYSE | 82.78 | | 2 | RCE | NASDAQ | 124.09 | |------------------------------------|
use nsd nsd::drop("examples.replay.stocks"); stocks = nsd::create_fn( "examples.replay.stocks", (symbol: String(8), exchange: String(8), last_sale: f64) -> { symbol: symbol, exchange: exchange, last_sale: last_sale * 2.0, rank: __row_id__ + 1 }); [{ symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 }] ~> stocks stocks:::replay()
3
use nsd let stocks = nsd::save('packages.resize.stocks', Table::new( symbol: String(8), exchange: String(8), last_sale: f64 )) [{ symbol: "TCO", exchange: "NYSE", last_sale: 38.53 }, { symbol: "SHMN", exchange: "NYSE", last_sale: 6.57 }, { symbol: "HMU", exchange: "NASDAQ", last_sale: 27.12 }] ~> stocks 'packages.resize.stocks':::resize(1) stocks
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | TCO | NYSE | 38.53 | |------------------------------------|
let stocks = nsd::save('packages.save.stocks', Table::new( symbol: String(8), exchange: String(8), last_sale: f64 )) [{ symbol: "TCO", exchange: "NYSE", last_sale: 38.53 }, { symbol: "SHMN", exchange: "NYSE", last_sale: 6.57 }, { symbol: "HMU", exchange: "NASDAQ", last_sale: 27.12 }] ~> stocks stocks
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | TCO | NYSE | 38.53 | | 1 | SHMN | NYSE | 6.57 | | 2 | HMU | NASDAQ | 27.12 | |------------------------------------|
stocks = nsd::save( "examples.os.call", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) os::call("chmod", "777", oxide::home())
os::clear()
true
use str cur_dir = os::current_dir() prefix = if(cur_dir:::ends_with("core"), "../..", ".") path_str = prefix + "/demoes/language/include_file.oxide" include path_str
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | ABC | AMEX | 12.49 | | 1 | BOOM | NYSE | 56.88 | | 2 | JET | NASDAQ | 32.12 | |------------------------------------|
os::env()
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | id | key | value | |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 0 | BUN_INSTALL | /Users/ldaniels/.bun | | 1 | CARGO | /Users/ldaniels/.rustup/toolchains/stable-aarch64-apple-darwin/bin/cargo 10000 | | 2 | CARGO_HOME | /Users/ldaniels/.cargo | | 3 | CARGO_MANIFEST_DIR | /Users/ldaniels/GitHub/oxide/src/core | | 4 | CARGO_MANIFEST_PATH | /Users/ldaniels/GitHub/oxide/src/core/Cargo.toml | | 5 | CARGO_PKG_AUTHORS | | | 6 | CARGO_PKG_DESCRIPTION | | | 7 | CARGO_PKG_HOMEPAGE | | | 8 | CARGO_PKG_LICENSE | | | 9 | CARGO_PKG_LICENSE_FILE | | | 10 | CARGO_PKG_NAME | core | | 11 | CARGO_PKG_README | | | 12 | CARGO_PKG_REPOSITORY | | | 13 | CARGO_PKG_RUST_VERSION | | | 14 | CARGO_PKG_VERSION | 0.1.0 | | 15 | CARGO_PKG_VERSION_MAJOR | 0 | | 16 | CARGO_PKG_VERSION_MINOR | 1 | | 17 | CARGO_PKG_VERSION_PATCH | 0 | | 18 | CARGO_PKG_VERSION_PRE | | | 19 | COMMAND_MODE | unix2003 | | 20 | DYLD_FALLBACK_LIBRARY_PATH | /Users/ldaniels/GitHub/oxide/target/debug/build/curl-sys-976ef1fd41b2ae67/out/build:/Users/ldaniels/GitHub/oxide/target/debug/build/libnghttp2-sys-03d0e22189823925/out/i/lib:/Users/ldaniels/GitHub/oxide/target/debug/build/zstd-sys-b2743e594d963e4d/out:/Users/ldaniels/GitHub/oxide/target/debug/deps:/Users/ldaniels/GitHub/oxide/target/debug:/Users/ldaniels/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib:/Users/ldaniels/.rustup/toolchains/stable-aarch64-apple-darwin/lib:/Users/ldaniels/lib:/usr/local/lib:/usr/lib | | 21 | HOME | /Users/ldaniels | | 22 | JAVA_HOME | /Users/ldaniels/.sdkman/candidates/java/current | | 23 | LC_CTYPE | en_US.UTF-8 | | 24 | LOGNAME | ldaniels | | 25 | OLDPWD | / | | 26 | PATH | /Users/ldaniels/.bun/bin:/Users/ldaniels/.sdkman/candidates/java/current/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/ldaniels/.cargo/bin:/opt/homebrew/bin:. | | 27 | PWD | /Users/ldaniels/GitHub/oxide | | 28 | RR_REAL_RUSTDOC | /Users/ldaniels/.cargo/bin/rustdoc | | 29 | RUSTC | /Users/ldaniels/.cargo/bin/rustc | | 30 | RUSTC_BOOTSTRAP | 1 | | 31 | RUSTDOC | /Users/ldaniels/Library/Application Support/JetBrains/IntelliJIdea2025.1/plugins/intellij-rust/bin/mac/aarch64/intellij-rust-native-helper | | 32 | RUSTUP_HOME | /Users/ldaniels/.rustup | | 33 | RUSTUP_TOOLCHAIN | stable-aarch64-apple-darwin | | 34 | RUST_BACKTRACE | short | | 35 | RUST_RECURSION_COUNT | 1 | | 36 | SDKMAN_CANDIDATES_API | https://api.sdkman.io/2 | | 37 | SDKMAN_CANDIDATES_DIR | /Users/ldaniels/.sdkman/candidates | | 38 | SDKMAN_DIR | /Users/ldaniels/.sdkman | | 39 | SDKMAN_PLATFORM | darwinarm64 | | 40 | SHELL | /bin/zsh | | 41 | SSH_AUTH_SOCK | /private/tmp/com.apple.launchd.lSmiPPAhaN/Listeners | | 42 | TERM | ansi | | 43 | TMPDIR | /var/folders/ld/hwrvzn011w79gftyb6vj8mg40000gn/T/ | | 44 | USER | ldaniels | | 45 | XPC_FLAGS | 0x0 | | 46 | XPC_SERVICE_NAME | application.com.jetbrains.intellij.505803.110144030 | | 47 | __CFBundleIdentifier | com.jetbrains.intellij | | 48 | __CF_USER_TEXT_ENCODING | 0x1F5:0x0:0x0 | |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
code = oxide::compile("2 ** 4") code()
16
oxide::debug("2 ** 4")
Ok(Pow(Literal(Number(I64Value(2))), Literal(Number(I64Value(4)))))
a = 'Hello ' b = 'World' oxide::eval("a + b")
Hello World
oxide::help() limit 3
|-------------------------------------------------------------------------------------------------------| | id | name | module | signature | description | returns | |-------------------------------------------------------------------------------------------------------| | 0 | version | oxide | oxide::version() | Returns the Oxide version | f64 | | 1 | uuid | oxide | oxide::uuid() | Returns a random 128-bit UUID | u128 | | 2 | sprintf | oxide | oxide::sprintf(a: String, b: Array) | C-style "sprintf" function | String | |-------------------------------------------------------------------------------------------------------|
oxide::home()
/Users/ldaniels/oxide_db
oxide::inspect("{ x = 1 x = x + 1 }")
|-------------------------------------------------------------------------------------------------| | id | code | model | |-------------------------------------------------------------------------------------------------| | 0 | x = 1 | SetVariables(Variable("x"), Literal(Number(I64Value(1)))) | | 1 | x = x + 1 | SetVariables(Variable("x"), Plus(Variable("x"), Literal(Number(I64Value(1))))) | |-------------------------------------------------------------------------------------------------|
oxide::inspect("stock::is_this_you('ABC')")
|---------------------------------------------------------------------------------------------------------------------------------------------------| | id | code | model | |---------------------------------------------------------------------------------------------------------------------------------------------------| | 0 | stock::is_this_you("ABC") | ColonColon(Variable("stock"), FunctionCall { fx: Variable("is_this_you"), args: [Literal(StringValue("ABC"))] }) | |---------------------------------------------------------------------------------------------------------------------------------------------------|
oxide::printf("Hello %s", "World")
true
oxide::println("Hello World")
true
oxide::reset()
true
oxide::sprintf("Hello %s", "World")
Hello World
oxide::uuid()
fc9c5137-e246-4679-8ee5-53637ccc7992
oxide::version()
0.44
str::ends_with('Hello World', 'World')
true
str::format("This {} the {}", "is", "way")
This is the way
str::index_of('The little brown fox', 'brown')
11
str::join(['1', 5, 9, '13'], ', ')
1, 5, 9, 13
str::left('Hello World', 5)
Hello
str::len('The little brown fox')
20
str::right('Hello World', 5)
World
str::split('Hello,there World', ' ,')
["Hello", "there", "World"]
str::starts_with('Hello World', 'World')
false
📦 str::strip_margin — Returns the string with all characters on each line are striped up to the margin character
str::strip_margin(" |Code example: | |stocks |where exchange is 'NYSE' ", '|')
Code example:
stocks where exchange is 'NYSE'
str::substring('Hello World', 0, 5)
Hello
str::superscript(5)
⁵
str::to_string(125.75)
125.75
stocks = nsd::save( "examples.compact.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "DMX", exchange: "NYSE", last_sale: 99.99 }, { symbol: "UNO", exchange: "OTC", last_sale: 0.2456 }, { symbol: "BIZ", exchange: "NYSE", last_sale: 23.66 }, { symbol: "GOTO", exchange: "OTC", last_sale: 0.1428 }, { symbol: "ABC", exchange: "AMEX", last_sale: 11.11 }, { symbol: "BOOM", exchange: "NASDAQ", last_sale: 0.0872 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 }] ~> stocks delete stocks where last_sale > 1.0 stocks
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 1 | UNO | OTC | 0.2456 | | 3 | GOTO | OTC | 0.1428 | | 5 | BOOM | NASDAQ | 0.0872 | |------------------------------------|
tools::describe({ symbol: "BIZ", exchange: "NYSE", last_sale: 23.66 })
|----------------------------------------------------------| | id | name | type | default_value | is_nullable | |----------------------------------------------------------| | 0 | symbol | String(3) | BIZ | true | | 1 | exchange | String(4) | NYSE | true | | 2 | last_sale | f64 | 23.66 | true | |----------------------------------------------------------|
stocks = |--------------------------------------| | symbol | exchange | last_sale | rank | |--------------------------------------| | BOOM | NYSE | 113.76 | 1 | | ABC | AMEX | 24.98 | 2 | | JET | NASDAQ | 64.24 | 3 | |--------------------------------------| tools::describe(stocks)
|----------------------------------------------------------| | id | name | type | default_value | is_nullable | |----------------------------------------------------------| | 0 | symbol | String(4) | null | true | | 1 | exchange | String(6) | null | true | | 2 | last_sale | f64 | null | true | | 3 | rank | i64 | null | true | |----------------------------------------------------------|
stocks = nsd::save( "examples.fetch.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 }] ~> stocks tools::fetch(stocks, 2)
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 2 | JET | NASDAQ | 32.12 | |------------------------------------|
tools::filter(1..11, n -> (n % 2) == 0)
[2, 4, 6, 8, 10]
stocks = nsd::save( "examples.table_len.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "WKRP", exchange: "NYSE", last_sale: 11.11 }, { symbol: "ACDC", exchange: "AMEX", last_sale: 35.11 }, { symbol: "UELO", exchange: "NYSE", last_sale: 90.12 }] ~> stocks tools::len(stocks)
3
stocks = nsd::save( "examples.map_over_table.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "WKRP", exchange: "NYSE", last_sale: 11.11 }, { symbol: "ACDC", exchange: "AMEX", last_sale: 35.11 }, { symbol: "UELO", exchange: "NYSE", last_sale: 90.12 }] ~> stocks use tools stocks:::map(row -> { symbol: symbol, exchange: exchange, last_sale: last_sale, processed_time: cal::now() })
|---------------------------------------------------------------| | id | symbol | exchange | last_sale | processed_time | |---------------------------------------------------------------| | 0 | WKRP | NYSE | 11.11 | 2025-06-15T01:46:03.978Z | | 1 | ACDC | AMEX | 35.11 | 2025-06-15T01:46:03.979Z | | 2 | UELO | NYSE | 90.12 | 2025-06-15T01:46:03.980Z | |---------------------------------------------------------------|
use tools stocks = nsd::save( "examples.tools_pop.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 }] ~> stocks stocks:::pop()
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 2 | JET | NASDAQ | 32.12 | |------------------------------------|
use tools stocks = nsd::save( "examples.tools_push.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "BOOM", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 }] ~> stocks stocks:::push({ symbol: "XYZ", exchange: "NASDAQ", last_sale: 24.78 }) stocks
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | ABC | AMEX | 12.49 | | 1 | BOOM | NYSE | 56.88 | | 2 | JET | NASDAQ | 32.12 | | 3 | XYZ | NASDAQ | 24.78 | |------------------------------------|
use tools to_table(reverse( ['cat', 'dog', 'ferret', 'mouse'] ))
|-------------| | id | value | |-------------| | 0 | mouse | | 1 | ferret | | 2 | dog | | 3 | cat | |-------------|
tools::row_id()
0
use tools stocks = nsd::save( "examples.scan.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "ABC", exchange: "AMEX", last_sale: 12.33 }, { symbol: "UNO", exchange: "OTC", last_sale: 0.2456 }, { symbol: "BIZ", exchange: "NYSE", last_sale: 9.775 }, { symbol: "GOTO", exchange: "OTC", last_sale: 0.1442 }, { symbol: "XYZ", exchange: "NYSE", last_sale: 0.0289 }] ~> stocks delete stocks where last_sale > 1.0 stocks:::scan()
|------------------------------------| | id | symbol | exchange | last_sale | |------------------------------------| | 0 | ABC | AMEX | 12.33 | | 1 | UNO | OTC | 0.2456 | | 2 | BIZ | NYSE | 9.775 | | 3 | GOTO | OTC | 0.1442 | | 4 | XYZ | NYSE | 0.0289 | |------------------------------------|
tools::to_array("Hello")
["H", "e", "l", "l", "o"]
use tools::to_csv stocks = nsd::save( "examples.csv.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "ABC", exchange: "AMEX", last_sale: 11.11 }, { symbol: "UNO", exchange: "OTC", last_sale: 0.2456 }, { symbol: "BIZ", exchange: "NYSE", last_sale: 23.66 }, { symbol: "GOTO", exchange: "OTC", last_sale: 0.1428 }, { symbol: "BOOM", exchange: "NASDAQ", last_sale: 0.0872 }] ~> stocks stocks:::to_csv()
[""ABC","AMEX",11.11", ""UNO","OTC",0.2456", ""BIZ","NYSE",23.66", ""GOTO","OTC",0.1428", ""BOOM","NASDAQ",0.0872"]
use tools::to_json stocks = nsd::save( "examples.json.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "ABC", exchange: "AMEX", last_sale: 11.11 }, { symbol: "UNO", exchange: "OTC", last_sale: 0.2456 }, { symbol: "BIZ", exchange: "NYSE", last_sale: 23.66 }, { symbol: "GOTO", exchange: "OTC", last_sale: 0.1428 }, { symbol: "BOOM", exchange: "NASDAQ", last_sale: 0.0872 }] ~> stocks stocks:::to_json()
["{"symbol":"ABC","exchange":"AMEX","last_sale":11.11}", "{"symbol":"UNO","exchange":"OTC","last_sale":0.2456}", "{"symbol":"BIZ","exchange":"NYSE","last_sale":23.66}", "{"symbol":"GOTO","exchange":"OTC","last_sale":0.1428}", "{"symbol":"BOOM","exchange":"NASDAQ","last_sale":0.0872}"]
tools::to_table(['cat', 'dog', 'ferret', 'mouse'])
|-------------| | id | value | |-------------| | 0 | cat | | 1 | dog | | 2 | ferret | | 3 | mouse | |-------------|
util::base64('Hello World')
SGVsbG8gV29ybGQ=
util::to_binary(0b1011 & 0b1101)
1001
util::gzip('Hello World')
0v1f8b08000000000000fff348cdc9c95708cf2fca49010056b1174a0b000000
util::gunzip(util::gzip('Hello World'))
0v48656c6c6f20576f726c64
util::hex('Hello World')
48656c6c6f20576f726c64
util::md5('Hello World')
0vb10a8db164e0754105b7a99be72e3fe5
util::to(1376438453123, Date)
2013-08-14T00:00:53.123Z
util::to_ascii(177)
±
util::to_date(177)
1970-01-01T00:00:00.177Z
util::to_f64(4321)
4321
util::to_i64(88)
88
util::to_i128(88)
88
util::to_u128(88)
88
www::url_decode('http%3A%2F%2Fshocktrade.com%3Fname%3Dthe%20hero%26t%3D9998')
http://shocktrade.com?name=the hero&t=9998
www::url_encode('http://shocktrade.com?name=the hero&t=9998')
http%3A%2F%2Fshocktrade.com%3Fname%3Dthe%20hero%26t%3D9998
www::serve(8787) stocks = nsd::save( "examples.www.stocks", Table::new(symbol: String(8), exchange: String(8), last_sale: f64) ) [{ symbol: "XINU", exchange: "NYSE", last_sale: 8.11 }, { symbol: "BOX", exchange: "NYSE", last_sale: 56.88 }, { symbol: "JET", exchange: "NASDAQ", last_sale: 32.12 }, { symbol: "ABC", exchange: "AMEX", last_sale: 12.49 }, { symbol: "MIU", exchange: "OTCBB", last_sale: 2.24 }] ~> stocks GET http://localhost:8787/examples/www/stocks/1/4
[{"exchange":"NYSE","last_sale":56.88,"symbol":"BOX"}, {"exchange":"NASDAQ","last_sale":32.12,"symbol":"JET"}, {"exchange":"AMEX","last_sale":12.49,"symbol":"ABC"}]