## Is Julia ready for prime time?

March 2017

I really want to like Julia. She promises to solve all the frustrations with other numerical languages.

#### The contenders

At the moment I use R which first appeared 41 years ago, and occasionally Matlab which also dates back to the 1970s. And the age shows, they are archaic, irrational, slow and just plain frustrating. For the R issues take a look at the R inferno.

OK, these three are not as bad as SAS, now 51 years old, and is as close to being a crime against humanity as one gets with programming languages. I know many who use it, arguing SAS is the only game in town for really large datasets, but then why not use R inside Oracle or the Microsoft SQL server?

There is one possibility, NumPy, a numerical computation package for python. I love python and use it all the time. Numpy feels incongruous, numerical code crafted onto a language designed for a very different purpose. If R/Matlab are bad, Numpy is worse. No.

Not only are these languages archaic and clumsy, they are slow. I often use embedded C++ in R, getting 20 times or more speed improvement.

#### Julia to the rescue?

So, what about Julia? It certainly got endorsements from the people I respect, like Thomas J. Sargent. Julia is a modern language, very elegant and fast. It would be fantastic to be able to switch from R and Matlab to Julia.

So, I took Julia for a spin, trying to implement a Julia version of my R and Matlab book code.

Just not possible.

It started easy.

Here is the start of the R code (Matlab is quite similar). It downloads SP-500 data from finance.yahoo.com


library(tseries)
price = get.hist.quote(instrument = "^gspc")


In Julia (as well as in R/Matlab) one can use Quandl:


using Quandl;
quandl("YAHOO/INDEX_GSPC")


It is a commercial product, so not quite the same as using R get.hist.quote(), but gets the job done.

Still so far so good.

##### max and maximum

In Julia min() and max() are not used to get the min() and max(), but for something else, the minimum of the arguments, so need


maximum(y)
minimum(y)


OK, for a numerical language, where we are used to using min(x) and max(x) for the minimum of the vector x, why do it this way? Here is why. I can see the reason, but it is annoying.

At least why not give us a better error message than


julia> max(x)
ERROR: MethodError: no method matching max(::DataArrays.DataArray{Float64,1})


Like perhaps adding something like “did you mean maximum(y)?”

##### Basic statistical tests and plots

My book code has some simple autocorrelation calculations and tests.

R has it


acf(y,1)
jarque.bera.test(y)
Box.test(y, lag = 20, type = c("Ljung-Box"))


and so does Matlab


sacf(y)
lbqtest(y)


To do that in Julia I have to code this up myself. We have


autocor(y,1:20)


but what about the confidence bounds and plot and tests?

Same thing applies to analysis of distributions, like QQ plots. (yes that exists, and no, you probably don’t want to go there).

##### GARCH

Getting into more sophisticated analysis, like GARCH, there is a very basic candidate, missing most needed functionality, see here. It installs, but fails on dependencies (NLopt had build errors). Why then install it to begin with? R would reject it. Bizarrely, then Julia still then loads it without complaining:


using GARCH
fit = garchFit(y)
ERROR: UndefVarError: garchFit not defined


So no GARCH.

##### Plotting

And finally, plotting, not sophisticated like the R acf() and sacf() in Matlab. But just a simple plot of a vector. Try plot(y). Good luck.

Here is the official advice. First suggestion uses plotly() which opens in browser tabs, new tab for every call. That will drive you crazy quite quickly. I like plotly, I use it here, but it is a crappy first recommendation for plotting in a numerical package. Second recommendation is pyplot(). Fonts so small I can’t see them, and will not put the plot window into the foreground when plot() is called!

A bit sad having to call either js or python to make simple plots. And since the R plot() or ggplot() are much better than either of those, why not recommend them instead? Here is one way.

Not quite the same as having it built in.

### To conclude

Many of the missing things are easy to code, but a numerical language where one has to manually code the autocorrelation functions? Makes me wonder about what else I would have to manually code. Libraries are there for a reason.

This is where I gave up, it is just not possible to translate the very simple book code into Julia without serious coding of what should be library functions.

So, as much as I wanted to like Julia, she is not yet ready for prime time, at least not with my type of applications. But its early days.

I did write some numerically intensive code and Julia did live up to the promise. It is a great language to program in, much better than R, Matlab and Numpy, and much faster.

I fully expect Julia to fill in the gaps and become useful in my work at some point. The day I can stop programming in R and Matlab, switching to Julia, will be a great day.