
Optimizing .*: Details of Vectorization and Metaprogramming - leephillips
http://www.juliabloggers.com/optimizing-details-of-vectorization-and-metaprogramming/?utm_source=ReviveOldPost&utm_medium=social&utm_campaign=ReviveOldPost
======
davidacoder
It is worth pointing out that this blog post is old, from January. Julia 0.5
adds a phenomenal new feature, the dot syntax [1], that automatically fuses
vectorized expressions. I believe that feature was added quite a while after
this blog post was written.

Currently the dot syntax works for all functions, except for operators like
.+, but in julia 0.6 it will work across the board. At that point, an
expression like

    
    
      A.*B.*C
    

will automatically be translated into the de-vectorized loop version that the
author identifies as the fasted way to implement something like that, without
the need for any macros or other special tricks.

[1] [http://docs.julialang.org/en/latest/manual/functions/#dot-
sy...](http://docs.julialang.org/en/latest/manual/functions/#dot-syntax-for-
vectorizing-functions)

------
zackmorris
Found this comparison of Julia, MATLAB, R, Python and C/C++:

[http://docs.julialang.org/en/release-0.5/manual/noteworthy-d...](http://docs.julialang.org/en/release-0.5/manual/noteworthy-
differences/)

At the highest level, Julia operates on all of the elements of a matrix for
each operation, is 1-based, assigns by reference, is case-sensitive, has the
range operator (:) like python, but doesn't allow negative indices to read
from the end.

Now for some get off my lawn:

In terms of learnability from easiest to hardest, I would rank them:

Python

MATLAB

Julia

R

I'm still hoping for a pure functional language that operates on matrices and
doesn't introduce a lot of non-imperative operators and terminology. For
example closures with immutable data gets us a fair part of the way to
Clojure, without the learning curve. For the most part I've given up on ever
learning Erlang, Haskell, Scala, etc even though I know Scheme. Maybe F#, I
dunno. I feel that Rust is one level of abstraction beneath my pain threshold.
Swift is too micromanagy when it comes to nulls. Javascript has abandoned its
scripting roots to regress back towards C++ and its new syntactic sugar isn't
helping things. I really want to like Go but worry it will be superseded by a
truly concurrent language running on video cards with automagic error
handling. I've given up on CUDA and OpenCL due to their roots in OpenGL,
because their metaphors are too cumbersome compared to MATLAB. C++ and PHP are
still my most loved and hated languages because they do everything wrong but
excel at things like performance and laziness. In the end, these are my
primary goals.

~~~
iamed2
What puts MATLAB ahead of Julia, in your opinion?

~~~
dysfunctor
I was curious about that as well. I've known folks who were genuinely
discouraged and exhausted from working with matlab, and are now happy toiling
in python. I've not converted them to the Julia side yet, but I will!

Julia is definitely harder to learn than python, but it's far and away worth
the effort, and its only ever going to get easier. There's merit in having to
push your mind a bit when learning a new skill. Struggling has certainly
helped me concrete my skillset. I remember my first time reading sicp, and it
was very difficult and foreign to me at the time, but after sticking it out I
realized what a huge effect it has had on my work, my ability to push myself
to learn new things, and how I think about programming problems to an extent.

Julia feels like a modern, less academic scheme in a lot of ways, and I see
all these people so much more intelligent than me that are making it into an
even stronger language and I just get this sense of pride about it all.

So yeah, matlab sucks.

------
eveningcoffee
My takeaway from this was that Julia has @nobounds option to remove bound
checking.

~~~
iamed2
It's quite nice, and works for user-defined collections as well:
[https://www.youtube.com/watch?v=4XorFlvQEiI](https://www.youtube.com/watch?v=4XorFlvQEiI)

------
viraptor
> the difference between your “high-performance code” and your prototype code
> is @devec

So is there a reason @devec is not applied by default?

~~~
iamed2
See davidacoder's post at the top; it does that now, essentially.

