Julia, a language for technical computing

Julia is a new programming language by Viral Shah, Jeff Bezanson, Stefan Karpinski, and Alan Edelman.

From the blog post Why We Created Julia:

We are greedy: we want more.

We want a language that’s open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that’s homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.

(Did we mention it should be as fast as C?)

While we’re being demanding, we want something that provides the distributed power of Hadoop — without the kilobytes of boilerplate Java and XML; without being forced to sift through gigabytes of log files on hundreds of machines to find our bugs. We want the power without the layers of impenetrable complexity. We want to write simple scalar loops that compile down to tight machine code using just the registers on a single CPU. We want to write A*B and launch a thousand computations on a thousand machines, calculating a vast matrix product together.

We never want to mention types when we don’t feel like it. But when we need polymorphic functions, we want to use generic programming to write an algorithm just once and apply it to an infinite lattices of types; we want to use multiple dispatch to efficiently pick the best method for all of a function’s arguments, from dozens of method definitions, providing common functionality across drastically different types. Despite all this power, we want the language to be simple and clean.

Looking at the excellent Julia manual, it becomes clear that Julia is a descendant of Common Lisp. While Common Lisp has many detractors (and not entirely without reason), nobody can claim that the family of languages it spawned aren't well designed. On the contrary, languages like NewtonScript, Dylan, [Cecil and Diesel,] Goo, PLOT, and now Julia all have a hard to grasp quality without a name that makes them an improvement over many of their successors.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

A bit of a letdown

Yet another "Common Lisp" with infix notation. And ponies. And not quite working...

Build issues?

Hi, I'm one of the julia developers. I can totally imagine your reaction to a new language. However, why do you say it's not quite working? Can you elaborate? Is it a build issue, or are you trying binaries? In general, a number of people have reported build issues related to OpenBLAS. Your feedback would be greatly useful in fixing the relevant bugs.

Error Repair

Why not include some practicable Burke-Fischer error repair (http://www.ccs.neu.edu/home/turon/icfp-2011-slides.pdf), and then extend it to semantic errors as well :-) Then we'd have DWIM, the successor to ISWIM.

Java Grande on Lisp

I remember 1-2 decades ago Java(*) was promoted for
scientific computation. JDK 1.2 could easily beat
some C or FORTRAN linpacks. Meanwhile Java has mostly
evolved in the type system but also in the backend,
particularly GC.

If I look at your language it looks more that it aims
at being a script language and not a compiled language.
For example you issue a warning when ambiguious overloading
happens already during the declaration (**), which more or
less forces the programmer to order declarations, if he
doesn't want to get warnings.

In Java I can order declarations as I wish, here some
JDK 1.7 code:

    public static String f(String x, Object y) {
        return "f2 "+x+", "+y;
    }

    public static String f(Object x, String y) {
        return "f3 "+x+", "+y;
    }

    public static String f(String x, String y) {
        return "f1 "+x+", "+y;
    }

    public static void main(String[] args) {
        System.out.println("f(1,2)="+f("a","b"));
        System.out.println("f(1,2.0)="+f("a",Integer.valueOf(1)));
        System.out.println("f(1.0,2)="+f(Integer.valueOf(1),"b"));
    }

The specific method is declared last. The output is:

f(1,2)=f1 a, b
f(1,2.0)=f2 a, 1
f(1.0,2)=f3 1, b

Any particular scientific method underlying the development of the "warnings" of Julia, or are they just ad-hoc? Are there more "warnings" around? Is there a summary list?

Bye

(*)
http://www.javagrande.org/

(**)
http://julialang.org/manual/methods/

Plotting is the Killer Feature

I use Matlab every single day in my capacity as a data oriented neuroscientist. I am also a deep lover of Lisp, and as such I can make the following observation.

The precise language semantics are nice things to get right, but Matlab's real powers are twofold: 1) it lets me write relatively sloppy matrix code and its jit makes it fast enough to do interactive data exploration, and 2) it has a rich system for displaying that data and interacting with it visually (eg, zooming in on data, associating mouse clicks with other transformations, making different kinds of plots, etc), whipping up quick and dirty applications for specific data analysis pipelines that require human interaction.

Julia might compete with the former, but as of now it doesn't have a plotting system, as I understand it. This is an absolutely critical feature, especially if you want to get matlab users to convert.

Secondly, as a Lisp programmer, I can only ask "who cares about non-s-expression syntax?" I am always astounded that s-expressions are an issue for any programmer anywhere. Syntax seems like such a silly thing to worry over.

I know I'm probably in the minority on this one, but would you consider an s-expression syntax? I'd be much, much, much more likely to convert if I could program in s-expressions.

Devil's advocate

If syntax doesn't matter why do you want an s-expression syntax?

Exactly!

Exactly!

Yes, plotting is absolutely

Yes, plotting is absolutely non-negotiable. Currently, we have very basic plotting through the web-repl, using D3. We are certainly going to make this full-featured.

http://julialang.org/images/web_repl.png

Interesting language

But:
1) The manual's section about integers don't talk about overflow so I guess that it has either C/C++ or Java behaviour: each language which implement such poor semantic tend to avoid discussing about overflow, too bad.

2) minor criticism: "elseif" is a bad keyword: "elseif" and "else if" sound the same even if they are different. "elif" doesn't have such problem.

3) for exception processing, if you don't have the equivalent of D's "scope", please make sure that you do: IMHO this makes it much simpler to write readable programs even when they use functions which can throw exceptions.

else if bikeshedding

minor criticism: "elseif" is a bad keyword: "elseif" and "else if" sound the same even if they are different. "elif" doesn't have such problem.

I must say I'm surprised by this idea. Indeed "elseif" and "else if" look the same, they have the exact same meaning! I always thought that the mere existence of an elseif/elif keyword to be an ugly compromise of languages that impose explicit end-markers at the end of conditional blocks -- and therefore can't afford nested "else if ..." constructions.

I say "compromise" rather than "defect", because I recognize this third keyword -- or rather, the explicit end-marker on conditional -- has advantages; in particular it removes the "if .. then .. if .. then .. else" ambiguity, which is a really nasty one.

Long story short, I don't buy your argumentation. I could only say that "elif" is shorter.

Not bikesheeding: just an embarrassing mistake

>Indeed "elseif" and "else if" look the same, they have the exact same meaning!

Thanks for correcting me, I wonder why I became convinced that there was a difference? Oh well another embarrasing mistake.

>I could only say that "elif" is shorter.
It has the same number of character as "else", but I agree that this is a bikeshedding argument.

I think it's better to keep

I think it's better to keep things close to natural language when it doesn't hurt. It helps comprehension, something more important than character count. The newcomer or non CS grad looking at an elseif statement will understand & remember it better than an elif statement.

Julia looks good

As a longtime Java/C#/C++/VB programmer I have never been comfortable with LISPy languages like Clojure - the syntax (or lack thereof) frys my teeny brain.
But I have read the Julia manual and I think I have finally found a LISPy language that I could really use. The section on Metaprogramming explained Expr's in a clear and concise way that I was able to wrap my head around.
Plus, I have always wanted a language that supported multiple dispatch.

floating point

I like the Matlab syntax and Lispy function. Just a nitpick but looking at the raw data types in the manual

1) you might really want to consider longer base types. IEEE 754-2008 (128 bit floats) are now standard in the very spec you are using. x86-64 supports in in hardware and gcc compiles to it. You obviously are aiming for math applications so you need to at least support current hardware.

2) When you define your char type as unicode, and specify 32 bits I'm assuming you are using the UTF-32 encoding and not a UTF-8. I'd say that explicitly since most people reading a manual in English are going to expect UTF-8 encodings when they import data.