Julia vs Python

Julia is a challenger to Python in science, each with an extensive library. The newcomer can it replace the old? (Python dates from 1991).

Demo Julia programming language
Example of Julia code

The development of Julia began in 2009 and the language became popular when the compiler was open sourced in 2012. It is currently available under the MIT license. The objective is to create a language with the advantages of Python (simplicity and dynamism), R (statistical processing), C (execution speed), Perl (string processing), Matlab (linear algebra), and others. It also wants to be distributed, parallel, generic.

In the tradition of Pascal, the language name comes from the French mathematician Gaston Julia, who discovered fractals.

Its simplicity and its scientific capabilities make it a possible alternative to Python. But is it superior? We will not compare the program execution speed because Julia is new and still under development, while Python is optimized for decades and therefore close to its limits. Which one is faster to execute a particular algorithm is significant on the cloud, but on the desktop, what matters is how they behave on large data sets, matrix calculations for example. Some Julia programs are faster than the Python version, but this is not always the case. It really depends on if we call functions compiled to binary, which is the case with most Python libraries, or if they are written in Julia which is necessarily less efficient.

Instead, we compare features and syntaxes. Both languages ​​are meant easy to understand and are aimed primarily at an audience that has no interest in the hardware, and thus in derivatives of C such as the Go language, ​​that are done to simplify the task of the compiler and not improve programmer productivity.

Similarities

Differences

Introduction to the syntax of Julia

Function

The definition begins with the function keyword and ends with end. This is classic, but not optimal, Scriptol simplifies by ending a function with return or return followed by a value.

A function can also be defined by assigning an expression to a name with arguments. For example:

fun(x) = x * 5

println(fun(2))

This should display 10.

What is peculiar to this language is that the return value is the result of the last evaluated expression, unless a return statement is explicitly inserted into the body of the function.
Arrays are passed by reference in arguments and therefore can be changed after a function call.

Operators are functions. You can assign the + symbol to a function f, and make a call to f (x, y), it returns the sum of the two arguments.

Control structures

The if structure is similar to PHP or Python.

The for loop has the form:

for i = 1:n
   ... 
end 

This is as easy as Python albeit with a different syntax .

The iteration on a container has the same form that in Scriptol or other modern languages ​​:

for s in [1, 2, 3] ... end

The while loop is classic :

while a < 5
  a += 5
end

There are no other control structure. No until, no switch. Pattern matching is not envisaged by the creators.

Classes and homoiconicity

Classes are composite types in which are nested functions which become their methods.

type maclass 
   function f(x, y)
     ....
   end
end

There are no prototypes as JavaScript to add members dynamically, but since a program can modify and extend due to homoiconicity, so it must be possible to modify the objects and dynamically add attributes and methods ...

This is covered in the manual, but the examples are not very clear. I note for now that the eval function, such as in JavaScript, can evaluate and integrate a code in the program, and various functions exist for "introspection", ie accessing code by itself.

Should I use Julia?

I'm really impressed by the possibilities of the language. Go and Dart seem to have been designed in another era. Python is left far behind but has the excuse of having been actually designed in another era.
Julia has all the features of Python and even more, the code is just as easy to write, it has similar libraries in science and seems to be an alternative.

It is not perfect either. Nothing is planned for pattern matching, something that is highly developed in Scala, another modern and innovative language. Objects do not support inheritance or compositions which rules out wide applications.
The documentation is sparse and difficult to understand. Most examples are at command line, that nobody actually uses and it is unreadable.
Error messages are especially a weak point. Most errors within a function are reported on line 1, which is the line where the function begins and are therefore difficult to locate. It will be very difficult to learn programming with this language if no progress is made on this point.

Finally, Julia seems really designed for scientific and difficult to use for general purpose scripting. My experience to implement the sieve of Erasthothenes was laborious. One must practice a little divination. Finding nothing in the documentation on how to insert a comment, I used just in case the Python syntax and was lucky it worked! (Actually C syntax is recognized also).
You must address this language with a pioneer spirit, because you will not find at the moment (February 2014), any help on the Web.

Julia Studio is an free IDE dedicated to the language.

References: The site of Julia. The authors are Jeff Bezanson, Stefan Karpinski, Viral B. Shah, Alan Edelman.

Programming and data languages Asm.js - Basic - C - C++ - C# - Dart - Eiffel - Go - Java - JavaScript - Julia - Pascal - PHP - Python - Ruby - Rust - Scala - Scriptol - TypeScript - HTML - XML - XAML - SQL