Choosing a Language
In many fields of programming, the choice of language is quite open... even interpreted languages are often acceptable!
But with voxels? Let's do a quick exercise, shall we...
The Scaling Problem
- Grab a calculator (we ain't monsters here)!
- Think of how far into the distance you want to 'see', in meters/voxels.
- Type that number into the calculator.
- Double the number once.
- Multiply the number, by itself, twice.
- Look at the result.
- Try this again, from step 2, with some other numbers...
Alternatively, you can use the formula
D is the initial number from step 2.
Unless you keep the range of the active volume very small (on the order of
256³), you will quickly realize that there is a scaling problem: Increasing the size of the volume will consume cubically more and more memory, making computations horrendously expensive.
Requirements for performant Voxels
As such, there are some rather strong requirements when choosing a language:
- Tightly packing data, via structs and continuous arrays.
- Processing large arrays/lists of numbers at bare-metal speed.
- Creation of complex, nested, but performant, data-structures.
- No copying or cloning of data unless requested.
- Access to graphics hardware acceleration.
This effectively cuts out all languages that are interpreted1 instead of compiled; unless you are fine with a very small volume size, using these languages is not recommended for anything but higher level scripts.
While Chunking and various acceleration structures go a long way to alleviate the issues posed by interpreted and JIT'd languages, you will eventually need the ability to manage memory on both fine and large scales.
Unfortunately, all this restricts your choices to system-level languages, such as
For this guide we will be using basic
Rust; you do not need to know how lifetimes work, for now.
Storing Voxels In Memory!
Languages that are executed "from source code", such as
Just-In-Time Compiled, such as
'Normal' or 'Natural', see https://en.wiktionary.org/wiki/idiomatic.