Warming up

Here it goes. This is my first blog entry with the great purpose to learn Julia language from scratch. The motivation for such is knowledge, of course, but some sort of convenience as well. From what I read already I conclude Julia is promising tool for scientific computing being described as fast and elegant and my goal here is to find out how it’s gonna suit me. Throughout the blog entries you read I will try to solve many small problems you may encounter yourself, so I really hope someone will find whole thing useful.

Lets talk a bit about my motivation.

On a daily basis I use R as my main tool for any statistical analysis. It is not rocket sience (my usage of it, not the language itself), I have to admit right here. When it comes to R my main reason to complain (omitting many reasons not to complain) is slowness of basic algebra operations. Whenever I want to multiply two matrices or compute stationary distribution of a random walk matrix, I hopelessly watch only one of my CPU cores running while others stay lazy. I am aware of solutions for that, one can use packages for parallel computing in R or even better try to install openBLAS and compile R with it to have BLAS parallel operations ‘for free’. But these still require some additional knowledge and extra hacking.

When it comes to matlab, I used it on a daily basis when I was in academia – my master thesis was implemented in matlab and python. What I liked the most was its readability when it comes to operations on matrices

# sample matlab code
A = eye(100);
subA = A[1:end,2:end]
# same thing in R
A = matrix(runif(10000,0,1),100,100)
subA = A[1:nrow(A),2:ncol(A)]

I use R and I like it so much but I simply miss matlab. I remember it as much cleaner language, I recall code in matlab as much more readable then R.

Then there is python. I do use it as a tool for very fast (in terms of code creation time) input preprocessing. I like it because it is clean. Take a look at the code below that selects number that are divisible by 4.

# comprehensions example in python 
A = range(1,1000)
B = [ x for x in A if x % 4 == 0 ] 
# same in R
A <- 1:1000;
B = A[sapply(A, function(x) x %% 4 == 0 )]

My opinion is that python code is more readable at the first glance. You can guess what values would go to B. R code requires you to know what sapply does. It is strictly R-ish thing. Python code is more elegant and straightforward to read.

But enough of the shame on R language. It is a mature tool for statistical analysis comparable with enterprise solutions like SAS. As for today there is around 6000 R packages with the purpose to solve different statistical problems. In other words, if you are looking for a code to do any task concerning statistics you should check out R packages because most of the time you will find implementation waiting for you. I think most of the scientists when writing papers also provide corresponding R package with implementation for you to try out. And that is the power of R. It is already mature and growing.

Summing all of these up: R, matlab and python have some nice features one would like to see in a common language. And that common language is Julia that is claimed to be a mix of those with a speed of C/fortran. That is enough for me to start trying it out.

---

Comments are closed.