Julia: A Language for Data Science, Visualization, and Machine Learning

To update or switch versions, run webi julia@stable (or @v1.10, @beta, etc).

Cheat Sheet

Julia is a programming language for Data Science - a far better alternative to (or plugin for) Python when performance matters.

Table of Contents

  • Files
  • Hello World
  • Compile for Distribution
  • Vim Plugin

Files

These are the files / directories that are created and/or modified with this install:

~/.config/envman/PATH.env
~/.local/opt/julia/

How to create a Hello World with Julia

Try out the REPL by coping and pasting the code below (it'll print some nice ASCII art to the console):

julia -i
function mandelbrot(a)
    z = 0
    for i=1:50
        z = z^2 + a
    end
    return z
end

for y=1.0:-0.05:-1.0
    for x=-2.0:0.0315:0.5
        abs(mandelbrot(complex(x, y))) < 2 ? print("*") : print(" ")
    end
    println()
end

Or write the program to ./mandelbrot.jl and run it:

julia ./mandelbrot.jl

How to Build a Distributable Binary with Julia

Here's an example project that you can build:

  1. Clone and enter the example project
    git clone --depth=1 https://github.com/JuliaLang/PackageCompiler.jl ./PackageCompiler
    pushd ./PackageCompiler/examples
    
  2. Run Julia in project mode
    julia -q --project
    
  3. Compile the binary
    using PackageCompiler
    create_app("MyApp", "MyAppCompiled")
    exit()
    
  4. Test & Enjoy
    ./MyAppCompiled/bin/MyApp foo bar --julia-args -t4
    

See also:

How to Install the Language Server (for VSCode, Vim, etc)

Open the Julia REPL and add LanguageServer:

julia -i
using Pkg
Pkg.add("LanguageServer")
Pkg.add("SymbolServer")

You'll need to reinstall if you switch environments.

How to Install the Julia Vim Plugin

julia-vim adds support for:

  • Latex-to-Unicode
  • jumping from between start and end of blocks with %
    (and other block jump sequences)
mkdir -p ~/.vim/pack/plugins/start
git clone https://github.com/JuliaEditorSupport/julia-vim.git \
    ~/.vim/pack/plugins/start/julia-vim

Usage Examples:

  • \alpha<tab> will produce α
    (meaning typing \alpha and hitting the tab key)
  • Hitting % on an end will take you to the function or for, etc

Contribute

Report an Issue Submit Installer Star on GitHub