On Julia interoperability with C and PyCall

Edit: I see that some of the following was also covered in a different thread. Using cppyy for julia/C++ interoperability - #5 by lungben
Sorry for the cross-post.

I’ve just gotten a message about current and upcoming features of cppyy.
I think it’s appropriate for me to inline the message here. In particular, please see at the end for a code example.

I was notified by a user that cppyy
works cleanly from Julia, see below, which instantiates a template that has
been JITted from Julia. By extension, that means most of HEP's Python and
C++ codes should work and where not can be simplified in either Cling (C++)
or Python, inline, before calling from Julia.

There's an issue with Clang9 (clashing symbol), but that's not fundamental.
Contrary to an attempt of ROOT.jl (as I understood it), libCling.so is made
to be closed, so that clash is just a bug that's fixable. That is, other
than an increased memory usage, there's no technical problem with having two
Clang run-times in the same process.

(It needs closing regardless, as there are many, many uses of libLLVM out
there. In fact, I'm sure Julia is going to have to close up at some point,
as I've even seen device drivers, of all things, use libLLVM!)

Anyway, maybe this info will help stave off questions about how to handle
the intermediate stage, legacy code, and collaborators who will continue to
develop in these other languages.

More interesting for us, would be if there's folks who want to build on top
of Cling's planned libinterop. Basically that'd be the front of PyCall with
the backend of cppyy (in the form of libinterop), w/o the Python layer. We
need another language to test libinterop (there's Python and D, which both
work on top of cppyy's clingwrapper C-API, and some interest from Lisp, but
a solid 3rd language would be needed to proof generality). Given that it
works through cppyy's Python layer, there's no technical reason why it could
not work w/o and it shouldn't be too hard to implement, given the existing
example codes.

The maintainer of Cxx.jl believes that its approach is still the best b/c
it'll have better performance (memory-wise, if nothing else, but also it
can reach deeper into Julia's internals). This is true, but even there LLVM
will move on as Cling's features enter into the new Clang-Repl. And I don't
believe that the better performance is worth the extra maintenance cost.

So, if there's interest within the Julia-HEP tribe, it'd be great if they
could contact us and get the ball rolling.

$ python3 -m venv TEST0
$ source TEST0/bin/activate
(TEST0) $ python -m pip install cppyy==1.9.6
...
(TEST0) $ julia
julia> import Pkg; Pkg.add("PyCall")
julia> using PyCall; cppyy = pyimport("cppyy")
PyObject <module 'cppyy' from '/home/TEST0/lib64/python3.8/site-packages/cppyy/__init__.py'>

julia> cppyy.cppdef(
                """#include <iostream>
                   template<typename T>
                   void blah ( const T& arg )
                     { std::cout << "hello " << arg << std::endl ; }""")
true

julia> cppyy.gbl.blah(1.234)
hello 1.234