Julia, My New Favorite Language


     For the past few months I have been experimenting with a relative newcomer on the programming scene. Although first, I should note that my experience in programming is strictly technical/scientific. I am experienced in FORTRAN, Mathematica, and Python. And now, Julia (relatively). Firstly, it is very fast. Python is only faster when using packages such as Numba or Cython. With these packages Python might approach the speed of FORTRAN however it is worth noting that in complicated environments with multiple packages Cython or Numba can conflict. In this regard, Julia avoids this problem, having a relative speed of 1.91 vs C++14 Intel Compiler (base rel. speed of 1). Base python has a relative speed of about 30 while Cython and Numba based python of 1.03 and 1.18. All of this is provided from a  brilliant programming language comparison study done by Aruoba and Fernandez-Villaverde, found HERE

     The reason I bring up Python in particular is that Julia is extremely similar to each other, but having important differences, found HERE. Many in the STEM fields use Python as a technical computing language. However I am putting stock into Julia. Not because I think Python is inadequate - certainly not. There are just certain advantages in Julia. Firstly, as was already mentioned, great speed without potential package conflicts, which I have experienced in Python. Another is that I do prefer certain syntax of Julia vs Python. Such a case is that functions and loops require an 'End' statement to close it, making the code significantly easier to read and understand, in my opinion.

     Another extremely novel feature is the usage of LaTeX symbols in the code. This allows one to include various mathematical symbols in the code by typing \[Latex Code] + Tab which then directly inserts the corresponding symbol as an ASCII character. Two basic examples are as follows.

     If I want to code the differential equation: Δy/Δx = x2 in a for loop, without Latex it might look like 

for i in range(int(maxT/del_t) - 1):
    x[i+1] = x[i] + del_t * (a*x[i]^2)
    t[i+1] = t[i] + del_t

     However, with LaTeX symbols, we can change this up a bit. 

for i in range(int(maxT/Δt) - 1):
    x[i+1] = x[i] + Δt * (a*2[i]^2)
    t[i+1] = t[i] + Δt

     Of course, this is a very simple example. One can see the possibilities when writing output text and such. LaTeX has very diverse symbol usage. Considering the ease of inserting them in the three main Julia editors one has no reason not too. 

     Another reason I support Julia is that the matplotlib equivalent of Julia is GadFly (there are others), and the output graphics are gorgeous. Compare a matplotlib (top) and gadfly (bottom) sin function export below. I prefer the GadFly plot myself, although in this representation the true quality may suffer some. 


     These are, of course, more superficial reasons to use Julia but I enjoy it. As my experience on the programming aspects grows, I find that I enjoy Julia even more. Most of the particulars are outlined in the link above, Noteworthy Differences. For the past few days, as of the time of this post, I have been writing my own "package" of sorts that load my most frequently uses packages and provide certain user functions that I utilize frequently, such as a user-defined function that short-cuts writing GadFly plots as PNG files, which is exactly how I got the image above.

     It should be noted that there are four main development environments for Julia. The REPL (Read-Eval-Print-Loop) environment, Juno, Conda (AKA IJulia), and standard text editors. The LaTeX shortcuts  do not work in a standard text editor of course. The general approach I have taken is to use text editors such as VIM or EMACS, wring a .jl file and envoking it in a Linux terminal by $ julia foo.jl Conda is very useful to experiment with features and "play" but I find it is too glitchy for serious work. Juno is a beautiful IDE but I have yet to reach the level of sophistication that would move me into the environment. Although it does have the distinct advantage of having the REPL available at hand, which also puts the julia man pages directly at hand. Which brings the default Julia environment to the front. the REPL. Its very similar to the Linux terminal python environment. Its handly in utility capacities such as package updating but for code development it is virtually useless to me. 

Anyone interested may refer to http://www.julialang.org


Remember to turn your brain off for a reboot sometimes...