I’m using Julia as framework for simulation of physical systems and prototyping for signal-processing and control algorithms. Of course, the latter should eventually run on some embedded hardware (in my case, it will be an ARM architecture).
As I see it, making Julia code (I intentionally don’t say Julia) runnable on embedded devices would solve this “two-language problem” as well. Today, control-related stuff is often prototyped in e.g. Python or Matlab/Simulink and then transformed to C code (manually, or automatically after spending a lot of money for several Mathworks toolboxes).
We can think of several ways to get Julia code onto the embedded hardware:
- Re-write the code manually in C, write a (small) wrapper and call this code from Julia to validate against the prototype code. That’s today’s two-language approach.
- Write a C-code generator using Julia’s strong metaprogramming capabilities. For not-too-complex algorithms, a subset of the entire functionality could do the job. That’s an advanced version of today’s two-language approach.
- Extract the LLVM IR and (cross-) compile it for the embedded hardwate, using the appropriate LLVM backend.
- (Cross-) compile a binary (executable, library) containing the algorithms (methods), similar to PackageCompiler.jl.
- Run Julia on the embedded hardware, AOT-compile all required methods when going in production. This would allow prototyping in Julia directly on the embedded hardware and then just “fix the code” at some point.
- Have a minimal Julia “runtime” on the embedded hardware, without the JIT compiler, for which “modules” can be (cross-) compiled – this could probably simplify the build process of 4 and would provide the possibility to add interpreted “glue code” to connect the modules.
If there’s a lot of flash and RAM, one could just use option 5. I guess that’s already possible today. However, on embedded devices, the entire OS (Yocto, Buildroot, Alpine, …) is usually stripped down to 2-4 MB, so one does not want to have some 100 MB software on it.
What are your thoughts on this? Do you also see a (huge) benefit? What could be the best way to go (under which circumstances / requirements)?