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] [file] [args...]
julia [options] -e "code"
julia [options] -E "code"
julia [options] -L file

PARAMETERS

-h, --help
    Displays usage information and available options.

-v, --version
    Prints the Julia version information and exits.

-e, --eval <expr>
    Evaluates the given Julia expression.

-E, --print <expr>
    Evaluates the given Julia expression and prints its result.

-L, --load <file>
    Loads a Julia source file into the current session before other arguments are processed.

-i, --interactive
    Starts an interactive REPL session after command-line arguments are processed.

-q, --quiet
    Suppresses printing the Julia banner at startup.

-P, --procs <n>
    Adds a specified number of worker processes for distributed computing.

-t, --threads <n>
    Sets the number of execution threads available for multi-threading.

--project[=<dir>]
    Activates a specified Julia project environment, defaulting to the current directory.

--sysimage=<file>
    Uses a custom precompiled system image file instead of the default.

--startup-file={yes|no|<file>}
    Controls loading of the user's custom startup file (~/.julia/config/startup.jl).

--check-bounds={yes|no|auto}
    Enables or disables array bounds checking at runtime.

--optimize={0|1|2|3}
    Sets the optimization level for compiled code (higher number for more optimization).

--color={yes|no|auto}
    Enables or disables colored output in the REPL and for warnings/errors.

--depwarn={yes|no|error}
    Controls how deprecation warnings are handled (print, ignore, or error).

--history-file={yes|no}
    Enables or disables loading and saving of REPL command history.

DESCRIPTION

Julia is a high-level, high-performance, dynamic programming language designed for technical computing, data science, and artificial intelligence. It combines the ease of use of scripting languages with the speed of compiled languages. The `julia` command invokes the Julia interpreter, providing a versatile interface for various tasks: running Julia scripts from files, launching an interactive REPL (Read-Eval-Print Loop) for direct code execution and experimentation, executing Julia code snippets directly from the command line, managing project environments and packages, and configuring runtime behavior such as optimization levels, threading, and distributed computing.

Its Just-In-Time (JIT) compilation to native code enables exceptional performance, making it suitable for demanding computational workloads.

CAVEATS

Julia's Just-In-Time (JIT) compilation means that the first execution of a function can be slower due to compilation overhead. Subsequent calls are typically much faster. A full Julia installation is required for the `julia` command to function. Memory usage can be significant for large-scale scientific computations.

INTERACTIVE REPL

Running `julia` without any arguments launches an interactive Read-Eval-Print Loop (REPL). This is an excellent environment for trying out code snippets, debugging, and interactive data analysis.

SCRIPT EXECUTION

To execute a Julia script, simply provide the path to the .jl file as an argument: `julia my_script.jl arg1 arg2`. Any arguments following the script file are passed to the script.

PACKAGE MANAGEMENT

The Julia REPL includes a powerful built-in package manager. By typing `]` in the REPL, users can enter package manager mode to easily add, remove, update, and manage project dependencies and environments.

HISTORY

Julia was initially announced to the public in 2012, with version 1.0 released in August 2018. From its inception, the `julia` command-line utility has been the primary interface for users to interact with the language. Its design has evolved to incorporate advanced features like multi-threading, distributed computing, and flexible package management, reflecting Julia's growth into a robust platform for high-performance technical computing. The CLI options provide fine-grained control over the runtime environment, critical for diverse applications ranging from scripting to complex simulations.

SEE ALSO

python(1), perl(1), R(1), gcc(1), make(1)

Copied to clipboard