3 ms·
These kinds of tricks certainly are more pleasant to do in languages with real metaprogramming support. For numerical applications, one interesting project tha
by ufo 9y ago
These kinds of tricks certainly are more pleasant to do in languages with real metaprogramming support.
For numerical applications, one interesting project that comes to mind is the Terra programming language. It uses a flexible high level language (Lua) to metaprogram a fast and predictable C-like language (Terra). The advantage compared to the examples you mentioned is that each language can focus on its strength: the low level language being similar to C allows the programmer to better reason about performance and having a high level language for metaprogramming keep things simple.
https://terralang.org https://terralang.org
There are also systems out there specifically designed for numeric applications that let you specify an algorithm in a high level DSL and generate highly performing C code, some of which might even tesr various versions of the code to find one that runs better on your machine (for example, the best way to iterate the data might be affected by cache sizes). I don't remember the names of these off the top of my head but the Terra PhD thesis has lots of references to them.