JuliaInterop / Cxx.jl

The Julia C++ Interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Current Cxx.jl roadmap

gstavrinos opened this issue · comments

Firstly, thank you to everyone that has contributed on this awesome package. I have used it extensively on my projects.

Regarding the discussion that was raised due to a release of a package of mine here: JuliaRegistries/General#27296, I would like to know the roadmap of the Cxx.jl package in terms of long-term julia support and/or the plans for a replacement package.

Thanks in advance,

George

For long-term julia support and maintenance, the utilities provided by bootstrap.cpp may need to be split into different parts.

Cxx.jl is based on LLVM and Clang. As for the LLVM part, I guess we can use LLVM.jl(LLVM's C API wrapper) to reimplement related functionalities in bootstrap.cpp. LLVM.jl is well-maintained and stable between Julia versions, so there will be no maintenance overhead for the long-term.

As for the Clang part, unfortunately, libclang(Clang's stable C API) doesn't provide enough features that are needed by Cxx.jl(Cxx.jl uses Clang's codegen to generate LLVM IR from C++ code, but libclang is mainly for doing things with the AST), so I think we need a C++ library that provides stable C API for Clang's codegen module. For the long-term maintenance, we only need to do bugfixes on this library for different Clang versions, nothing needs to be done on the Cxx.jl side.

As for the Julia part, I believe we should implement Cxx.jl by using Julia's internal interfaces as little as possible. If it's inevitable to use some internal functions, one needs to submit PRs to the upstream to make sure all of them are available between Julia versions.

As for the build system, we now have Clang_jll in Yggdrasil, so it's easy to upgrade the build system to BB2.

Anyway, these are my two cents about the long-term support of this package. I haven't actively worked on this package for quite a while until recently, I'm starting to play with the Clang part.

Thank you for the detailed answer, @Gnimuc. It is much appreciated. I now understand the limits and hurdles of the Cxx.jl package.

I can't say I completely understood what you meant with "As for the build system, we now have Clang_jll in Yggdrasil, so it's easy to upgrade the build system to BB2.", but it's ok.

Since you know and are involved in the JuliaInterop organization, what would you advise someone that wants to interface a C++ library to do? I would appreciate if you could give an answer for both someone starting from scratch and for someone that has already some implemented code using Cxx.jl.

Sorry if I am being pushy. It's not my intention. I would appreciate an answer whenever you have the time. I am just struggling to find the best way to make the most out of my (current and future) Julia packages.

Thanks again.

what would you advise someone that wants to interface a C++ library to do? I would appreciate if you could give an answer for both someone starting from scratch and for someone that has already some implemented code using Cxx.jl.

For the sake of stability, I highly recommended starting with CxxWrap.jl for now. For those who have Cxx-based packages, if the package is only for personal use and Cxx is working fine and there is no need for new features introduced in Julia 1.4+(e.g. the new multithreading feature), then I guess it's ok to stick with Cxx. Or one could switch to CxxWrap.jl when users complain about the Julia version limitation.

There are two main features provided by Cxx.jl: the @cxx macro, and the icxx/cxx macro. It looks like the implementation of the icxx/cxx macro is much simpler than the @cxx macro, so I would expect that we could get a stable icxx/cxx macro for Julia 1.6+ in the near future.

As I'm not an active user of Cxx.jl, I don't really know the use case where one should prefer @cxx over icxx/cxx. To me, the use case is somehow overlapped.

Sorry if I am being pushy. It's not my intention. I would appreciate an answer whenever you have the time. I am just struggling to find the best way to make the most out of my (current and future) Julia packages.

Never mind. Learning to make Cxx.jl work on Julia 1.6+ is high on my priority list. :)

Thank you again for another detailed answer.

For my current packages I think I will stick with Cxx.jl since there are plans for further development and Julia 1.6+ support. For my new packages I will try (once more) to implement them in CxxWrap.jl although the C++ interface is not as friendly.

I am closing this issue. Feel free to re-open it if you need the visibility of the discussion.

Thank you very much.

I don't really know the use case where one should prefer @cxx over icxx/cxx. To me, the use case is somehow overlapped.

In my experience (not using Cxx at the moment since I need a recent Julia, but I did use it a lot in the past), the icxx/cxx macros are a lot more important than having @cxx - the latter is a nice convenience, but non-trivial uses cases will often require icxx/cxx in many places. So I think if a Julia v1.6 compatible version without @cxx would be very nice already.