Specifically I'd like to write a file calculator application for a numeric file format that I have. The idea is you'd be able to do something like:
skcalc out file1 fft file2 fft ~* abs_sq
(RPN notation). This would find the cross-spectral power between two files. I'd like to support much more complicated operations, and if I could compile my command line expression at runtime and execute that'd be a huge win. In particular I'd like to be able to support whatever SIMD subset the host processor gives me.
But what you want is basically a JIT.
Here is an example JIT where I translate brainfuck programs to assembly:
Alternatively you can just use an interpreter.
Some inspiration in C/C++
Also I'm currently implementing a compiler for deep learning with SIMD support (and GPU and parallelism later). For now I'm only supporting compile-time code generation but later I will also add runtime code generation, probably via LLVM JIT capabilities: https://github.com/mratsim/compute-graph-optim
You could generate C from your numeric file format, then use the dynlib module in nim to load it during runtime. That is to say, replace C++ with nim, but don't bother with nim's format when generating code, since it's easier to generate C/ASM for your specific needs. I find "hard C" like that, for well defined, specialized transformations of numeric data, to be very unlikely to require any shenanigans that might result in stack smashing, undefined states, or race conditions. Using nim everywhere else where those shenanigans would be required in spades? Still a good idea.
But I've never really done much with fourier transforms, so I dunno. Have you looked at the standardized fftw library at http://www.fftw.org ? They have a "fftw-wisdom" command for doing some sort of compilation/optimization beforehand.