Jluna, the Modern Julia Wrapper for C++, has entered 1.0 Beta

After many weeks of updates, jluna, the Julia <-> C++ wrapper, is feature-complete.

It is available for free, under MIT license, here: https://github.com/Clemapfel/jluna

It now includes:

  • handwritten manual aimed at people less familiar with C++, installation guide
  • 0-overhead thread pool that allows C++ code to interface with Julia concurrently
  • benchmarks and performance evaluation, confirming viability in performance-critical environments (< 5% overhead compared to the C-API)
  • 0-overhead way to call arbitrary C++ functions in Julia

jluna aims to completely replace the Julia C-API in usage in C++ projects. Hopefully, this makes Julia easier to embed and more attractive to non-Julia projects. The C-API can be quite hard to use, which is why I have taken care to create verbose documentation, exception forwarding, and varied safety features.

For more information, consider reading the GitHub readme.

The main difference to Cxx.jl and CxxWrap.jl are:

  • jluna assumes C++ as the host language, instead of Julia. It is a C++ library, not a Julia package
  • it is aimed at modern C++20, heavily making use of features such as concepts
  • it requires up-to-date C++ compilers and Julia 1.7.0+
  • internals, interfacing, syntax, etc. are completely different. jluna was designed separately, from scratch

The library will continue to be supported, hopefully for years to come. Thank you to all who already gave the project a chance, and to all that are considering using it in the future.

46 Likes

Is the package already being promoted to C++ people elsewhere? I don’t need C++ as host myself (but I like all solutions to allow Julia code available from more languages):

I realize; and that you can already call Julia from R, but isn’t this also useful to make R extensions to call Julia?

It might be that’s not needed, even though R extensions are usually written in C++. Same with Python extensions (or more often in C; or Fortran?).

PythonCall.jl is beautiful for calling Python (and taking care of its dependencies), but also to call Julia, with Python the host language.

I’m thinking, is there a way to make extensions for both Python and R, already, in C++ (if that not commonly done?), meaning with the wrapper the same, not just the wrapped C++ code, possible to build it for Python or R?

Is this package helpful for that, while keep the wrapper in C++, to be usable from it too, even though the wrapped code is in Julia?

1 Like

Is the package already being promoted to C++ people elsewhere?

For now, I only announced it here and on the Julia discord, I think tomorrow I’ll try to visit the Julia slack and maybe the C++ subreddit

I’m thinking, is there a way to make extensions for both Python and R, already, in C++ (if that not commonly done?), meaning with the wrapper the same, not just the wrapped C++ code, possible to build it for Python or R?

If you think of the languages like a directed graph, to connect all these languages you would need a C++ host, and a R → C++ library, Python → C++ library and Julia → C++ library, the latter of which jluna is. That way, C++ can serve as the connection between all of them.

1 Like

For R<->C++, there is Rcpp. For Python<->C++, there are cppyy and pybind11 (see also hpy and cffi for C).

1 Like

Thank you for your hard work!
I am wondering whether the julia-c++ binding library can be designed to be header-only? I see that both Cxxwrap and jluna donot choose this approach. The users need to link basic library (libjluna.so + jlna_c_adaptor or libcxxwrap-julia.so).
When I use Cxxwrap recently, I think if we make the c++ binding library header-only, we can build a standalone dynamic library that only links to libjulia and easier to distribute.

1 Like

This is huge! Thank you for all your hard work!
I’m especially happy with the multi-threading interface :heart: