No Eclipse!

Welcome to the bonus section, me hearties! Eclipse, and other integrated development environments (IDEs) are for the weak of heart. If you want to understand how real coding is done, we’re going to abandon these land-lubber tools.

Install Sublime Text 2. That’s where we’re going to be doing our coding from now on. It has cool themes for ye picky coders, and you can make it as pretty as you wish.

Now, how do we run the code?

On a Mac, you have an application called Terminal. You can search through your applications and you’ll find it. Alternatively, if you want to be quick, you can use Command-Space keystrokes to activate Spotlight search, where you can search for Terminal.

Open it up. Type in cd ~/Desktop and hit return. You’re now in your Desktop folder! Want to see what’s inside? Type ls, and hit return. You’ll see all the files in your Desktop folder. Let’s create a new folder specially for CS1.

Type in mkdir Bonus_CS1 (and hit return). We’ve created a directory inside of Desktop folder. You can see the folder icon appear on your desktop. Then, type in cd Bonus_CS1 (return, once more). As you can see, the command cd is to change directories. mkdir is a command to make a directory.

Now we’re inside the Bonus_CS1 folder. Let’s create a sample Python program!

Open up Sublime Text 2. On the bottom right, you can see that Sublime wants you to tell it what language you’ll be coding in. There are many, many options.

Click on the “Plain Text” and scroll down to select “Python”. Python is a sub-folder that contains two options:

Choose the ordinary Python option.

Let’s put the following code into the file.

print "Dude, Eclipse is for n00bs."

Okay, now how do we run this code? If you’re on a Mac, you’re lucky. Python is already installed for you! If not, you’re still lucky, since the course instructions made you install Python anyways.

Let’s save this file as within the folder Bonus_CS1. In the future, you won’t have to scroll through the language option and select Python in Eclipse, because it will automatically detect the .py at the end of the file name and realize it must be Python.

Similarly, had you saved the file first (before typing anything inside), Sublime will automatically choose Python as the language for you. Now that we’ve saved the file, we can quite Sublime and go back to Terminal.

Type pwd, which stands for print working directory. It should show that you’re inside the Bonus_CS1 folder. For me, it outputs /Users/chanchan/Desktop/Bonus_CS1. If your name were John, it might show /Users/John/Desktop/Bonus_CS1. Either way, that last part should show Bonus_CS1. That’s the most important part.

Great, now let’s run the code! Type in python (and hit enter). It should output what we printed!

That’s how you run code without Eclipse! Pretty neat. :)

Keep in mind that Python by itself will tell you all the same errors that eclipse does. For example, if you typed in prin instead of print in Sublime, and then ran python in your terminal, it would show you the following error:

    prin 'hello there'
SyntaxError: invalid syntax

Great! Now you don’t need Eclipse anymore. You’ve taken your first step into not being a n00b.