Why writing C interfaces in Julia is so easy*
2019-07-24, 11:00–11:30, Elm A

Julia allows interfacing with shared libraries using ccall. This allows calling into compiled binaries that could be written in any language that exposes the C ABI. In this talk, I'll describe best practices to follow for interfacing with C libraries.

This talk is titled why writing C interfaces in Julia is so easy, but as anyone that has written interfaces to C ABI will know, interfacing with the C ABI is never easy. There can be segfaults, memory leaks, uninitialized memory issues and a host of other challenges to deal with when working through this process. In this talk, I'll briefly describe how the C ABI works, and then describe how ccall can be used. I'll also go through many best practices that I've used to ensure a nice clean Julian interface to a shared library. I will show how some best practices regarding writing interfaces to a large number of functions, you can use Julia's type system to guarantee that the users of your Julia library don't accidentally pass the wrong pointer to a function using unsafe_convert, and some general advice for programmers interested in writing their own libraries in a lower level language (such as C, C++, Rust, Nim etc) and how to ensure that they can be provided as pre-compiled binaries for Julia packages (using BinaryBuilder and alternatives).