Julia Cheat Sheet
Essential Julia syntax for scientific computing, including arrays, broadcasting, multiple dispatch, and the type system.
2 PagesIntermediateMar 22, 2026
Basics
Variables, strings, and functions.
julia
# Variables and printingx = 42name = "Julia"println("Value: ", x)s = "Hello, $name!" # string interpolationfunction greet(n) return "Hi, $n"endsquare(x) = x^2 # one-line function
Multiple Dispatch
Methods selected by the types of all arguments.
julia
area(r::Float64) = pi * r^2 # circlearea(w::Float64, h::Float64) = w * h # rectanglefunction describe(x::Int) println("$x is an integer")endfunction describe(x::AbstractString) println("$x is a string")end
Arrays
Working with Julia's 1-indexed arrays.
- zeros(3)- Creates a 3-element array of zeros
- arr[1]- Arrays are 1-indexed, not 0-indexed
- push!(arr, x)- Appends x; trailing ! marks a mutating function
- map(f, arr)- Applies function f to every element
- arr .+ 1- Broadcasting: applies + elementwise via dot syntax
- size(arr)- Returns a tuple of the array's dimensions
Type System
Defining and inspecting types.
- Int64 / Float64- Built-in concrete numeric types
- abstract type- Declares a node in the type hierarchy, cannot be instantiated
- struct- struct Point x::Float64 y::Float64 end defines an immutable type
- mutable struct- Same as struct but fields can be reassigned
- typeof(x)- Returns the runtime type of a value
- Union{Int, Nothing}- A type that is either Int or Nothing
Pro Tip
Type-annotate hot-path function arguments (e.g. x::Float64) so Julia can specialize and compile fast machine code instead of falling back to slower generic dispatch.
Was this cheat sheet helpful?
Explore Topics
#Julia#JuliaCheatSheet#Programming#Intermediate#MultipleDispatch#Arrays#TypeSystem#Syntax#DataStructures#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance