Jump to content

Julia (programming language)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Stefan.karpinski (talk | contribs) at 19:45, 25 April 2014 (again, this is not a typo – "a factor of two" is the correct idiom, not "a factor or two".). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Julia
Official Julia logo
ParadigmMulti-paradigm: multiple dispatch, procedural, functional, meta
Designed byJeff Bezanson, Stefan Karpinski, Viral B. Shah, Alan Edelman (MIT Group Leader)
First appeared2012
Stable release
0.2.1 / February 11, 2014; 11 years ago (2014-02-11)
Typing disciplineDynamic with optional type annotations and type inference
OSLinux, OS X, FreeBSD, Windows
LicenseMIT License
Filename extensions.jl
Websitejulialang.org
Influenced by
MATLAB, Scheme, Lisp, C, Python, Perl, Ruby

Julia is a high-level dynamic programming language designed to address the requirements of high-performance numerical and scientific computing while also being effective for general purpose programming.[1][2][3] Julia's core is implemented in C and C++, its parser in Scheme, and the LLVM compiler framework is used for just-in-time generation of machine code. The standard library is implemented in Julia itself, using the Node.js's libuv library for efficient, platform-independent I/O. Unusual aspects of Julia's design include having a type system with parametric types in a fully dynamic programming language and adopting multiple dispatch as its core programming paradigm. The most notable aspect of Julia's implementation is its speed, which is often within a factor of two of fully optimized C code.[4] Development of Julia began in 2009 and an open-source version was publicized in February 2012.[5][6]

Language features

Julia draws significant inspiration from various dialects of Lisp, including Scheme and Common Lisp, and it shares many features with Dylan – another multiple-dispatch-oriented dynamic language – and Fortress, another numerical programming language with multiple dispatch and a sophisticated parametric type system. While CLOS adds multiple dispatch to Common Lisp, the addition is opt-in: only user-defined functions explicitly declared to be generic can be extended with new multimethods. In Julia, Dylan and Fortress, on the other hand, this extensibility is the default and the system's built-in functions are all generic and extensible. In Dylan, multiple dispatch is as fundamental as it is in Julia: all user-defined functions and even basic built-in operations like + are generic. Dylan's type system, however, does not fully support parametric types, which are more typical of the ML lineage of languages. By default, CLOS does not allow for dispatch on Common Lisp's parametric types; such extended dispatch semantics can only be added as an extension through the CLOS Metaobject Protocol. By convergent design, Fortress also features multiple dispatch on parametric types; unlike Julia, however, Fortress is statically rather than dynamically typed, with separate compilation and execution phases. This matrix of language features is summarized in the following table:

Language Type system Generic functions Parametric types
Julia dynamic default yes
Common Lisp dynamic opt-in yes (but no dispatch)
Dylan dynamic default partial (no dispatch)
Fortress static default yes

Metaprogramming

Julia, like Lisp, represents its own code in memory using a user-accessible data structure, thereby allowing programmers to both manipulate and generate code which the system can evaluate. This makes complex code generation and transformation far simpler than in systems without this feature. A relatively simple example of the latter is an assert macro that will raise an error if an expression is false:

macro assert(ex)
    :($ex ? nothing : error("Assertion failed: ", $(string(ex))))
end

Notice that while the argument to a function are typically variables, the arguments to macros are expressions. Given an expression, e.g.

@assert 1==0

the macro generates the new expression

1==0 ? nothing : error("Assertion failed: ", "1==0")

where the original expression has been spliced into the condition slot of the ternary operator and has been converted to a string for the error message. Now if the original expression evaluates as true, nothing happens, where if the expression evaluates as false, an error is raised.

Packages

In the Julia packaging system each package is a Git repository that can be stored in any publicly accessible location. A master package listing that includes package dependency information is maintained in METADATA.jl,[7] enabling installation from the Julia prompt:

julia> Pkg.add("PackageName")

Packages are typically written in Julia but can include both binaries and code written in other languages, which can be automatically compiled at package install time by the package manager.

References

  1. ^ "The Julia Language" (official website).
  2. ^ Bryant, Avi (Oct 2012). "Matlab, R, and Julia: Languages for data analysis". O'Reilly Strata. Retrieved 7 February 2013.
  3. ^ Krill, Paul. "New Julia language seeks to be the C for scientists". InfoWorld. Retrieved 7 February 2013.
  4. ^ "Julia: A Fast Dynamic Language for Technical Computing" (PDF). 2012.
  5. ^ "Why We Created Julia". Julia website. Feb 2012. Retrieved 7 February 2013.
  6. ^ Gibbs, Mark (2013-01-09). "Gear head". Network World (column). Retrieved 7 February 2013. {{cite web}}: |contribution= ignored (help)
  7. ^ "METADATA.jl" (central package listing for Julia)