Summary and Setup

Trebuchet

Melissa and her schoolmates built a trebuchet in their physics club. In their first tests they experienced that aiming it is not that easy and intuitive, so they are planning to write a program that automatically aims their trebuchet given the distance of the target and the velocity of the wind.

As for the programming language, they chose Julia since it has state-of-the-art packages for this task and they also read it composes very well. Unfortunately nobody knows this language already, so they have to learn it from scratch.

Prerequisites

You need to understand the concepts of files and directories as well as arrays and indices.

It is beneficial to have some programming experience in another language.

This lesson requires Julia 1.6 or greater

Software Setup


Details

This lesson requires installation of the following components:

  1. terminal emulator (“shell”);
  2. the version control software “git”;
  3. a text editor (either “VSCodium” or “nano”), and;
  4. Julia.

Git and Bash

  1. Download the Git for Windows installer.
  2. Run the installer and follow the steps below:
    1. Click on “Next” four times (two times if you’ve previously installed Git). You don’t need to change anything in the Information, location, components, and start menu screens.
    2. From the dropdown menu, “Choosing the default editor used by Git”, select “Use the Nano editor by default” (NOTE: you will need to scroll up to find it) and click on “Next”.
    3. On the page that says “Adjusting the name of the initial branch in new repositories”, ensure that “Let Git decide” is selected. This will ensure the highest level of compatibility for our lessons.
    4. Ensure that “Git from the command line and also from 3rd-party software” is selected and click on “Next”. (If you don’t do this Git Bash will not work properly, requiring you to remove the Git Bash installation, re-run the installer and to select the “Git from the command line and also from 3rd-party software” option.)
    5. Select “Use bundled OpenSSH”.
    6. Ensure that “Use the native Windows Secure Channel Library” is selected and click on “Next”.
    7. Ensure that “Checkout Windows-style, commit Unix-style line endings” is selected and click on “Next”.
    8. Ensure that “Use Windows’ default console window” is selected and click on “Next”.
    9. Ensure that “Default (fast-forward or merge) is selected and click”Next”
    10. Ensure that “Git Credential Manager” is selected and click on “Next”.
    11. Ensure that “Enable file system caching” is selected and click on “Next”.
    12. Click on “Install”.
    13. Click on “Finish” or “Next”.
  3. If your “HOME” environment variable is not set (or you don’t know what this is):
    1. Open command prompt (Open Start Menu then type cmd and press Enter)

    2. Type the following line into the command prompt window exactly as shown: setx HOME "%USERPROFILE%"

    3. Press Enter, you should see SUCCESS: Specified value was saved.

    4. Quit command prompt by typing exit then pressing Enter This will provide you with both Git and Bash in the Git Bash program.

Video Tutorial

Nano

nano is a basic editor and the default that instructors use in the workshop. It is installed along with Git.

Julia

  • Open a web browser and visit the Julia download page
  • Download the Current stable release for Windows by clicking the 64-bit (installer) link.
  • Run the installer once it finishes downloading.
  • Click on Next to accept the default directory (or after specifying your preferred installation location).
  • On the Select Additional Tasks screen under Other, check the box to Add Julia to PATH.
  • Click Next.
  • Click on Finish.

We will run Julia through the Git-Bash interface. Once you have it installed:

  • Open the Start menu and click on the Git folder.
  • Click on Git Bashnot Git Cmd!
  • A warning message might pop up about a missing icon: click “I see,” and continue.
  • Once the terminal window loads, type julia and enjoy the lesson!

VSCodium

  • Install VSCodium for your platform
  • Start VSCodium
  • Inside VSCodium, go to the Extensions view by clicking View on the top menu bar and then selecting Extensions.
  • In the Extensions view, search for the term “julia” in the Marketplace search box, then select the Julia extension (julialang.language-julia) and select the Install button. This will add Julia to your VSCodium and automatically link the text editor to your copy of Julia you installed earlier.
  • Restart VSCodium.

Then, test that everything works:

  • In VSCodium, create a new file by clicking File on the top menu bar and selecting New File.
  • Inside the file, type println("Hello World!")
  • Save your file by clicking File on the top menu bar and selecting Save. Name your file hello.jl.
  • Run your file by first pressing Ctrl+Shift+P to bring up a command palette for search all commands available in VSCodium. Then type Julia: Execute active file in REPL in the command palette and press Return.
  • If everything works, you should see a message “Hello World!” appear.

Video tutorial

Bash

The default shell in some versions of macOS is Bash, and Bash is available in all versions, so no need to install anything. You access Bash from the Terminal (found in /Applications/Utilities). See the Git installation video tutorial for an example on how to open the Terminal. You may want to keep Terminal in your dock for this workshop.

To see if your default shell is Bash type echo $SHELL in Terminal and press the Enter key. If the message printed does not end with ‘/bash’ then your default is something else and you can run Bash by typing bash.

If you want to change your default shell, see this Apple Support article and follow the instructions on “How to change your default shell”.

Git

For macOS, install Git for Mac by downloading and running the most recent “mavericks” installer from this list. Because this installer is not signed by the developer, you may have to right click (control click) on the .pkg file, click Open, and click Open on the pop up window. After installing Git, there will not be anything in your /Applications folder, as Git is a command line program. For older versions of OS X (10.5-10.8) use the most recent available installer labelled “snow-leopard” available here.

Nano

nano is a basic editor and the default that instructors use in the workshop. See the Git installation video tutorial for an example on how to open nano. It should be pre-installed.

Julia

juliaup:

  • Run curl -fsSL https://install.julialang.org | sh or brew install juliaup if you want to use homebrew.

Manual:

  • Download the current stable release from the Julia download page and follow the installation instructions.

VSCodium

  • Install VSCodium for your platform
  • Start VSCodium
  • Inside VSCodium, go to the Extensions view by clicking View on the top menu bar and then selecting Extensions.
  • In the Extensions view, search for the term “julia” in the Marketplace search box, then select the Julia extension (julialang.language-julia) and select the Install button. This will add Julia to your VSCodium and automatically link the text editor to your copy of Julia you installed earlier.
  • Restart VSCodium.

Then, test that everything works:

  • In VSCodium, create a new file by clicking File on the top menu bar and selecting New File.
  • Inside the file, type println("Hello World!")
  • Save your file by clicking File on the top menu bar and selecting Save. Name your file hello.jl.
  • Run your file by first pressing Ctrl+Shift+P to bring up a command palette for search all commands available in VSCodium. Then type Julia: Execute active file in REPL in the command palette and press Return.
  • If everything works, you should see a message “Hello World!” appear.

Video tutorial

Bash

The default shell is usually Bash and there is usually no need to install anything.

To see if your default shell is Bash type echo $SHELL in a terminal and press the Enter key. If the message printed does not end with ‘/bash’ then your default is something else and you can run Bash by typing bash.

Git

If Git is not already available on your machine you can try to install it via your distro’s package manager. For Debian/Ubuntu run sudo apt-get install git and for Fedora run sudo dnf install git.

Nano

nano is a basic editor and the default that instructors use in the workshop. It should be pre-installed.

Julia

juliaup:

  • Run curl -fsSL https://install.julialang.org | sh.

Manual:

  • Download the current stable release from the Julia download page and unpack the folder to any location that is in your PATH or link the binary in the bin folder to such a location.

VSCodium

  • Install VSCodium for your platform
  • Start VSCodium
  • Inside VSCodium, go to the Extensions view by clicking View on the top menu bar and then selecting Extensions.
  • In the Extensions view, search for the term “julia” in the Marketplace search box, then select the Julia extension (julialang.language-julia) and select the Install button. This will add Julia to your VSCodium and automatically link the text editor to your copy of Julia you installed earlier.
  • Restart VSCodium.

Then, test that everything works:

  • In VSCodium, create a new file by clicking File on the top menu bar and selecting New File.
  • Inside the file, type println("Hello World!")
  • Save your file by clicking File on the top menu bar and selecting Save. Name your file hello.jl.
  • Run your file by first pressing Ctrl+Shift+P to bring up a command palette for search all commands available in VSCodium. Then type Julia: Execute active file in REPL in the command palette and press Return.
  • If everything works, you should see a message “Hello World!” appear.

Video tutorial