First Project using the Julia Language

Some notes about software, hardware technologies and personal interests

First Project using the Julia Language

July 22, 2020
Reading time: 11 minutes.

It’s been a few times that I heard about the Julia language in the past. Labeled as a programming language for “data science” and “scientific computing”. I felt intrigued and decided to use it for one of my projects at work considering that it’s been nearly 2 years since Julia reached a stable 1.0 version. I hope sharing my experience will help other people interested in the language for their applications.


Julia’s Logo, source: The Julia Project.

My background and why I should mention it.

I’m a long time user of Fortran, C++, C, and I have used Python, R, Matlab, and Java in the past, mostly for scientific computing projects. I’m far from being an expert in any language and I just try to keep up with projects’ needs. These days I’m mostly using C++ and Python.

This is important to point out because people with different backgrounds may have completely different opinions or I could just be dead wrong. It could also help the reader come up with its own mental mapping to some the features Julia “borrows” from other languages as I describe in the Julia syntax and other languages section.

How did I come across Julia?

The first time I heard about Julia was around 2015-2016 when I was working at Intel Corporation. One of my colleagues mentioned as a really good language that is suitable for Artificial Intelligence (AI) and Machine Learning (ML) applications. I must admit I didn’t pay much attention since it was far from stable and I remember reading blogs and posts about the language. My first thought was to give it more time as it’s still work in progress.

The second time was around 2018, a request came in one of the open source project for Julia bindings. While it renewed my interest, we declined the request given the lack of actual projects using Julia and the fact that Julia wasn’t stable, yet. Around the same time, I attended Professor Alan Edelman’s talk at Oak Ridge National Laboratory. He is one of the founders of Julia and a renowned authority in the field. I had a much better idea of what Julia does. My impression was that it’s a really nice dynamic interface for numerical computing and linear algebra abstractions. Fast forward to 2020 and I decided to finally give it a shot.

Setting up my first Julia project

I was ready to jump as I had a project that I started drafting with Python, but soon enough I restarted it in Julia. My first impressions of each aspect of the process:

Julia syntax and other languages

In this section I try to draw parallels with other languages. Take it with a grain of salt, this is just my own mental map.

Julia performance

Performance is presented as Julia’s big selling point as it solves the “two-language problem”. Personally, the “two-language problem” wasn’t my biggest concern. Julia itself can be seen as a nice front-end to LLVM or GCC, which are written in C++, and usually Python underlying libraries (written in C, C++ or Fortran) are rich enough for common tasks with numerical structures. For example, I’d expect Julia or Python libraries would be calling BLAS or LAPACK somewhere under the hood. However, I can see the value in many areas in which CPU runtime could be important as you just write code in “one language” to maintain a single codebase.

Package stack

Overall, the package stack was kept simple for this project. Beyond the rich Julia Base I only used a few packages to solve a linear fitting model, code formatting, plotting and file pattern search. They are listed here:

I ended up writing a scripts/requirements.jl file to automate the process on setting up dependencies on new systems:

scripts/requirements.jl:

  using Pkg

  Pkg.add("JuliaFormatter")
  Pkg.add("Glob")
  Pkg.add("DataFrames")
  Pkg.add("GLM")
  Pkg.add("Plots")
  Pkg.add("PackageCompiler")

  # precompile dependencies
  using PackageCompiler
  create_sysimage([:Glob, :Plots, :GLM, :DataFrames], 
                   sysimage_path = "jexio_deps.so")

  exit()

run from terminal with:

  > julia scripts/requirements.jl

Wishlist and Final Thoughts

This is my personal wishlist of things for Julia that I’d like to see and hopefully do in the future:

Overall, I like what Julia offers for scientific computing. I’m looking forward to see Julia’s evolution in the new decade. It’s well designed and easy to grasp if you’re coming from a numerical background (Fortran, Matlab, R). I find comparisons with Python a bit unfair. Python is a well-established general-purpose object-oriented dynamic language with a rich ecosystem for numerical capabilities that were later added into the language. It’s still great that there are competing products for the kind of things I work on. Would I migrate Python production code to Julia? Certainly not, there are associated costs and Python is a fine language. I think of Julia as being domain-specific with a still rapidly growing ecosystem. Would I use it for data analysis, simulations, or a quick prototype for number crunching applications? Certainly yes. Did I enjoy using Julia? Yes, it’s a nice addition to my portfolio of programming languages.

Back to main page