Installing and Using Julia

Installing Julia

The latest release of Julia (1.10.4) can be downloaded at https://julialang.org/downloads/. Julia is available for Windows, macOS, and Linux. Windows will be used for the demonstrations in class, but Mac and Linux should work with no complications for all class assignments (see https://julialang.org/downloads/platform/ for detailed download instructions for each platform). Using the 64-bit (installer) for Windows, download and run the executable file julia-1.10.4-win64.exe and accept all of the defaults (note: if an earlier version of Julia is on your computer, easiest to first uninstall the earlier version).

After starting Julia using the desktop icon, the Julia window will open. Type ] at the command prompt to switch to package manager mode and then add IJulia (note: it can take quite a while to add and load a package) and then build IJulia. When finished, use the Backspace key to return to the Julia command prompt. Type using IJulia, then jupyterlab(), and then y to install Jupyter via Conda (note: if you have Anaconda installed on your computer, Jupyter should already be installed, and this step is unnecessary). JupyterLab will launch in your default browser. (Note: if you had a previous version of Julia installed on your computer, you should update all of your previously installed packages by typing up in the package manager.)

Using the File Browser on the left of the JupyterLab window, select/create a new folder where you can save the notebooks that will be used for this class (e.g., select Documents and then create and then select a new folder ISE754). In the Launcher tab of the browser window, select the Julia 1.10.4 icon under Notebook, and a new notebook named Untitled.ipynb will be created. At the prompt in the first cell, type "Hello world" and then Cntl+Enter to print it below in a new output cell. After saving your notebook, the easiest way to close and exit JupyterLab and Julia is to close their windows.

To open the notebook later, start Julia and at the command prompt and type using IJulia, then jupyterlab(), and the notebook will open in your browser. To create a new notebook, under the File menu in JupyterLab, select New and then Notebook, and then in the Select Kernel pop-up window, select Julia 1.10.4.

Using Julia

After launching Julia, execute using IJulia followed by jupyterlab() at the command prompt to launch Jupyter in your default browser. Julia has an extensive set of built-in functions and additional packages related to more specialized topics. It can be used in two different ways: as a traditional programming environment and as an interactive calculator.

In calculator mode (running Julia either in Jupyter or at the command prompt), the built-in and package functions provide a convenient means of performing one-off calculations and graphical plotting. In programming mode, running Julia in an IDE like Visual Studio Code (VS Code) with Julia extensions provides a programming environment (editor, debugger, and profiler), enabling users to write their own functions and scripts.

Loading Packages

Julia has a variety of third-party open-source packages that will be used to provide additional functionality. The first time they are used in a notebook, the command using "PackageName" loads the package.

If any package has not yet been added to Julia on your computer, the package manager in Julia should first be used to download it. (If you are already running Julia and JupyterLab on your computer, you can start another Julia instance to get a command prompt.) Type ] at the command prompt to switch to package manager mode and then add "PackageName" (note: it can take quite a while to add and to load some packages). When finished, use the Backspace key to return to the Julia command prompt.

To search for packages: https://juliapackages.com/packages

References

  1. Robert Hildebrand, Editor, Mathematical Programming and Operations Research: Modeling, Algorithms, and Complexity with Examples in Python and Julia, 2020 (part of the Open Optimization project).
  2. Changhyun Kwon, Julia Programming for Operations Research, 2nd Edition, 2019.
  3. Allen Downey and Ben Lauwens, Think Julia: How to Think Like a Computer Scientist, 2018 (is a good book-level intro to Julia, most introductory materials for Julia are videos).
  4. The Fast Track to Julia, best cheat sheet for Julia 1.0
  5. Julia Data Science, open source book on how to do data science using Julia
  6. Introduction to Datascience: Learn Julia Programming, Math & Datascience from Scratch, Karthikeyan A K, open source book that teaches the basics of Julia needed for data science applications (new material is added to the book on an ongoing basis).