

Julia Impressions - a0
http://eyeballtrees.com/posts/julia-impressions.html

======
ninjin
I really want to get into Julia. As I have been using an increasing amount of
numerical code NumPy, SciPy and even my own Cython code has started to fail me
performance-wise. The Julia community is really friendly and I tried rolled
out a few implementations of the inner-most loop of a Recursive Neural Net in
a variety of languages.

[https://github.com/ninjin/ppod/tree/master/hck/rnn_perf](https://github.com/ninjin/ppod/tree/master/hck/rnn_perf)

Disappointingly enough I was unable to push the performance of Julia beyond
that of pure (and ugly) Matlab. I tried asking over at #julia, but it seems
that my implementation should be reasonably canonical. This is really a pity
for me since I would love to remain highly productive in terms of code and use
something scripting-esque rather than have to re-consider going back to C. I
have also had a look at Nimrod, but the scientific library support appears
somewhat lacking at the moment.

~~~
idunning
I used Julia's in-built profiler to look at your code. Almost all the work is
done, as you'd hope, on lines 20, 22, 33, and 35. I added @inbounds to lines
20 and 35, figuring that line 22 is mostly just the effort of calculating
tanh. This dropped the running time on my computer from 10.7 seconds to 6.4
seconds, so about 60% of original running time. If I compile with gcc (gcc
rnn_perf.c -O2 -o rnn_perf -lm) and run that, I get 6.2 (O3 is worse). That
might not be how you compiled the C version, but regardless it looks like your
C time was about 46% of the original Julia time, so its getting close. Three-
fifths of the work now is in the tanh line. I'll submit a PR.

~~~
StefanKarpinski
Having people like Iain – with this kind of knowledge of numerical programming
and optimization – help you out with your code is one of the major benefits of
Julia programming :-)

~~~
Bootvis
This is some quality advertising on your and Iain's part. It makes me want to
use Julia even more when I get the chance.

------
zmmmmm
What are the libraries like for Julia at this point? The big thing holding me
to R is the breadth of libraries for a) various statistical methods and
algorithms and b) plotting.

I'm kind of desperate to get away from R at this point, but reluctant to move
to Python (not that I have anything against Python, but I would really like to
add a high performance language to my toolkit than something inbetween).

~~~
izyda
Out of curiosity, why are you so desperate to get away from R? Is it for the
speed of a high performance language?

As you mention, the vast selection of libraries (and the continual development
of these libraries) make even the python module universe look small (in
reference to statistical methods, statistical algorithms/machine learning,
plotting).

Further, not only are there a lot of libraries.. but many of them are bleeding
edge written by the same people who originally invented the given algorithm.
Most similar libraries in other languages (like Python) have incomplete ports
of these libraries to them often not written by the same people. Not to
mention, the documentation behind these algorithms is often excellent -
besides the usual man files, there's "vignettes" (detailed instruction manual)
as well as an entire journal that now has become a place to publish papers
detailing the usage and implementation of many of these algorithms.

So I'm curious, why leave?

~~~
zmmmmm
I love a lot about R, and I totally acknowledge the benefits. I don't think I
would ever stop using it for data exploration and ad hoc analysis.

But after trying really hard over the past 3 years I'm sort of giving up ever
being able to use it in a productive reliable fashion for building more
complex software. It's a failing on my own part in many ways, but the loose
typing and poor support for structuring code interact very badly with my
personal style. When I'm working in R I literally spend 80% of my time
fighting with the type system, debugging weird and wonderful features of R.
I'm at the point where whenever I write an R function the first 50 lines of
the code are type checks to make sure the data coming in is what I expect. I
came to this point after I started systematically tracking why I was wasting
so much time, and nearly every time it would come back to the type of my data
being something other than what I had expected or assumed.

So I'm sort of figuring if I'm at the point where I'm writing manually
statically typed code in R ... I should look around for a language that's just
like R but has at least slightly stronger data types built in.

~~~
epaladin
I agree completely on the type system. When first starting with it, I was
thinking "wow this is great, I don't have to worry about types and things just
work". But then weird things start to happen, and you realize it's due to
strange type issues that are sometimes harder than they should be to track
down. And then half your code ends up being something like
as.numeric(as.character(as.vector(xyz)))

------
idunning
Great stuff. I think the author may be using the release version 0.2, as the
boot time issue has been rectified now for the most part in the next release,
0.3. The next big slow-load issues is packages, that'll be post 0.3 though.

~~~
eyeballtrees
OP here. I'm currently using 0.2, I'll have to upgrade and see if that fixes
the issue. Thanks!

~~~
ViralBShah
There are two separate issues, I believe you refer to. There is the boot time,
which has been considerably improved, and is less than a second. The second
thing is the slight pause that you refer to (if I understand the post
correctly), when executing stuff the first time. That is the JIT compiling and
warming the code cache.

~~~
StefanKarpinski
The startup time in 0.3 is more than 10x faster than 0.2 – it's down to ~200
ms on my machine, whereas it was about 2 seconds before. It's now quite
painful to go back and use 0.2.

------
throwaway13qf85
I'm really excited by Julia. We use Matlab heavily in my team (as in, we
probably have 300-600 Matlab instances running at any given time not counting
the ones on personal workstations) and I'd love to use a language with similar
support for numerical programming and linear algebra, but with better typing
and functional programming support.

Do you have any suggestions for slowly introducing Julia to the team?

~~~
Bootvis
May I ask what you're doing with all those instances?

And to be extremely bold: what are you paying for all those licenses?

------
CyberShadow
How is multiple dispatch different from function overloading, as found in
C++/Pascal? Is it the same thing?

~~~
brandonbloom
Dispatch is the process of selecting and executing the matching overload.
Multiple-dispatch refers to the ability to select the best overload based on
more than just the first argument. C++ can do arity and type-based multiple-
dispatch, but only statically. Julia supports dynamic multiple dispatch, where
as C++'s virtual methods are only single-dispatch dynamically.

~~~
StefanKarpinski
Precisely. This may sound pedantic or academic, but in practice when static
overloading and dynamic dispatch differ, the static behavior is usually not
what you want. In my experience, this makes it painful to make code that is
polymorphic in multiple arguments behave correctly in C++ (double dispatch [1]
is one of the necessary but awkward tactics that's used), whereas multiple
dispatch just works. And of course, almost working and actually working are a
world apart even though they sound so close.

[1] [http://lostechies.com/derekgreer/2010/04/19/double-
dispatch-...](http://lostechies.com/derekgreer/2010/04/19/double-dispatch-is-
a-code-smell/)

------
irremediable
What's the deal with the lack of conditionals in comprehensions? Is there a
good reason that the Julia devs didn't include that, or is it just something
that's not been implemented yet?

Edit: after a little searching, I found this.

> Filters and guards don't mix with multidimensional comprehensions. For 1-d
> comprehensions, I'm not convinced that it's really worth the additional
> syntax. What's the case for making it part of the syntax instead of just
> using a filter function?

~~~
omaranto
Julia's comprehensions are multidimensional array comprehensions so allowing
filtering doesn't make much sense because the result needs to be rectangular
and filtering can create arbitrary holes.

For a one-dimensional array comprehension it does make sense to allow
filtering and this can be easily expressed in Julia by making a coroutine that
produces the values and collecting its output in an array.

Multidimensional (here multi=2) array result:

    
    
        julia> [i+j for i=1:3, j=1:3]
        3x3 Array{Int32,2}:
         2  3  4
         3  4  5
         4  5  6
    

One dimensional array result, with filtering:

    
    
        julia> collect(@task for i=1:6; if i%3>0; produce(i); end; end) 
        4-element Array{Any,1}:
         1
         2
         4
         5
    

Notice that this last technique is more powerful than typical comprehensions,
since it doesn't just add the possibility of filtering but arbitrary code to
generate the elements.

~~~
irremediable
Thanks for the further info! I'd managed to figure out that it was because of
multidimensional arrays (that snippet I quoted) but I didn't immediately see a
nice way to achieve the same thing. And now, because you posted it, I do.

I'll have to give Julia a go. :)

------
xioxox
I was interested in Julia until I discovered that it doesn't allow useful
things like object-oriented inheritance (unless you go down some complex
metaprogramming route). Multiple dispatch is indeed cool, but for some types
of systems modelling with inheritance and classes is a great or the best
approach (e.g. GUI widget libraries). I thought about how you might wrap
something like Qt, gave up, and decided to continue with lovely Python (and
its lovely 0 based indexes).

~~~
ihnorton
Single inheritance is possible and used extensively in Julia. Multiple
inheritance is not (currently) supported, and there are a few places where it
would be useful, but it is surprising that this would be a show stopper.

~~~
xioxox
I'm not sure it's the single inheritance people from other languages might
understand. Perhaps I'm misunderstanding things as I've hardly used the
languages, but there are links like
[http://thenewphalls.wordpress.com/2014/03/06/understanding-o...](http://thenewphalls.wordpress.com/2014/03/06/understanding-
object-oriented-programming-in-julia-inheritance-part-2/) and
[http://grollchristian.wordpress.com/2014/01/22/julia-
inherit...](http://grollchristian.wordpress.com/2014/01/22/julia-inheriting-
behavior/) and
[https://github.com/JuliaLang/julia/issues/4935](https://github.com/JuliaLang/julia/issues/4935)

~~~
ihnorton
Sure, but that is a different thing than "not object-oriented inheritance".
Designing with Julia's types and multiple-dispatch is _different_ , but there
are some nice patterns emerging.

That said, Julia is still developing. The kinds of people who are interested
in Julia right now are probably different from the people who we hope to
attract and be broadly useful for in 2-5 years. But feedback now is important
so the language and ecosystem can get there!

------
thinkpad20
I've been following Julia for a while now, not really using it, but playing
with it a bit and keeping up with it. I think it's very promising and I really
look forward to seeing it fledged out more.

It's a very small nitpick, but I wish Julia had a postfix function application
syntax. It would be nice to be able to say `foo = 'hello'.reverse` and have it
be syntactic sugar for `foo = reverse(hello)`. Or some other operator since
`.` is in use. This reads nicer for long function chains, and especially when
a function modifies its argument, it's nice to have that argument come first,
which gives an OO-impression. E.g. for me this:

    
    
        app = make_app(options)
        app.route("/", _ -> "hello, world!"),
        app.route("/submit", POST, req -> "hello, $(req.params["name"])!")
        app.start(3000)
    

than this:

    
    
        app = make_app(options)
        route(app, "/", _ -> "hello, world!"),
        route(app, "/submit", POST, req -> "hello, $(req.params["name"])!")
        start(app, 3000)

~~~
idunning
There is this, which is similar but not quite the same:

    
    
        julia> "hello" |> reverse |> uppercase
        "OLLEH"

------
hderms
Julia looks like a wonderful mix of Ruby, Python and ML (or something). I'm
really eager to see this adopted by more people.

------
ihaveqvestion
People who are using Julia or similar tools to do "scientific computing,
machine learning, data mining, large-scale linear algebra, distributed and
parallel computing" \- what sort of problems are you solving? How did you end
up doing this sort of work?

------
SandB0x
Hmm, I was hoping for some impressions of using Julia for numerical computing.
The mechanics of list comprehensions and uppercasing some text seem a little
tangential.

~~~
thinkpad20
That's an important part of Julia, but it's also important to talk about the
language as a language. One of nice things about Julia is that it has things
to talk about other than its numerical computing capabilities :) Those are
fine and dandy, but as a non-numerical-computer, I find lots to like about
Julia that has nothing to do with its ability to multiply matrices.

------
doctoboggan
I too am intrigued by julia based off of my brief interactions with it. My
only issue is the lack of namespaces. Is there a good reason why they aren't
included?

~~~
thinkpad20
They are:
[http://docs.julialang.org/en/latest/manual/modules/](http://docs.julialang.org/en/latest/manual/modules/)

Or is that not what you were referring to?

------
SeanDav
If I can ask a stupid question. Why Julia? It seems to me that if you are not
going to be using Python, then why not use a language like Java?

~~~
jey
Huh, what upside does Java have?

Julia is specifically designed to be a great high-performance high-level
language for scientific computing. See [http://julialang.org/blog/2012/02/why-
we-created-julia/](http://julialang.org/blog/2012/02/why-we-created-julia/)

------
matheusbn
At the beginning of this article: "I spent most of last night programming in
Julia and I've got some thoughts on my first impressions. TL;DR: It's like
Python with less OOP, more FP and heavier typing. Also, _it 's awesome_."

\--------------------------------

Then I clicked on the site's about: "Welcome to Eyeball Trees. My name is
Stephen Malone and _I cannot be trusted_."

I'm really confused!

