_
_ _ _(_)_ |
(_) | (_) (_) | A fresh approach to technical computing
_ _ _| |_ __ _ |
| | | | | | |/ _` | | http://julialang.org
| | |_| | | | (_| | | julia-dev@googlegroups.com
_/ |\__'_|_|_|\__'_| |
|__/ |
Julia is a high-level, high-performance dynamic language for technical computing, with syntax that is familiar to users of other technical computing environments. It provides a sophisticated compiler, distributed parallel execution, numerical accuracy, and an extensive mathematical function library. The library, mostly written in Julia itself, also integrates mature, best-of-breed C and Fortran libraries for linear algebra, random number generation, FFTs, and string processing. More libraries continue to be added over time. Julia programs are organized around defining functions, and overloading them for different combinations of argument types (which can also be user-defined). For a more in-depth discussion of the rationale and advantages of Julia over other systems, see the following highlights or read the introduction in the manual.
Julia's LLVM-based JIT compiler combined with the language's design allow it to approach and often match the performance of C/C++. The following benchmarks are from a Macbook with 2.1GHz Intel Core 2 Duo:
____________________________________________________________________________________
Julia Matlab Octave Python/NumPy C++ (GCC)
46c2c6de R2011a 3.4 2.7.1/1.5.1 4.6.1 -O3
____________________________________________________________________________________
fib .500 309. 570. 7.49 .179
parse_int .210 124. 557. .630 .151
mandel 1.82 40.0 260. 9.64 .530
quicksort .640 71.0 1611. 30.6 .600
pi_sum 49.5 69.0 20578. 1289. 49.3
rand_mat_stat 38.9 139. 517. 363.
____________________________________________________________________________________
Figure: benchmark time (ms) across various programming system versions.
Julia beats other high-level systems on all micro-benchmarks above. It also comes within a factor of two of optimized C++ on all but two tests, and is never more than four times as slow. Relative performance between languages on other systems is similar. These benchmarks, while not comprehensive, do test compiler performance on a range of common code patterns, such as function calls, string parsing, sorting, numerical loops, random number generation, and array operations.
Note: A C++ implementation of random matrix statistics is missing because this test involves many whole-matrix operations, and it is not clear what an idiomatic implementation would look like.
Julia does not impose any particular style of parallelism on the user. Instead, it provides a number of key building blocks for distributed computation, making it flexible enough to support a number of styles of parallelism, and allowing users to add more. The following simple example demonstrates how to count the number of heads in a large number of coin tosses in parallel.
nheads = @parallel (+) for i=1:100000000
randbit()
end
This computation is automatically distributed across all available compute nodes, and the result, reduced by summation (+
), is returned at the calling node.
The core of the Julia implementation is licensed under the MIT license. Various libraries used by the Julia environment include their own licenses such as the GPL, LGPL, and BSD (therefore the environment, which consists of the language, user interfaces, and libraries, is under the GPL). Core functionality is included in a shared library, so users can easily and legally combine Julia with their own C/Fortran code or proprietary third-party libraries. Furthermore, Julia makes it simple to call external functions in C and Fortran shared libraries, without writing any wrapper code or even recompiling existing code. You can try calling external library functions directly from Julia's interactive prompt, playing with the interface and getting immediate feedback until you get it right. See LICENSE for the full terms of Julia's licensing.
## Resources- Homepage: http://julialang.org
- Discussion: julia-dev@googlegroups.com
- Source code: https://github.com/JuliaLang/julia
- Git clone URL: git://github.com/JuliaLang/julia.git (see below)
- Documentation: https://github.com/JuliaLang/julia/wiki
- GNU make — building dependencies.
- gcc, g++, gfortran — compiling and linking C, C++ and Fortran code.
- curl — to automatically download external libraries:
- LLVM — compiler infrastructure.
- fdlibm — a portable implementation of much of the system-dependent libm math library's functionality.
- MT — a fast Mersenne Twister pseudorandom number generator library.
- OpenBLAS — a fast, open, and maintained basic linear algebra subprograms (BLAS) library, based on Kazushige Goto's famous GotoBLAS.
- LAPACK — library of linear algebra routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems.
- ARPACK — a collection of subroutines designed to solve large, sparse eigenvalue problems.
- FFTW — library for computing fast Fourier transforms very quickly and efficiently.
- PCRE — Perl-compatible regular expressions library.
- GNU readline — library allowing shell-like line editing in the terminal, with history and familiar key bindings.
- GNU/Linux: x86/64 (64-bit); x86 (32-bit).
- Darwin/OS X: x86/64 (64-bit); x86 (32-bit) is untested but should work.
Julia's binary installs ship as platform-specific tarballs:
- GNU/Linux x86/64: https://github.com/downloads/JuliaLang/julia/julia-08b1e294ed-Linux-x86_64.tar.gz
- Darwin/OS X x86/64: https://github.com/downloads/JuliaLang/julia/julia-08b1e294ed-Darwin-x86_64.tar.gz
- GNU/Linux x86: https://github.com/downloads/JuliaLang/julia/julia-618b93c22c-Linux-i686.tar.gz
Download the appropriate tarball and untar it somewhere; for example, if you are on an OS X (Darwin) x86/64 system, do the following:
curl -OLk https://github.com/downloads/JuliaLang/julia/julia-08b1e294ed-Darwin-x86_64.tar.gz
tar zxvf julia-08b1e294ed-Darwin-x86_64.tar.gz
You can either run the julia
executable using its full path in the directory created above, or add that directory to your executable path so that you can run the julia program from anywhere:
export PATH="$(pwd)/julia:$PATH"
Now you should be able to run julia like this:
julia
If everything works correctly, you will see a Julia banner and an interactive prompt into which you can enter expressions for evaluation. You can read about getting started in the manual.
## Source Download & CompilationFirst, acquire the source code either by cloning the git repository (requires git to be installed):
git clone git://github.com/JuliaLang/julia.git
or, if you don't have git installed, by using curl and tar to fetch and unpack the source:
mkdir julia && curl -Lk https://github.com/JuliaLang/julia/tarball/master | tar -zxf- -C julia --strip-components 1
Next, enter the julia/
directory and run make
to build the julia
executable.
When compiled the first time, it will automatically download and build its external dependencies.
This takes a while, but only has to be done once.
Note: the build process will not work if any of the build directory's parent directories have spaces in their names (this is due to a limitation in GNU make).
Once it is built, you can either run the julia
executable using its full path in the directory created above, or add that directory to your executable path so that you can run the julia program from anywhere:
export PATH="$(pwd)/julia:$PATH"
Now you should be able to run julia like this:
julia
If everything works correctly, you will see a Julia banner and an interactive prompt into which you can enter expressions for evaluation. You can read about getting started in the manual.
## Platform-Specific NotesOn some Linux distributions (for instance Ubuntu 11.10) you may need to change how the readline library is linked. If you get a build error involving readline, try changing the value of USE_SYSTEM_READLINE
in Make.inc
to 1
.
On Ubuntu, you may also need to install the package libncurses5-dev
.
attic/ old, now-unused code
contrib/ emacs and textmate support for julia
doc/ miscellaneous documentation and notes
examples/ example julia programs
external/ external dependencies
install/ used for creating binary installs
j/ source code for julia's standard library
lib/ shared libraries loaded by julia's standard libraries
src/ source for julia language core
test/ unit and function tests for julia itself
ui/ source for various front ends
Add the following line to ~/.emacs
(require 'julia-mode "JULIA_PATH/contrib/julia-mode.el")
where JULIA_PATH
is the location of the top-level julia directory.
Copy (or symlink) the TextMate Julia bundle into the TextMate application support directory:
cp -r JULIA_PATH/contrib/Julia.tmbundle ~/Library/Application\ Support/TextMate/Bundles/
where JULIA_PATH
is the location of the top-level julia directory.
Now select from the menu in TextMate Bundles > Bundle Editor > Reload Bundles
.
Julia should appear as a file type and be automatically detected for files with the .j
extension.
Adjusting your terminal bindings is optional; everything will work fine without these key bindings.
For the best interactive session experience, however, make sure that your terminal emulator (Terminal
, iTerm
, xterm
, etc.) sends the ^H
sequence for Backspace
(delete key) and that the Shift-Enter
key combination sends a \n
newline character to distinguish it from just pressing Enter
, which sends a \r
carriage return character.
These bindings allow custom readline handlers to trap and correctly deal with these key sequences; other programs will continue behave normally with these bindings.
The first binding makes backspacing through text in the interactive session behave more intuitively.
The second binding allows Shift-Enter
to insert a newline without evaluating the current expression, even when the current expression is complete.
(Pressing an unmodified Enter
inserts a newline if the current expression is incomplete, evaluates the expression if it is complete, or shows an error if the syntax is irrecoverably invalid.)
On Linux systems, the Shift-Enter
binding can be set by placing the following line in the file .xmodmaprc
in your home directory:
keysym Return = Return Linefeed