Chapter 7: Building & Projects - From Blueprint to Reality

Single-File Compilation

For simple scripts, you can compile a single file directly.

python redline.py build my_script.rl

Multi-File Projects with RedConfig.toml

For any real project, you'll want a RedConfig.toml file. This is the master blueprint for your project. It tells the compiler everything it needs to know.

[project]
name = "MyAwesomeProject"
version = "1.0.0"
entry_point = "src/main.rl"
output_dir = "bin"

With this file in your project's root directory, the build script will automatically use it.

# Run from your project's root directory
python path/to/redline.py build

Chapter 8: The Philosophy - How It All Works

So, how does the magic happen? It's not magic, it's efficient science.

The Transpilation Pipeline: RL β†’ C++ β†’ Executable

When you run redline build, a three-stage process kicks off:

  1. Parsing (Rust): Our high-speed Rust core reads your .rl files, validates the syntax, and builds an Abstract Syntax Tree (AST)β€”an internal representation of your code.
  2. Code Generation (Rust): The core then walks the AST and generates clean, human-readable C++17 code.
  3. Compilation (C++): Finally, we hand that generated code off to your system's G++ compiler, which creates a highly-optimized, native executable.

Why C++ is the Target

Simple: performance and ecosystem. C++ is one of the fastest languages on the planet, and by compiling to it, we get that speed for free. We also get to tap into decades of C++ libraries and tools.

Why Rust is the Core

The compiler itself needs to be fast, safe, and reliable. Rust's focus on memory safety and performance makes it the perfect tool for building a rock-solid compiler that won't crash while it's processing your genius ideas. This means fewer bugs in our tools, so you can focus on the bugs in your own brilliant, world-changing experiments.