C++Now 2018 has ended
Back To Schedule
Tuesday, May 8 • 2:30pm - 4:00pm
The Julia Language and C++: The Perfect Marriage?

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
The objective of this session is to introduce [the Julia language](https://julialang.org) and its interfaces to C++. Julia is a high-level programming language with a focus on scientific computing. Julia leverages LLVM to achieve levels of performance comparable to C++. It is a strongly typed, but dynamic language with a strong focus on generics. Similarly to C++, function overloading is supported, resulting in a "multiple dispatch" system that chooses the correct function to call based on the types of the arguments, compiling specialized versions of the function as needed. However, unlike C++, the dispatch decision is delayed until runtime, eliminating the difference between compile time and runtime types. Julia is an excellent high-level companion to a C++ library (compared to e.g. Python). Its combination of high performance and almost zero-overhead FFI to C++ allow interfacing at any level of abstraction, even in inner loops (e.g. the inner loop of matrix multiply) without a significant performance penalty.

There are currently two methods of using C++ libraries within Julia: [Cxx.jl](https://github.com/Keno/Cxx.jl) to write the interfacing code as part of a Julia program, or [CxxWrap.jl](https://github.com/JuliaInterop/CxxWrap.jl) to write the interface in C++. Cxx.jl leverages Clang and LLVM to JIT compile inline C++ code and execute it on the julia execution engine, while CxxWrap.jl uses the existing Julia-C interface from C++. Cxx.jl allows tight integration between Julia and C++ code, interspersing both in the same source file, with arbitrarily nested control flow between the two languages. It also provides a C++ REPL and interactive use of C++ code, similar to Cling. Furthermore, it allows instantiating C++ templates on julia values. In CxxWrap.jl on the other hand, all glue code is in C++ and compiled into a shared library, akin to Boost.Python for Python. This is less flexible with regard to template parameters, but reduces the stress on the JIT-compiler. CxxWrap.jl also offers a few higher-level C++ constructs to facilitate calling into Julia from C++.

In our tutorial, we will start with some examples to introduce the basic Julia concepts, followed by interactive tutorials introducing the usage of both Cxx.jl and CxxWrap.jl. We will finish with a number of examples and benchmarks. By the end of the session, we hope you will agree that Julia is a fast, high-level language that offers excellent mechanisms to use existing C++ libraries without much effort.

Additional material for this talk can be found here: https://github.com/barche/cppnow2018-julia

avatar for Keno Fischer

Keno Fischer

CTO, Julia Computing Inc
avatar for Bart Janssens

Bart Janssens

Major, Royal Military Academy
I am an associate professor at the mechanics department of the Royal Military Academy. For my Ph.D., I worked on Coolfluid, a C++ framework for computational fluid dynamics with a domain specific language. My interest in Julia is sparked by its powerful metaprogramming functionality... Read More →

Tuesday May 8, 2018 2:30pm - 4:00pm MDT
Hudson Commons