I am searching for programming languages with a certain paradigm, or the name of the paradigm which works like follows:
- You start with writing the source code of a program or something more like a script.
- This is then executed by the "compiler" (interpreted or just in time compiled) and produces a actual executable.
- You run the produced machine code.
So the compiler does not only translate source code to machine code but also provides a runtime environment while doing so. The code is executed by the compiler at one, with no user interaction, just the source code as input (no Read–eval–print loop, console or such things).
For example, C++ (11/14/17) then to go in this direction with things like recursive templates and constexpr, where entire functions can be executed at compile time (not runtime). But I imagine it even more generic and allowing for reflection (like Smalltalk, where everything is an object). It could help to reduce redundancy of the source code and allow more abstraction.
Code example:
const char* names[] = { "a", "b", "c", ... };
template<int size>
struct S {
assert(size < sizeof(names)/sizeof(void*));
for(int i = 0; i < size; ++i)
this.add_field(Type::float, names[i]);
}
This can not be done in C/C++, D has a bit more features like static ifs ans so on, but no language I know actually supports this.
Is there a name for this paradigm and are there languages which are heavily based on it?