(Available here: https://github.com/Clemapfel/jluna)
You may have heard of a relatively new, fancy, high-performance language called Julia, which, by now, has fully matured into one of the fastest, most modern and elegant languages in existence.
So far, it has been cumbersome to embed it into C-language projects, because it's C-interface is hard to use and poorly documented. Because of this, many choose to just use python or lua instead.
Because of this (and in lieu of a full-time job), I have spent the last 3 months creating jluna, a written-from-scratch C++ <-> Julia interface that aims to fully replace the Julia C-API, by wrapping it in all the comfy cushions of modern C++20: compile-time assertions through concepts, full exception forwarding and elegant syntax make it a great choice for projects where C++ is the host language. It includes a fully human-written manual introducing every feature, installation guide, and in-line documentation for IDEs.
Hopefully my work will make some of you consider using Julia as the (auxiliary) scripting language in your next C++ project, or, if you already have a Julia project, jluna may serve as the glue that binds it to any of the countless C- or C++-APIs.
It is available for free, under MIT license, here.
Showcase:
```cpp // execute arbitrary strings with exception forwarding State::safe_script(R"( f(x) = xxx
mutable struct MyStruct
_field
MyStruct() = new(123)
end
instance = MyStruct();
)");
// access and modify variables Main["instance"]["_field"] = 456; State::script(R"(println("instance._field is now: ", instance._field))");
// call julia-side functions with C++-side values int result = Main["f"](12); Base["println"](result);
/// muti-dimensional, 0-overhead array interface State::script("jl_array = reshape(collect(1:9), 3, 3)"); Array<size_t, 2> cpp_array = Main["jl_array"];
// iterable and assignable for (auto e : cpp_array) e = e.operator size_t() + 10; // this also modified julia-side variable Main.jl_array
// julia-style, multi-dimensional indexing cpp_array.at(1, 2);
// julia-style array comperehension
cpp_array.at({8, 2, 5, 6});
Hidden Bonus: jluna made C++ have list comprehension
using namespace jluna;
for (size_t i : "(i for i in 1:10 if i % 2 == 0)"_gen)
std::cout << i << " ";
2 4 6 8 10
```