**This is an old revision of the document!** ----
====== Math 753/853: Installing Julia ====== The goal here is to get you working with Julia. There are a variety of paths toward that goal. You will have to decide which approach is best for you. * Download and install Julia binaries on your own laptop. * From a UNH computer, download and install Julia binaries onto a USB stick. * Log on to [[http://www.juliabox.com|JuliaBox]] using google credentials. * Download the Julia source code and compile it. ===== Download and install Julia binaries on your own laptop ===== The [[http://julialang.org/downloads/|Julia download page]] provides precompiled binaries for Windows, Mac OS X, and Linux operating systems, and [[http://julialang.org/downloads/platform.html|platform-specific instructions]] in case you run into any trouble. ===== Download and install Julia binaries onto a USB stick, using a UNH computer ===== We have not installed Julia on UNH computers, including the ones in Kingsbury N129, for several reasons. One reason is that Julia is evolving rapidly enough that installing and updating across campus is impractical. But more importantly, I think it's best for you, the student, to get some hands-on experience in the free software ecosystem, and to retain as much control as possible of your software environment. To that end, my plan for using Julia on the Kingsbury N129 computers is for students to download and install the Julia binaries for Windows into a folder on a USB stick. I personally don't know much about Windows, so this will be a bit of an in-class experiment. If it doesn't go well, I'll get Academic Technologies to install Julia directly on the Kingsbury N129 computers. ===== Run Julia on JuliaBox ===== If you have a [[https://accounts.google.com/signup|Google account]] you can run Julia on [[https://www.juliabox.com/]]. Just log on with your Google ID. ====== The Julia REPL ====== The simplest way to run Julia is via the Julia REPL (read-eval-print-loop). Once you install Julia, you can start the REPL by double-clicking on the executable file (Windows, Mac OS X, or Linux) by calling Julia from the command-line (Linux). If you are running Julia on JuliaBox, you will need to click the Console tab at the top. You will see a Linux command line prompt like this ''juser@juliabox:~$''. Type ''julia'' after that prompt and hit "enter". You should see something like this <code> _ _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_) | Documentation: http://docs.julialang.org _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release |__/ | x86_64-unknown-linux-gnu </code> The ''julia>'' at the end is the Julia prompt. Type an expression there (e.g. 3+4) and hit the enter key. You should see this. <code> julia> 3+4 7 julia> </code> ----- ====== Julia notebooks ====== A Julia notebook is a system that combines mathematical text, executable Julia code, and graphical output within a web browser. If you have Julia running on a laptop or UNH computer, you can start a notebook as follows Note: you will have to do all these steps //only the first time// you run a Julia notebook. After that you can just start with step 5, ''using IJulia''. **1.** Download a Julia notebook file to your computer. Let's start with notebooks from [[http://sistemas.fciencias.unam.mx/~dsanders/|David Sanders]]' [[https://github.com/dpsanders/hands_on_julia|Hands-on Julia]] tutorial. You can downlad them from the previous link or get them here: * {{:gibson:teaching:fall-2016:math753:hands_on_julia:1._numbers_variables_and_basic_functions.ipynb|1. Numbers, variables and basic functions.ipyn}} * {{:gibson:teaching:fall-2016:math753:hands_on_julia:2._iteration_-_ranges_vectors_and_conditionals.ipynb|2. Iteration - ranges, vectors and conditionals.ipynb}} **2.** Start the Julia REPL by clicking the executable or directly from the command line. <code> _ _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_) | Documentation: http://docs.julialang.org _ _ _| |_ __ _ | Type "?help" for help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 0.4.6 (2016-06-19 17:16 UTC) _/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release |__/ | x86_64-unknown-linux-gnu julia> </code> **3.** At the Julia prompt, type ''Pkg.add("IJulia")''. This tells Julia to download and install the IJulia notebook software onto the computer. <code julia> julia> Pkg.add("IJulia") INFO: Nothing to be done INFO: METADATA is out-of-date — you may not have the latest version of IJulia INFO: Use `Pkg.update()` to get the latest versions of your packages julia> </code> **4.** At the Julia prompt, type ''Pkg.update()''. This tells Julia to download and install any required software updates. This might take a while and print out lots of download & install information. <code> julia> Pkg.update() INFO: Updating METADATA... INFO: Updating cache of ColorTypes... INFO: Updating cache of BinDeps... INFO: Updating cache of ZMQ... INFO: Updating cache of IJulia... INFO: Updating cache of URIParser... INFO: Updating cache of Conda... INFO: Updating cache of HttpCommon... ....and many more such messages... julia> </code> **5.** At the Julia prompt, type ''using IJulia''. This tells Julia to load the IJulia module into your active Julia session. <code> julia> using IJulia INFO: Recompiling stale cache file /home/gibson/.julia/lib/v0.4/IJulia.ji for module IJulia. INFO: Recompiling stale cache file /home/gibson/.julia/lib/v0.4/ZMQ.ji for module ZMQ. INFO: Recompiling stale cache file /home/gibson/.julia/lib/v0.4/Nettle.ji for module Nettle. julia> </code> **6.** At the Julia prompt, type ''notebook()''. This tells Julia to start an IJulia notebook in a browser, either starting up a new browser, if you don't have one running, or as a new tab in an existing browser. <code> julia> notebook() </code> The browser window should look like this, listing the Julia notebooks you downloaded. {{ :gibson:teaching:fall-2016:math753:hands_on_julia:jupyter1.jpg?800 |}} **6.** Click on "Numbers, variables, and basic functions.ipynb" in the browser. That'll start the interactive Julia notebook session. {{ :gibson:teaching:fall-2016:math753:hands_on_julia:jupyter2.jpg?800 |}} **7.** At this point you can click on and modify anything in the Julia notebook. Try clicking on the line that read ''typeof(10)'' and then hitting "shift-return" or "shift-enter" to execute the ''typeof(10)'' statement. i.e. to make Julia evaluate the expression ''typeof(10)'' and respond with the result.