Julia Fast scientific language
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
juliajulia <file.jl> <args>
julia -e '<expr>'
julia --project=.
]?julia -t autoinclude("<file.jl>")
Concepts
- Generic function name: area
- Dispatch all argument types
- Method specialized, compiled
- Fast native code reused after
Command line
juliajulia <file.jl> <args>
julia -e '<expr>'
julia -E '<expr>'
julia --project=<dir>
julia -t <n|auto>
julia -p <n|auto>
julia -i <file.jl>
julia -L <file.jl>
julia --startup-file=no
REPL
?];BackspaceCtrl+D / exit()
Ctrl+CansCtrl+Rmethods(<f>)
@time <expr>
Reviseinclude("<file.jl>")
using <Pkg>
import <Pkg>
Packages
add <pkg>rm <pkg>statusupactivate <dir>
activate --tempinstantiatetestprecompiledev <path or name>
st -oadd <pkg>@<ver>
generate <Name>
using Pkg; Pkg.add("<pkg>")
Basics
x = 3; y = x^2println("x = $x")
"a" * "b"
if a < b ... elseif ... else ... end
for i in 1:10 ... end
while <cond> ... end
function f(x, y=2; k=1) ... end
f(x) = x^2x -> x^2(1, "a")
Dict("a" => 1)
d["a"]get(d, k, <default>)
1:2:9typeof(x)try ... catch e ... finally ... end
Arrays
[1, 2, 3][1 2; 3 4]A[i, j]A[2:end, :]push!(v, x)length(v) / size(A)
zeros(n, m) / ones(n)
rand(n, m)collect(1:5)[f(x) for x in v if <cond>]
f.(v)v .+ 1map(f, v) / filter(f, v)
reduce(+, v) / sum(v)
sort(v) / sort!(v)
A'A * B / A .* Bzip(a, b) / enumerate(v)
v[v .> 0]Types & dispatch
struct P x::Float64; y::Float64 end
mutable struct C n::Int end
P(1.0, 2.0)area(s::Circle) = pi * s.r^2
abstract type Shape end
struct Circle <: Shape ... end
Base.show(io::IO, p::P)
struct Box{T} v::T end
f(x::T) where T<:Number
methods(f)@which f(x)f(a, b...) / f(v...)
Macros & tooling
@time f(x)@btime f($x)@show x@code_warntype f(x)
Threads.@threads for ...
@testset "name" begin ... end
@test <expr>
@kwdef struct ... end
Recipes
mkdir myproj && cd myprojjulia --project=.# ] then: add DataFrames# julia> using DataFrames
git clone <url> && cd <repo>julia --project=. -e 'using Pkg; Pkg.instantiate()'julia --project=. src/main.jl
# main.jlfunction (@main)(args) println("got $(length(args)) args") return 0end
# julia -t 4 sum.jlusing Base.Threadsv = rand(10^6)s = Atomic{Float64}(0)@threads for x in v atomic_add!(s, x)end
Help
?<name>



