Getting Started and C++
Goals
To get your computers set up for the course and start coding in C++ based on your previous knowledge.
VSCode
You are likely already familiar with VSCode. You should download it if you don’t already have it.
Laptop Setup
(Note this guide is heavily based on Prof. Jeff Ondich’s)
Unix is a family of operating systems and both Linux and macOS are Unix-based. You’ve likely already been using Unix a lot if you have used the lab computers at all since they run macOS. Today’s goal is to get you setup with a Unix system on your own laptop.
macOS
Mac comes with the Terminal app (in Applications/Utilities) where you can work with a Unix command line. However, VSCode comes with the same Terminal, so it’s usually nicest to just use that (Terminal->New Terminal).
Linux
If you are running Linux, you have a terminal app somewhere, though the name varies. You can also just use VSCode’s Terminal.
Windows
If you are running Windows, you will need to install a few more things. Follow this guide for getting the “Windows Subsystem for Linux” installed on your machine and connected to VSCode. You will do everything through VSCode using the WSL extension.
A few notes:
- If your system supports it, go for WSL 2
- Under “Install your Linux distribution of choice”, I recommend that you choose Ubuntu 22.04 LTS (or something 22 LTS, which stands for “long term support”)
Everyone
I recommend installing a few more extensions:
Package managers
Package managers make it easier to install and update software on your machine for the kinds of software that you will use in this class. Which package manager you use will depend on your system.
Windows
You should now have apt
installed through WSL. Double check with which apt
. If you don’t have it, you should definitely have apt-get
, so check for that.
Linux
You should have apt
or apt-get
; double check with which
.
macOS
Mac doesn’t have a proper built-in manager and so you should download Homebrew “The Missing Package Manager for MacOS” :). Follow the instructions on that page to install (if you don’t already have it).
Vi(m), Python3, Git
Now let’s make sure you have everything you need and install anything you are missing.
Open your Terminal VSCode and type:
which vi
Hopefully the answer will be /usr/bin/vi
. The “which” command is asking where the vi
command is located (yes, “where” would probably make more sense). Do it again with two more commands:
which python3
which git
If you don’t have either of those installed, you’ll need to install them using your package manager:
macOS
brew install git
or brew install python3
WSL and Linux
sudo apt install git
or sudo apt install python3
(or apt-get if that’s what you have.)
Git
You know how when you are working on a programming project with a partner and one of you makes some changes and emails it to the other, and then the other makes some changes and emails it back? What about when you accidentally both make changes and forget to use the updated version and aren’t sure which you need? Or what about when you break your code and can’t remember how to get it working again?
Version control software is the answer to all of these problems and it will change your life (no guarantees, but I do really love it). The most popular kind of version control is git and the most popular hosting company for git is GitHub. GitHub has a lot of great features, including an educational wrapper and student packs with additional features, which we’ll be using in this class.
- If you already have a GitHub account and you want to use it for 361, great, just make sure that your Carleton email address is associated with it (Settings->Emails).
- If you don’t have one or want a new one, go to https://github.com/ and use your Carleton email address to make it. I strongly recommend you pick a name that you’d be comfortable putting on a resume.
- Sign up for GitHub’s Student Pack if you haven’t already
- Create a “classic Personal Access Token” (not a fine-grained PAT, they are still in beta). Save your classic PAT somewhere safe. This will serve as your password when downloading your repositories for class. Some notes:
- Set the expiration date past the end of term
- In the “Select the scopes”, just check “repo”, nothing else needed
- Remember to copy and paste it into a note on your local machine!
- Fill out this survey to let me know your GitHub username.
C++ Practice
Go to HackerRank.com and create a Developers account if you don’t already have one (you don’t need to use your real name if you don’t want to!).
Reference this cheat sheet for the code from the video.
Exercises
Complete each of the following HackerRank exercises.
- Solve Me First (Make sure your language is set to C++14)
- Input and Output
- Pointer (you will need the
<cmath>
library andabs()
function) - Feel free to also copy the prompts into VSCode and see if Copilot is helpful or not!
Extra
If you have extra time, try out other HackerRank C++ activities to get more practice. We’ll continue to check in on C++ in the coming weeks, so getting more practice will be helpful.
You can also learn a bit/refresh about Git, which we’ll be using in a basic capacity for submitting assignments.