Native Executables
● Advanced3 minBefore this: The kavach Command
kavach build turns a program into one executable file of native machine code, about half a megabyte, that runs on its own.
fn main() {
print("Hello from a native program")
}kavach build hello.kav
./hello
The executable prints what the program prints. To compile to machine code and run at once, without writing a file:
kavach run --native hello.kav
Hello from a native program
- The runtime, memory, tasks and printing, is linked into the file: there is no virtual machine to install.
kavach run --nativecompiles to machine code in memory and runs it at once, without writing a file.- Building needs the system's linker: the C++ Build Tools on Windows, a C compiler on Linux and macOS.
- Windows and Linux are tested on every change; macOS is written but not yet tested.
On Windows, an executable needs nothing to be installed: only the Universal C runtime, which every Windows from 10 on has. It doesn't need the Visual C++ runtime (VCRUNTIME140.dll).
What Kavach does for you
You pay only for what you use
An executable contains only the modules, functions and runtime parts the program really uses.