Daily Thought - 2024-11-16
< back to listThe host in Caterpillar embeds the runtime, providing platform-specific capabilities. Right now, the runtime is a bytecode interpreter. The host is an application that runs this interpreter. The host I'm currently working on (the game engine) is specifically a web application, but other hosts could be running on Linux/Windows/macOS, microcontrollers, whatever.
But the host does not only exist at runtime. It's also a compile-time concept. The compiler is not tied to a specific host, but it can query the current one over a generic interface. Using that interface, it can determine whether a given identifier in the code refers to a host function, and generate code accordingly.
This is just the current state. At some point, I want to compile Caterpillar to WebAssembly and native machine code. Then the host could turn into a concept that only exists at compile-time. You don't really need a runtime component that executes a host function, if you can instead teach the compiler to generate code that does the same thing.