Skip to main content

Getting Started

Oxide is an alternative syntax for Rust, designed to feel familiar to developers coming from Kotlin and Swift. It provides string interpolation, null safety operators, clean syntax without semicolons, and other syntax patterns from those languages while compiling to standard Rust.

Prerequisites

Installation

# Clone the repository
git clone https://github.com/izantech/oxide-lang.git
cd oxide-lang

# Build and install cargo-oxide
cargo install --path crates/cargo-oxide

Verify Installation

cargo oxide --version

Your First Oxide Program

Create a new Oxide project:

cargo oxide new hello-oxide
cd hello-oxide

This creates a project with the following structure:

hello-oxide/
├── Cargo.toml
├── src/
│ └── main.ox
└── .gitignore

Edit src/main.ox:

fn main() {
let name = "Oxide"
println!("Hello, $name!")

// Nullable types with safe operators
let value: Int? = 42
let doubled = value?.mapped { it * 2 } ?? 0
println!("Doubled: $doubled")

// Collection operations
let numbers = [1, 2, 3, 4, 5]
let evens = numbers.iter()
.filtered { it % 2 == 0 }
.toArray()
println!("Evens: #evens") // Debug format
}

Transpiles to:

fn main() {
let name = "Oxide";
println!("Hello, {}!", name);

let value: Option<isize> = Some(42);
let doubled = value.map(|it| it * 2).unwrap_or(0);
println!("Doubled: {}", doubled);

let numbers = vec![1, 2, 3, 4, 5];
let evens: Vec<_> = numbers.iter()
.filter(|it| *it % 2 == 0)
.collect();
println!("Evens: {:?}", evens);
}

Build and run:

cargo oxide build
cargo oxide run

Output:

Hello, Oxide!
Doubled: 84
Evens: [2, 4]

How It Works

The Oxide toolchain:

  1. Transpiles .ox files to .rs files
  2. Compiles using the standard Rust compiler
  3. Maps errors back to original Oxide source positions

This means you get:

  • Full Rust toolchain compatibility
  • Source maps for accurate error messages
  • Easy integration with existing Rust projects

Common Commands

cargo oxide build      # Transpile and build
cargo oxide run # Build and run
cargo oxide test # Run tests
cargo oxide check # Check for errors without building
cargo oxide watch # Auto-rebuild on changes
cargo oxide fmt # Format Oxide source files
cargo oxide doc # Generate documentation

Project Types

Create different project types:

cargo oxide new my-app         # Binary application
cargo oxide new --lib my-lib # Library

IDE Support

VS Code

Build and install the Oxide VS Code extension:

cd editors/vscode
npm install
npm run compile
# Press F5 in VS Code to launch with the extension

Features:

  • Syntax highlighting for .ox files
  • Autocomplete and hover documentation
  • Error diagnostics with Oxide source positions
  • cargo oxide commands integration

Next Steps