Julia vs Python
Julia is a Python contender in the scientific field, each with an extensive library. Can a beginner replace an old one? (Python dates from 1991).

Julia Sample Code
Julia's development began in 2009, and the language became popularized when the compiler became open source in 2012. It is currently available under license from MIT. The goal is to create a language with the advantages of Python (simplicity and dynamism), R (statistical processing), C (execution speed), Perl (string processing), Mathlab (linear algebra) and others. He also wants to be distributed, generalized.
In Pascal's tradition, the name of the language comes from the French mathematician Gaston Julia, the discoverer of fractals.
Its simplicity and scientific capabilities make it a possible alternative to Python. But is he any better? It is usually significantly faster than Python, which uses C libraries to compensate for the slow interpreter. It is important to execute the algorithm, but the main thing is how they behave on large data sets, for example, matrix calculations. To the Benchmarks.
The advantage of Python is that libraries can also be written in Julia and compiled, while adding quick functions to Python requires using a different language.
Functions and syntax will also be mapped. Both languages want to be easy to understand and are addressed primarily to an audience that is not interested in hardware, and therefore in languages derived from C, such as Go, which are made to simplify the compiler task, and not increase the programmer's performance .
Similarity
- They can be used on the command line and interactively.
- Dynamic variables.
- Dead ends.
- Nested functions.
- Find the shortest code.
Disagreements
Python uses indents to indicate the hierarchy of program blocks and thus the end. Julia is more classical and any construction ends in endom, as Matlab does (the origin of this syntax goes back to Algol).
When ends accumulate in an algorithm, it becomes harder to know which block is ending. But modern publishers show brackets that show the hierarchy of blocks (as in the image on the right), this is also not a big problem. They have to maintain the language that will come with time.- Python is interpreted even if there are versions compiled in C or Java bytecode.
Julia uses the LLVM JIT compiler and behaves like an interpreter. So there are similarities in use, but a different backend. - Julia's paintings are focused on 1.
- Julia uses the function keyword like JavaScript, while Python uses def. The first is more accurate.
- Lopsided. Like Tcl or Prolog, Julia is implemented as a data view. This allows the program to manipulate itself, transform, expand. Or create another program and execute it, which would be very useful in robotics.
- Polymorphism. The same functions can support different data types and are therefore generated by the JIT in multiple instances (multiple dispatch). This must be added to Python using an external module.
- Coroutines, with the same simplicity as Go.
- Metaprogramming. This follows from lopsidedness.
- Even if the default variables are not of type, they can be given by adding the annotation:: type, for example:
x::int8 = 10.
In - Julia can be found equivalent to C structures with compound types, which are also used to declare objects.
Types created by the programmer are as fast as language types.struct nom ... séquence de variables ... end
- a: b means interval, while Python uses the range (a, b) function and Mathlab something similar .
- [a, b] is the list assigned to the array to initialize it, or how to combine two arrays or add an element to the array. Python requires the append method.
- Julia will know whether the code continues on the next line or not. Python needs to indicate this in the code .
- Defining a macro to insert complex expressions into your code is simple:
macro nom(expr,expr) ...code... end
- Julia is intended for distributed processing, functions performed in parallel. This allows you to process one program in the cloud.
- You can use libraries written directly in C (or Python too).
Introduction to Julia syntax
Function
The definition starts with the function keyword and ends with end. This is usually, but not optimal, the Script language simplifies by completing the function with a return or return followed by a return value.
A function can also be defined by assigning a name expression with arguments. Exempli gratia:
fun(x) = x * 5
println(fun(2))
What 10 should show.
What is characteristic of this language is that the return value is the result of the last evaluated expression, unless the return statement is explicitly inserted into the function body.
Tables are passed by referencing arguments and can therefore be modified by a function call.
Operators are functions. You can assign the symbol + to the function f and call f (x, y), which returns the sum of the two arguments.
Control structures
The if structure is similar to that of PHP or Python .
Loop for shape:
for i = 1:n
...
end
Which is as simple as Python as with other syntax.
Iteration on the container, in the same form as in Script or other modern languages:
for s in [1, 2, 3]
...
end
The while loop is classic:
while a < 5
a += 5
end
There is no other control structure. No, no, no, no. Mattern is not considered by the creators .
Classes and homogeneity
Classes are compound types into which functions are nested, which thus become their methods.
type myclass
function f(x, y)
....
end
end
There are no such prototypes as in JavaScript for dynamically adding members, but since the program can change and expand due to homogeneity, it should be possible to edit objects and add attributes and methods to them...
This is interpreted in the textbook, but the examples are not very vivid. At the moment, I believe that the eval function, as in JavaScript, allows you to evaluate and integrate the code into the program, and that there are various commands for "introspection," access to the code even in accordance with the data.
Should Iuse Julia?
I'm really impressed with the possibilities of that language. You and Dart seem to have been developed at a different time. The python is left very far back, but he has an excuse that it was really developed at another time.
Yulia has all the capabilities of Python and even much more, the code is just as easy to write, it has similar libraries in the scientific field and therefore seems to be an alternative. It even allows you to use Python libraries.
But he's not perfect. Nothing is provided for mattern, something very developed in Scala, another modern and innovative language. Objects do not support inheritance or composition, which is widely used.
The documentation is brief and incomprehensible. Most examples are on the command line and are not very readable.
Error messages were mostly a weak point during my first attempt in 2014. Most errors within a function are marked on line 1, which is a string or begins with a function and is therefore difficult to find.
My experience of implementing the Erasthothenes criterion was time consuming at the time, but would have been easy with the current version.
Updated 23 April 2017
The language has changed a lot since the first test in 2014:
- Possible errors are now clearly identified with the line number in the source.
- Extensions add a matching pattern.
- The site now offers complete language documentation.
Julia Studio is a free EDI dedicated to this language.
Julia v. Python. Comparison of languages.
Julia On Wasm. How to compile Julia in WebAssembly. Experimental.
Links: Julia's website. Authors - Jeff Besanson, Stefan Karpinsky, Viral B. Shah, Alan Edelman.