Default Metaprogram

Metaprogramming can be used to do many things, such as arbitrary code and correctness checking, auto-generating code to place into one’s program, etc. Behind the scenes, the compiler internally runs another metaprogram at startup to compile the first workspace. This default metaprogram does things such as setting up the working directory for the compiler, setting the default name of the output executable based on command-line arguments, and changing between debug and release build based on command-line arguments.

This default metaprogram can be changed by adding -meta followed by the file name of the metaprogram to replace the default. Here is an example for how to change the default metaprogram:

jai -meta Verbose_Metaprogram my_file.jai

Jai does not operate like most other compilers that use a series of wacky command-line arguments in order to specify the program. Rather, Jai uses a metaprogram that does a compiler message loop to specify flags for the compiler. The flags are given to you as a struct. Here are a few helpful commandline arguments that can be useful when you are still programming at an ad hoc stage and do not want to write a formal metaprogram:

jai main.jai -x64     // compiles the program with the fast x64 backend
jai main.jai -llvm    // compiles the program with the llvm backend
jai main.jai -debug   // compiles the program in debug mode w/ llvm backend
jai main.jai -release // compiles the program in release mode w/ llvm backend -O2