Getting Started with Julia

This guide helps you set up Julia for working effectively with CensoredDistributions.jl, whether you're using the package for analysis or contributing to its development. It's aimed at people familiar with other technical computing languages (R, Python, MATLAB) but new to Julia workflows.

Note

If you're familiar with other languages for technical computing, these noteworthy differences may be useful.

What this guide is and isn't

This isn't a comprehensive guide to learning Julia programming. Instead, we provide practical setup advice to get you working productively with CensoredDistributions.jl quickly.

To learn Julia programming, we recommend:

Julia Installation with juliaup

  1. Download juliaup: This is the official cross-platform installer/updater for Julia. Go to the juliaup GitHub repository for installation instructions.

  2. Verify Installation: Open a terminal and type julia to start the Julia REPL. You should see a Julia prompt julia>.

Why juliaup? Easy version management, automatic updates, and seamless switching between Julia versions for different projects.

👉 Learn more: juliaup GitHub repository for detailed usage instructions.

Editor Setup: VSCode with Julia Extension

Recommended setup:

  1. Install Visual Studio Code
  2. Install the Julia extension from the VS Code Extensions marketplace (search for "Julia")

Key features:

  • Integrated REPL: Execute code directly from editor
  • Test Explorer: Run individual tests from sidebar with coverage visualization
  • Debugging: Set breakpoints, inspect variables, step through code
  • Plot viewer: Dedicated pane for visualizations
  • Symbol navigation: Go to definitions, find references

👉 Learn more: Julia VSCode documentation

Julia Environments

Julia uses environments to manage project dependencies. Each project can have isolated packages and versions.

Key concepts:

  • Project.toml: Lists project dependencies
  • Manifest.toml: Records exact versions (like a lockfile)
  • Environments can be stacked - global packages available to projects

👉 Learn more: Julia Pkg documentation

Using environments from the REPL

julia> ]                    # Enter package mode
(@v1.11) pkg> activate .    # Activate current directory as environment
(myproject) pkg> add SomePackage   # Add package to project
(myproject) pkg> status     # See what's installed

Common commands:

  • activate . - activate current directory as environment
  • activate --temp - create temporary environment for experiments
  • instantiate - install all dependencies listed in Project.toml

Install these in your Julia version environment (e.g., @v1.11) to make them available across projects:

julia> ]
(@v1.11) pkg> add Revise OhMyREPL BenchmarkTools TestEnv

Recommended packages:

  • Revise: Automatic code reloading - essential for development
  • OhMyREPL: Better REPL with syntax highlighting
  • BenchmarkTools: Performance measurement
  • TestEnv: Easy switching to test environments

startup.jl configuration

Automatically load essential tools by creating ~/.julia/config/startup.jl:

atreplinit() do repl
    # Load Revise for automatic code reloading
    try
        @eval using Revise
    catch e
        @warn "error while importing Revise" e
    end

    # Load OhMyREPL for better REPL experience
    try
        @eval using OhMyREPL
    catch e
        @warn "error while importing OhMyREPL" e
    end

    # Pkg convenience functions
    try
        @eval using Pkg
        @eval st() = Pkg.status()
        @eval up() = Pkg.update()
    catch e
        @warn "error while importing Pkg" e
    end
end

Working with CensoredDistributions.jl

Installing and using the package

julia> ]
(@v1.11) pkg> add CensoredDistributions
julia> using CensoredDistributions

# Start using the package
julia> using Distributions
julia> primary_censored(Gamma(2, 1), Uniform(0, 1))

Working with the tutorials

The tutorials include interactive Pluto notebooks. See the FAQ for detailed instructions on running the notebooks vs. copying code.

Development workflow (for contributors)

If you want to contribute to the package, see the Contributing Guide and Developer FAQ for detailed guidance.

# Clone and enter package directory
git clone https://github.com/EpiAware/CensoredDistributions.jl.git
cd CensoredDistributions.jl

# Start Julia in package environment
julia --project=.
julia> using CensoredDistributions  # Load package (automatically reloads with Revise)

# Make changes to source code - they reload automatically
# Test changes interactively
julia> primary_censored(Gamma(2, 1), Uniform(0, 1))

Running tests

julia> ]
(CensoredDistributions) pkg> test    # Run all tests

# Or from command line
julia --project=. -e 'using Pkg; Pkg.test()'

Quick environment switching

julia> using TestEnv
julia> TestEnv.activate()    # Switch to test environment with package available

Common issues and solutions

Package not found:

julia> ]
pkg> activate .        # Ensure correct environment
pkg> instantiate       # Install missing dependencies

Changes not reflecting:

  • Ensure Revise is loaded in startup.jl
  • Or restart Julia and reload your package

Environment conflicts:

julia> ]
pkg> resolve    # Resolve version conflicts
pkg> update     # Update to compatible versions

Next Steps

With this setup, you're ready to:

Additional Resources

Community & Help:

Package Development: