# Day 1: Installation and Setup When you are programming, you mainly need three tools: 1. Command Line or Terminal to run the programs. 2. A programming language in which you write the programs. Example: Ruby, Go, Java, etc. 3. An Integrated Development Environment (IDE) to write the program. Example: Visual Studio Code, Sublime Text, etc. Let’s get you set up with all three. ## Step 1: Install iTerm2 So far, you’ve been using drag-and-drop applications, by pointing and clicking on icons. A terminal lets you type commands which let you accomplish anything. If you have never used a terminal before, think of it as a powerful way to interact with your computer. Imagine you are a tourist in a foreign country. You don’t speak the language, but you can point to things and communicate with locals by making gestures. Now you could probably get by like this for a while, and it’s enough if you’re just travelling or passing by. However, if you want to stay in that country for a long term, start a business, or be part of the community, you have to speak that language. Using the graphical applications and pointing and clicking at things is like the first way. Using a terminal is the second way. **To become a programmer, you must be familiar with a terminal.** At first, using a terminal feels slow, but as you get better, you will spend most of your time during development in terminal. Your Mac comes with an integrated terminal out of the box. You can open it in one of two ways: - Click the Launchpad icon in the Dock, type Terminal in the search field, then click Terminal. - In the Finder, open the **/Applications/Utilities** folder, then double-click Terminal. It should open a window like this: ![](https://paper-attachments.dropboxusercontent.com/s_D4A466A9927FB20A54301ADB4FE3556414E59BB1B5365514CCEACACB86A9E0C9_1703660583739_CleanShot+2023-12-27+at+12.32.592x.png) However, we will be using a different terminal called [iTerm2](https://iterm2.com/). It’s a powerful replacement for the default Terminal on Mac. You can check out all the features [here](https://iterm2.com/features.html), but just trust me that your development experience will be much better with iTerm. I’ve been using if for the past many years, and love it. [Download and Install iTerm2](https://iterm2.com/) ![iTerm2](https://paper-attachments.dropboxusercontent.com/s_D4A466A9927FB20A54301ADB4FE3556414E59BB1B5365514CCEACACB86A9E0C9_1703661183431_CleanShot+2023-12-27+at+12.42.552x.png) The ~ stands for “your home directory”. This is where you are: your home directory. Let’s write your first command to print the text “hello world” on the terminal. $ echo "hello world" hello world Here, `echo` is a command, and you are passing the text “hello world” to it. When you hit Enter, the terminal prints the text on the screen. If you want to change to a different directory, you use the `cd` command, passing the name of the directory you want to switch to. `cd` stands for change directory. If you want to go back to the previous directory, type `cd ..` command $ cd Desktop $ Desktop $ cd .. That’s probably more than enough knowledge of the terminal to begin with. As we progress, we will learn more about the terminal. Finally, as a bonus, also install [Oh My Zsh](https://ohmyz.sh/). > Oh My Zsh is a delightful, open source, community-driven framework for managing your terminal configuration. It comes bundled with thousands of helpful functions, helpers, plugins, and themes. If you are like me, you care about your work environment. You will spend a lot of time in your terminal, so it’s good to have the best possible toolset you can. Oh My Zsh just makes your experience very pleasurable. Once you start using both iTerm2 and Oh My Zsh, you won’t feel like going back. Trust me. ## Step 2: Install Ruby To program in Ruby, we first have to install it on our computer. If you’re on a Mac, it already comes with Ruby. However, it’s most likely an older version of Ruby. It’s also used by the system programs on your operating system so it’s best not to use it or mess with it. We will download the separate, latest version of Ruby. There are many ways to install Ruby on your computer. The simplest way is to download Ruby is to use [Homebrew](https://brew.sh/), a package manager for macOS and Linux. Homebrew is a very useful tool as it lets you easily download various software packages. Later, we'll use Homebrew to install a database such as MySQL and other tools. So it’s best to download it right away. **Download Homebrew** Install Homebrew by copy + pasting the following script into your Terminal window. $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" *Note: Check out the* [*website*](https://brew.sh/) *to understand what the above script does.* Once it finishes, test if it was successfully installed by running the following command: $ brew --version Homebrew 4.0.10 If it prints the version, it means Homebrew was successfully installed. The next step is to install Ruby. Run the following command in the terminal: $ brew install ruby It takes a while, but once it's installed, you can run the following command to see if everything went OK. $ ruby --version If it prints the Ruby version you installed, you're good to go. All right, you have installed all the necessary tools and are now all set and ready to program. ## Step 3: Install Visual Studio Code We will use VS Code for our IDE. In my opinion, it’s one of the best editors out there which is both powerful and lightweight at the same time. > Some of you might be fans of Sublime Text, so feel free to use it instead. You can download and install VS Code [here](https://code.visualstudio.com/download). Next, we will create a new directory to save all our programs. In the terminal, use the `mkdir` command to create a directory named **code**. Then, use the cd` command to switch into that directory. $ mkdir code $ cd code Finally, open the VS Code, and open the **code** directory. > You can also launch VS Code directly from the terminal. See [this article](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line) to learn how. Now create a new file in this directory called `main.rb`. This is the file where our Ruby code will live. To run simple programs, we will use the in-built terminal included in the VS Code. You can open and close it using the `Ctrl + `` keyboard shortcut. ![](https://paper-attachments.dropboxusercontent.com/s_D4A466A9927FB20A54301ADB4FE3556414E59BB1B5365514CCEACACB86A9E0C9_1703663414322_CleanShot+2023-12-27+at+13.20.032x.png) FYI, this was the first IDE I ever used, when they taught us C++ in college. Not a surprised many of my classmates gave up and left computer science. ![Borland Turbo](https://paper-attachments.dropboxusercontent.com/s_D4A466A9927FB20A54301ADB4FE3556414E59BB1B5365514CCEACACB86A9E0C9_1703767579403_borland.webp) ## Writing the First Program Now that we have installed the necessary tools on the computer, the next step is to write a simple program and run it. Let's write the first line of Ruby code that prints a greeting when executed. print 'Hello World' That's it. We're done. This is a complete Ruby program. Nothing else is needed. No `require` or `include` statements, no `public static void main()`, no semi-colons, no indentations, nothing. Let's run it. In the terminal window, navigate to your directory and run the following command. $ ruby code.rb Ruby will execute our program and print 'hello world' on the screen. ![](https://paper-attachments.dropboxusercontent.com/s_D4A466A9927FB20A54301ADB4FE3556414E59BB1B5365514CCEACACB86A9E0C9_1703663698932_CleanShot+2023-12-27+at+13.24.502x.png) Amazing, right? Congratulations, that was your first Ruby program. We are now ready to start programming. In the next lesson, we will learn one of the most fundamental concept in programming, something called **a variable**.