LinuxCommandLibrary

julia

Execute Julia programs and enter REPL

TLDR

Start a REPL (interactive shell)

$ julia
copy

Execute a Julia program and exit
$ julia [program.jl]
copy

Execute a Julia program that takes arguments
$ julia [program.jl] [arguments]
copy

Evaluate a string containing Julia code
$ julia [[-e|--eval]] '[julia_code]'
copy

Evaluate a string of Julia code, passing arguments to it
$ julia [[-e|--eval]] '[for x in ARGS; println(x); end]' [arguments]
copy

Evaluate an expression and print the result
$ julia [[-E|--print]] '[(1 - cos(pi/4))/2]'
copy

Start Julia in multithreaded mode, using n threads
$ julia [[-t|--threads]] [n]
copy

SYNOPSIS

julia [options] [--] [script.jl] [args...]

PARAMETERS

-h, --help
    Display this help message

-v, --version
    Display Julia version information

-e, --eval <code>
    Evaluate <code> and exit

-E, --eval-repl <code>
    Like -e but compile to REPL-mode LLVM IR

-i
    Force entering interactive mode after script

-O{0,1,2,3}
    Set optimization level (default: 2)

-p <n>
    Enable <n> parallel workers

--threads [<N>|auto|1]
    Set number of threads (default: 1)

--project[=<dir>]
    Set project directory or @. for active

-J <image>
    Load custom precompiled sysimage file

--sysimage <image>
    Like -J: specify sysimage path

--sysimage-native-code[=yes|no]
    Use native code cache in sysimage

DESCRIPTION

Julia is a high-level, dynamic programming language optimized for technical computing, with performance rivaling C. The julia command launches the interactive REPL (Read-Eval-Print Loop) for live coding or executes .jl scripts with arguments.

In the REPL, users type expressions at the > prompt, press Enter for evaluation, use ; to suppress output, ?expr for help, and exit() to quit. Julia excels in numerical analysis, data science, machine learning, and parallel computing via multiple dispatch, metaprogramming, and just-in-time (JIT) compilation.

Key strengths include a familiar syntax like MATLAB/Python, package ecosystem (via Pkg.jl), and GPU/distributed support. On Linux, install via package managers (apt install julia) or binaries from julialang.org. Startup involves precompilation (visible as "Resolving package versions..."), improving subsequent launches.

Supports project environments for dependency management, threading (--threads auto), and custom sysimages to reduce latency. Ideal for replacing slower interpreted languages in compute-intensive tasks.

CAVEATS

Julia has notable startup latency due to JIT compilation (mitigate with custom sysimages via PackageCompiler.jl).
Requires significant RAM for large packages. Not pre-installed on most distros; manual setup common.

REPL TIPS

Use ?func for docs, @edit func() to edit source, ; suppresses output, ans for last result.
Tab completion and ?history available.

SCRIPT EXAMPLE

julia -e 'println("Hello, Julia!")'
Or echo 'println(42)' | julia for one-liners.

HISTORY

Development began in 2009 at MIT by Jeff Bezanson, Stefan Karpinski, Viral Shah, and Alan Edelman to address the 'two-language problem' in scientific computing. First preview 2012 (v0.1); stable 1.0 released 2018 after years of breaking changes. Now at v1.10+ (2024), with growing adoption in HPC, AI, and academia.

SEE ALSO

python3(1), Rscript(1), octave(1), ipython(1)

Copied to clipboard