Author

Klaus Rheinberger

Published

November 20, 2024

Language Overview

At the Julia homepage The Julia Programming Language the language is described as fast, dynamic, reproducible, composable, general, open-source.

Installation

Installation is possible for all common operating systems. Install the Juliaup installation manager, which will automatically install julia and help keep it up to date.

Here is an output of the juliaup status command:

>>> juliaup status
 Default  Channel  Version                 Update
-------------------------------------------------
       *  release  1.11.1+0.x64.linux.gnu

For more information type juliaup help in a terminal.

REPL

The Julia REPL (Read-Eval-Print-Loop) is the command-line interface for Julia. It is started by typing julia in a terminal. It has different modes, e.g. help mode, shell mode, package mode,

  • In the standard Julia mode you can type Julia code and get the output.
  • You can go into help mode by writing a question mark ? at the beginning of the line.
  • You can go into shell mode by writing a semicolon `?; at the beginning of the line.
  • You can go into package mode by writing a closing bracket ] at the beginning of the line.
  • To exit the help, shell, or package mode, type backspace or Ctrl-C.

Here is an example of a simple calculation in the Julia REPL standard mode:

Code
(cos(pi))^2
1.0

Integrated Development Environments

Basic Mathematics

See basic_math.jl.

Packages

In package mode you can add packages with the add command. Here is an example of adding the Plots package:

(@v1.11) pkg> add Plots

Type help in package mode to get information about all available commands.

Plots

The Plots package is a powerful plotting package. Here is an example of a simple plot:

Code
using Plots
plt = plot(size=(500, 300), legend=true)

plot!(plt, sin, -2π, 2π, label="sin(x)", color="red", title="Title", xlabel="x", ylabel="y",
     left_margin=5Plots.mm, bottom_margin=10Plots.mm, grid="on")

x = -2:0.1:2
y = x.^2
plot!(plt, x, y, label="x^2", color="blue")

See also other plotting packages like Makie.

Data Frames

Use the DataFrames package for data manipulation.

Code
using DataFrames
df = DataFrame(A = 1:4, B = ["M", "F", "F", "M"])
df[!, :C] = [1, 2, 3, 4]
df
4×3 DataFrame
Row A B C
Int64 String Int64
1 1 M 1
2 2 F 2
3 3 F 3
4 4 M 4

Optimization

Use the JuMP package for optimization problems. See optimization.jl.

Imprint

See the Imprint of the FHV - Vorarlberg University of Applied Sciences