# Julia

> High-level, high-performance dynamic programming language for technical computing with JIT compilation.

- Skill: `ffsshhttiikk/julia` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ffsshhttiikk/julia`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ffsshhttiikk/julia/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT License
- Author: ffsshhttiikk (https://skillmd.com/u/ffsshhttiikk)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/ffsshhttiikk/julia

---


# Julia

## What I do

I am a high-level, dynamic programming language designed for technical computing, numerical analysis, and computational science. I was created by Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and Alan Edelman, first released in 2012. I combine the ease of use of dynamic languages like Python with the performance of compiled languages like C. I feature multiple dispatch, JIT compilation (via LLVM), automatic differentiation, and native support for parallel and distributed computing. I am widely used in scientific computing, machine learning (Flux.jl, MLJ.jl), optimization (JuMP), and data analysis.

## When to use me

Use Julia when performing high-performance scientific computing, numerical simulation, optimization problems, machine learning research, data visualization, or when you need both interactive development and C-like performance.

## Core Concepts

- **Multiple Dispatch**: Functions can have different methods based on the types of all arguments, not just the receiver.
- **JIT Compilation**: Code is compiled to native machine code at runtime using LLVM, combining interpreted feel with compiled speed.
- **Type System**: Optional type annotations for performance and clarity, extensive parametric types.
- **Multiple Return Values**: Functions can return multiple values as tuples, automatically unpacked.
- **Metaprogramming**: Powerful macro system and expression manipulation like Lisp.
- **Native Parallelism**: Built-in support for multi-threading, distributed computing, and GPU computing.
- **Automatic Differentiation**: Packages like ForwardDiff and Zygote for gradient computation.
- **Unicode Support**: Full Unicode support including mathematical symbols as operators (α = 1).
- **Duck Typing with Type Stability**: Code works with any type that supports required operations.
- **Performance Annotations**: @inbounds, @simd, @tturbo for fine-grained performance control.

## Code Examples

**Multiple Dispatch:**
```julia
abstract type Animal end

struct Dog <: Animal
    name::String
    breed::String
end

struct Cat <: Animal
    name::String
    color::String
end

struct Bird <: Animal
    name::String
    species::String
end

# Multiple methods based on all argument types
make_sound(::Dog) = "Woof!"
make_sound(::Cat) = "Meow!"
make_sound(::Bird) = "Tweet!"

function interact(a1::Animal, a2::Animal)
    println("$(a1.name) and $(a2.name) interact")
end

function interact(d::Dog, c::Cat)
    println("$(d.name) the dog chases $(c.name) the cat!")
end

# Method specialization based on all arguments
function describe(a::Animal)
    return "$(a.name) is a $(typeof(a))"
end

function describe(a::Dog)
    return "$(a.name) is a $(a.breed) dog"
end

dog = Dog("Buddy", "Golden Retriever")
cat = Cat("Whiskers", "Orange")
bird = Bird("Tweety", "Canary")

println(make_sound(dog))
println(make_sound(cat))

interact(dog, cat)
interact(dog, bird)
interact(cat, bird)
```

**Performance and Type Annotations:**
```julia
# Type-stable function (fast)
function sum_even(numbers::AbstractVector{<:Integer})
    s = zero(eltype(numbers))
    @inbounds for i in eachindex(numbers)
        if iseven(numbers[i])
            s += numbers[i]
        end
    end
    return s
end

# Parametric types
struct Point{T<:Real}
    x::T
    y::T
end

# Methods with parametric types
Base.:+(p1::Point{T}, p2::Point{T}) where {T} = Point(p1.x + p2.x, p1.y + p2.y)
Base.:-(p1::Point{T}, p2::Point{T}) where {T} = Point(p1.x - p2.x, p1.y - p2.y)

# Type constraints
function distance(p1::Point{T}, p2::Point{T})::T where {T<:Real}
    dx = p1.x - p2.x
    dy = p1.y - p2.y
    return sqrt(dx^2 + dy^2)
end

# Type piracy - avoid!
# function Base.:+(a::Int, b::Int)
#     error("Don't do this!")
# end

# Composite types with inner constructors
struct Rational{T<:Integer}
    num::T
    den::T
    
    function Rational{T}(num::T, den::T) where {T<:Integer}
        den == 0 && throw(ArgumentError("Denominator cannot be zero"))
        g = gcd(num, den)
        new(num ÷ g, den ÷ g)
    end
end

# Outer constructor
Rational(num::T, den::T) where {T<:Integer} = Rational{T}(num, den)

p1 = Point(3.0, 4.0)
p2 = Point(1.0, 2.0)
println(p1 + p2)
println(distance(p1, p2))
```

**Data Science Workflow:**
```julia
using DataFrames
using CSV
using Statistics
using StatsBase

# Create DataFrame
df = DataFrame(
    name = ["Alice", "Bob", "Charlie", "Diana", "Eve"],
    age = [25, 30, 35, 28, 32],
    department = ["Engineering", "Sales", "Engineering", "Marketing", "Sales"],
    salary = [75000, 60000, 85000, 65000, 70000]
)

# Column operations
df.age_max = maximum(df.age)
df.salary_zscore = (df.salary .- mean(df.salary)) ./ std(df.salary)

# Filter and select
engineers = filter(row -> row.department == "Engineering", df)
name_salary = select(df, :name, :salary)

# Groupby and summarize
by_dept = combine(groupby(df, :department), 
                  :salary => mean => :avg_salary,
                  :age => mean => :avg_age,
                  :name => length => :count)

# Join
budgets = DataFrame(
    department = ["Engineering", "Sales", "Marketing"],
    budget = [500000, 300000, 200000]
)

joined = innerjoin(df, budgets, on = :department)

# Statistics
cor(df.age, df.salary)
describe(df)

# Multiple dispatch in data analysis
function analyze_column(col::AbstractVector{<:Number})
    return (mean = mean(col), 
            std = std(col),
            min = minimum(col),
            max = maximum(col))
end

function analyze_column(col::AbstractVector{<:String})
    return (unique = unique(col),
            counts = countmap(col),
            nunique = length(unique(col)))
end

println(analyze_column(df.age))
println(analyze_column(df.department))
```

**Parallel Computing:**
```julia
using Distributed
using Base.Threads

# Add worker processes
addprocs(4)

@everywhere function parallel_sum(n)
    s = 0.0
    for i in 1:n
        s += sin(i) * cos(i)
    end
    return s
end

# Distributed computing
@distributed (+) for i in 1:10000000
    sin(i) * cos(i)
end

# Parallel map
pmap(x -> x^2, 1:1000)

# Multi-threading
function thread_sum(n)
    @threads for i in 1:n
        @atomic sum += i
    end
    return sum
end

# GPU computing (requires CUDA.jl)
# using CUDA
# a_gpu = cu([1, 2, 3, 4])
# b_gpu = a_gpu .* 2

# Performance benchmarks
using BenchmarkTools

function benchmark_example(n)
    s = zero(Float64)
    @btime for i in 1:$n
        $s += sin(i) * cos(i)
    end
    return s
end

# Memory allocation tracking
@allocated 1 + 2

# Code warming and JIT
@time parallel_sum(1000000)
@time parallel_sum(1000000)  # Faster after JIT
```

## Best Practices

1. **Type Annotations for Performance**: Add type annotations to function signatures and struct fields for performance.
2. **Avoid Global Scope**: Define functions inside modules; use const for global variables.
3. **Use Multiple Dispatch**: Write functions with specific methods for different types to leverage dispatch.
4. **Preallocate Outputs**: Preallocate arrays and vectors instead of growing them in loops.
5. **Use @inbounds and @simd**: Add performance annotations when you're certain bounds are safe.
6. **Use @time and @btime**: Profile code to identify bottlenecks before optimizing.
7. **Use Revise.jl**: Use Revise for package development to see changes without restarting Julia.
8. **Follow Performance Tips**: Read the official performance tips in Julia documentation.
9. **Use Packages from Registry**: Use registered packages from JuliaHub for reliability.
10. **Write Tests with Test.jl**: Use Test.jl for unit testing with @test, @testset macros.

