Installation

Let's get Oxide set up on your computer! We'll install the necessary tools to compile and run Oxide programs.

What is Oxide?

Oxide is an alternative syntax for Rust that compiles to identical binary output via a rustc fork. If you're coming from Swift, Kotlin, TypeScript, or C#, Oxide's syntax will feel familiar while giving you access to Rust's powerful safety guarantees and performance.

Key points about Oxide:

  • Rust with familiar syntax: Oxide uses Swift/Kotlin-inspired conventions as an alternative to Rust's conventions
  • 100% compatible with Rust: Both .ox files (Oxide) and .rs files (Rust) can coexist in the same project
  • Same performance: Oxide compiles to the exact same machine code as Rust—zero runtime overhead
  • All of Rust's power: You get ownership, borrowing, the type system, traits, generics, and everything else that makes Rust safe

Let's look at a quick example of what Oxide looks like:

// Oxide: familiar and readable
fn greet(name: str): String {
    "Hello, \(name)!"
}

Compared to equivalent Rust:

#![allow(unused)]
fn main() {
// Rust: using Rust's conventions
fn greet(name: &str) -> String {
    format!("Hello, {}", name)
}
}

Both compile to identical code. The difference is the syntax.

Prerequisites

Before installing Oxide, you'll need:

  1. Rust toolchain - The Rust compiler (rustc), Cargo package manager, and Rust standard library
  2. A text editor or IDE - Any editor works; VS Code with Rust Analyzer is recommended
  3. A terminal - Oxide development happens on the command line

Since Oxide compiles via a rustc fork, having the standard Rust toolchain installed is essential, even though you'll primarily use Oxide syntax.

Installation

Step 1: Install Rust

First, install Rust using rustup. Open your terminal and run:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

This downloads and installs rustup, which manages your Rust toolchain. Follow the on-screen prompts.

On Windows, download and run rustup-init.exe from https://rustup.rs.

After installation, verify Rust is installed:

rustc --version
cargo --version

You should see version numbers for both.

Step 2: Install Oxide (Future Reference)

Note: The Oxide compiler is currently in development. This section describes how you'll install it once it's released.

Once available, you'll install the Oxide compiler via Cargo:

cargo install oxidec

This installs the oxidec command, which is the Oxide compiler. It's a wrapper around the rustc fork that handles .ox files transparently.

Verify the installation:

oxidec --version

You should see the Oxide compiler version.

For Now: Setting Up Your First Project

While the compiler is under development, you can explore Oxide syntax and concepts by:

  1. Reading this book and the examples
  2. Experimenting with the ideas in Rust code
  3. Preparing your workflow for when Oxide releases

Setting Up an Oxide Project

Creating a new Oxide project is straightforward using Cargo with the --oxide flag:

cargo new --oxide hello_oxide
cd hello_oxide

This creates an Oxide project with src/main.ox containing:

fn main() {
    println!("Hello, world!")
}

Development Status: Oxide v1.0 is currently in development. The Oxide compiler (a fork of rustc) and the --oxide flag for Cargo are being implemented and will be available when the Oxide toolchain is released. For early testing before the release, you can manually create a project with cargo new and rename src/main.rs to src/main.ox.

Here's what a basic project structure looks like:

hello_oxide/
├── Cargo.toml
└── src/
    ├── main.ox       # Your Oxide code
    └── lib.rs        # Optional: Rust library code (can coexist)

When you run cargo build or cargo run, Oxide files (.ox) and Rust files (.rs) work together seamlessly. Both compile to identical machine code.

Building and Running

Build and run your Oxide project:

cargo build
cargo run

The Oxide compiler processes your .ox files and compiles them via the rustc fork.

Troubleshooting

"command not found: oxidec"

Ensure you've installed the Oxide compiler with cargo install oxidec and that ~/.cargo/bin is in your PATH.

"Can't find Rust toolchain"

The Oxide compiler requires the Rust toolchain. Verify Rust is installed with rustc --version. If not, follow Step 1 above.

"Unknown file extension: .ox"

Make sure your file has the .ox extension (lowercase). Oxide files must use this specific extension to be recognized.

IDE/Editor support

If your editor doesn't recognize .ox files:

  • VS Code: Install the Oxide extension (coming soon)
  • Other editors: Configure them to treat .ox files as Rust for syntax highlighting until Oxide support is available

Moving Forward

You're now ready to start learning Oxide! The next chapter will guide you through writing your first program. Whether you're new to systems programming or transitioning from another language, Oxide provides syntax that may feel familiar while giving you access to Rust's excellent type system and safety guarantees.

If you get stuck, remember:

  • The examples in this book are all valid Oxide code
  • You can always reference the Rust equivalent to understand the underlying semantics
  • Rust's extensive ecosystem documentation applies directly to Oxide code
  • Both Oxide and Rust are valid choices—Oxide simply offers an alternative syntax

Happy coding!