3 ms·
The C++ template system is quite possibly the worst functional programming language ever 'designed', with the exception of esolangs. It would be so much saner
by comex 11y ago
The C++ template system is quite possibly the worst functional programming language ever 'designed', with the exception of esolangs. It would be so much saner if we could just run normal C++ code at compile time, with the ability to manipulate the main program's types as values. Then operations like this would simply be indexing a `std::vector<Type>`, there would be no need to add hacky special cases to the compiler and/or massively increase compilation time, and it would be possible to do somewhat more complex things without going insane (e.g. a compile-time perfect hash table generator, like gperf but without needing an external tool).
Rust has something like this in the form of procedural macros, but it can't manipulate types and values, only raw ASTs. Apparently Nim can do it.
- srean 11y agoYour first paragraph actually describes D. In the D world the compile time language and the runtime language is the same thing. You can take a look to see if you like it.