By: Francis Smart
|The Famous Julia|
First off, I am not going to talk much about Julia’s speed. Everybody has seen the tables and graphs showing how in this benchmark or another, Julia is tens times or a hundred times faster than R. Most blog posts talking about Julia test the generality of these results (Bogumił Kamiński 2013, Randy Zwitch 2013, and Wes McKinney 2012).
Also, “Julia allows interpolation into string literals using $, as in Perl:”(doc)
julia>user = “Bob”
julia>"Hello $user. How are you?"
"Hello Bob. How are you?"
2. Julia implements comprehension syntax for defining arrays which is an incredibly powerful method. Formally it looks something like this: A = [ F(x,y,…) for x=rx, y=ry, … ]
Imagine we would like to define an area equivalent to the number line:
Let’s see how we might do this in R.
3. Functions can be written in a mathematically intuitive form.
4. Numerical constants leading functions are automatically interpreted
5. Julia does not worry about deep nesting of functions. Imagine a very silly function that adds up all of the integers between 1 and n.
Does not even cause a hiccup! Now I have never been in the situation of needing this many recursions but this result reflects the general power of the language.
6. Julia has no problem with many Unicode characters. Thus if you want θ(μ,σ,φ)=μ^σ/φ
Personally I find this notation extremely appealing as it succinctly communicates the equation for which the researcher is actually dealing with as opposed to what typically happens when I code R.
Besides being more compact, Julia’s notation requires less mental juggling in order to translate from mathematical concepts to direct implementation.
7. Tuple fast assignment.
I am not sure if I am referring to this properly. Perhaps one of the omniscient badasses working on Julia can correct me if I am not describing this feature correctly.
julia> a, b, c, d = 1, 22, 33, 444
This might seem very trivial but check out how easy it is to pass parameters into a function. Item response theory probability of a 4PL model defined with ability parameter θ and item parameters a,b,c,d.
function ppi(θ=0, ipar=(1, 0, 0, 1), D=1.7)
a, b, c, d = ipar
# Define exponential factor appearing in
# numerator and denominator.
ε = e^(D * a * (θ - b))
# Define final probability being returned.
c + ((d-c)*ε)/(1+ε)
What I mean by this is that when programming in Julia, so long as you follow basic rules regarding programming efficiency your program is likely to run at a comparable speed in Julia as it would be if it were programmed in C. For me this is a big deal. It means that I do not have to think about figuring out how to program the same task in two different languages if I am programming a new library or feature.
Likewise, when reading functions and libraries written in Julia, I hopefully will have to worry less about working with other languages. This should make it possible for the source code for functions to be more accessible for the purposes of learning and improving my understanding of programming.
It is at this time that I want to mention a few critiques. As I see it, these critiques are entirely based on the novelty of the Julia environment which is completely addressed by the creators listing the current version of the language in 0.2 and testing 0.3. As far as how the language actually performs, I have no complaints. It does not have as many libraries as R but they are in development.
1. The documentation is surprisingly very readable and surprisingly enjoyable. I found that reading through documentation not only enhanced my understanding of Julia but significantly enhanced my understanding of programming languages in general. That said, the documentation seems to be written from programming polyglots to other programming polyglots. I think it would be very difficult for someone without programming experience to read the documentation and be able to do much with Julia.
2. The documentation is sparse on examples and the examples tend to be at a high level of complexity. I personally think that the best way to learn to program is through examples (though this might explain my spotting understanding of abstract concepts like scope). The documentation of Julia has a fair number of examples but I would think that doubling the number of examples would be very helpful. In addition, there are quite a number of functions written for Julia which do not have any documentation at all. Obviously it would be helpful to have documentation for such functions.
3. Finally, as a windows users (I know, poor form) it is not very easy to use Julia. I have been using Forio’s Julia Studio (since I do not like working with Window’s command line) but don’t find it that great to work with plus it is proprietary (though free). It would be nice if there was a very basic windows IDE like R’s for which I could write code in Nopepad++ and send it to Julia. But once again this is a minor issue. I am resolved to get a Linux build running on my machine once I make my way back to a country with decent internet.