My programs often use complex intermediate data structures and algorithms (databases, rule-based transforms, symbolic math, simplifications, …). Their results are rather simple, to be included or embedded in other C/C++ code or run outside of Julia.
From what I understood, there are possibilities to generate a rather large executable, with some hope that Julia will improve on that, but not being high on the list.
Would it then make sense (if possible at all) to develop a Julia-to-C/C++ converter, or small executable compiler, step-by-step, starting with a limited feature set:
Minimum C/Julia subset: no multiple dispatch, no packages …
including eval(), needed for packages (?)
Readability of the generated C-code would be definitively a plus.
You can make small binaries (limited subset of Julia):
Calling the Library from Python
That’s just an example, you can call from C or C++ too.
There’s already the outdated/unmaintained Intel’s Julia2C (for a limited subset of Julia; to C++ possible too):
If you want to call Julia from C++, with all Julia features possible including eval, then there’s the seemingly awesome (well documented) Jluna project for that. Similar project to call from Rust. And from C, just the embedding API, these build on.
You can’t have small binaries with all Julia features, at least if you include eval (that you may want to avoid anyway), since with it Julia is strictly more powerful than C or C++; then you need the backend of the compiler, LLVM dependency. But you can drop that (and some other dependencies, for smaller binaries if not needed.
My actual work requires translation of (Matlab) functions to C, C++, and event-based SystemVerilog.
After type inference, I describe the function in a small intermediate format, which then can be easily parsed into the target language.
After completion, I found the following sources along similar lines: