I know that a force of Julia is that it is high level and yet, you can code low level routines natively in Julia and still obtain good performances, whereas in Python, you would be advised to bind and wrap C or Fortran code to obtain similar performances. At the same time, I hear and read that Julia is mostly written in C. However, what I do not understand is what is natively written in Julia and what is not, i.e., what is written in C? For example, say linear algebraic operations. In Python, every operation between NumPy arrays is actually coded in C, I think the same goes for Matlab, what about in Julia, does a matrix-vector product run C code or not?
Where do you get that information? Here’s the Julia language repository breakdown from GitHub:
The C part is largely very low-level internals like garbage collection and codegen (interfacing with LLVM; a C++ project).
Much of the Julia standard library is written in Julia itself, e.g. even things as basic as complex number arithmetic or fancier things like sparse matrix–vector multiplies and printf
formatting
However, of course there have been decades of engineering effort poured into mature libraries, and we want to exploit those where possible. So, Julia uses pre-existing libraries (mostly in C and Fortran) for things like:
- LAPACK/BLAS linear algebra (e.g. matrix inversion, matrix–matrix multiplies). However, it also has native Julia versions of most of this functionality, which is useful for linear algebra on new number types (whether bignums, quaternions, finite fields, …). And people have also demonstrated that optimized native Julia BLAS operations can match the performance of heavily optimized BLAS libraries like MKL or OpenBLAS.
- Regular expressions, using the PCRE library.
- Downloading files, via libcurl. (But there is also a native-Julia HTTP library.)
- Low-level asynchronous IO, via libuv.
- Native compilation, via LLVM. (But higher-level compiler passes like type inference are largely implemented in Julia.)
- Bignum arithmetic, via GMP and MPFR. (But there are also native-Julia extended-precision arithmetic types.)
This is not because such things cannot be implemented in Julia, but more because we are mainly interested in using Julia to implement new functionality rather than simply re-inventing the wheel by replicating mature existing code.
(It depends on how you count. It’s true that the Julia implementation required little new C/C++ code.
However, we of course also utilize existing libraries as mentioned above, and these aren’t included in the github stats because deps/Makefile downloads a bunch of external libraries at build time.)