Hi everyone!
I face with interesting problem.
I need a language to extend existence c++ software.
Support user functions, add optimization over calculations and possible neural network experiments with solution.
The key point on julia is a possibility to get c-function pointer, which could be used within existent code easly. Its really interesting!
But project should exist for many many yaers with intensively developing. (but i have issues with julia every day, python dont even have such possibilities - fast user functions)
This community differently has a lot of expirience with julia.
Can you share your experience? Is it good with optimization and neural networking? (no tensorflow support). Is it good in long developing?
python could be fast if we fill data arrays within python (user functions defined in pyhon and executed to fill array, no calling for python api within c++ millions of times)
But julia functions could be handled as any c++ functions (with several difficulties of this functions bodies)
It’s unclear what you really want to know, but it’s indeed straightforward to call Julia from C++ using function pointers created with the @cfunction macro. We have done so at work for many years to call Julia from a C++ GUI application. Since the Julia parts are optional to the application, we have chosen to load libjulia dynamically, and the principal approach is documented at GitHub - GunnarFarneback/DynamicallyLoadedEmbedding.jl: Embed Julia with dynamical loading of libjulia at runtime.
The Julia C-API provides the “backbone” of Julia and is the basis for jluna and most other foreign-language libraries interacting with Julia. While powerful, the C-API can be quite hard to use and poorly documented. jluna aims to resolve this, fully wrapping the C-API in all of the convenience of modern C++: automatic memory management, proper exception handling and much nicer syntax. Other than this, Julia C-API and jluna are functionally equivalent.
The one area where jluna actually has more features than the C-API is in parallelization: jluna provides a thread pool that allows C-side functions to interact with the Julia state, something that is not possible using only [t]he C-API.
[Info on for calling in the other direction to C++, from Julia has more package alternatives]
[…]
CxxInterface.jl and CxxCall.jl both aim to call C++ functions (contained in a shared library) from Julia. They essentially are a ccall for C++, not a full language wrapper, the projects are therefore not functionally equivalent. jluna does provide a way for the julia state to call any C++ function, the mechanism to achieve this is completely different, however.
In summary, the only fully functional equivalent for jluna is the Julia C-API, as only it provides a Julia-wrapper that assumes C / C++ as the host language. It is therefore the superior choice in projects where Julia plays an auxiliary rule while C++ is more dominant, as jluna provides clearer design, more documentation and overall ease-of-use when compared to the C-API.
Like the C API of Julia, jluna supports all platforms; except the only reason I can see not using it, in preference to the C API directly, is if you require macOS support, but it’s a known issue that you can help fix: https://github.com/Clemapfel/jluna/issues/64
jluna is the only alternative to embed Julia into C++. CxxWrap.jl is for the other way call C++ from Julia, but that’s not what you asked for, though it might also be an option for you.
dynamic loading is a way.
is it a huge limitation?
All interaction is made via cfunctions - less powerful interface than the "regular" embedding.
Im trying to bind c++ structures and methods into julia, but c-api could be difficult with binded structure. (i dont found a way to call c_function with c++ structures as arguments) Was it a problem for you or you manage it some other way.