2  Getting started with Julia

2.1 Setting up VS Code

  1. Download and install Visual Studio Code
  2. Install the Julia extension from the VS Code marketplace
  3. Configure the Julia path in VS Code settings if needed

2.2 Installing Julia

Download Julia from julialang.org.

2.2.1 Windows

  1. Download the Windows installer (.exe)
  2. Run the installer and follow the prompts
  3. Add Julia to your PATH (optional but recommended)

2.2.2 macOS

  1. Download the macOS .dmg file
  2. Drag Julia to Applications
  3. Add to PATH: export PATH="$PATH:/Applications/Julia-1.x.app/Contents/Resources/julia/bin"

2.2.3 Linux

# Using juliaup (recommended)
curl -fsSL https://install.julialang.org | sh

2.3 Basic numerics

1 + 2, sin(1.0)
(3, 0.8414709848078965)

2.3.1 Arithmetic

a = 10
b = 3
a + b, a - b, a * b, a / b
(13, 7, 30, 3.3333333333333335)

2.3.2 Arrays

x = [1, 2, 3, 4, 5]
sum(x), length(x)
(15, 5)

2.4 Functions

f(x) = x^2 + 2x + 1
f(3)
16

2.5 Control Flow

2.5.1 Conditionals

x = 5
if x > 0
    println("positive")
elseif x < 0
    println("negative")
else
    println("zero")
end
positive

2.5.2 Loops

for i in 1:5
    println(i^2)
end
1
4
9
16
25

2.6 Types and Structs

struct Point
    x::Float64
    y::Float64
end

p = Point(1.0, 2.0)
p.x, p.y
(1.0, 2.0)