“Hello World”, and What the Heck is a Text Editor?

Screen Shot 2014-10-29 at 12.34.18 AM

Screen Shot 2014-10-28 at 11.19.16 PM
Codecademy environment, Ruby Tutorial…Left is instructions, center is where you type the code, and right is where you see the program run.

As I’ve been making my way through tutorials, something was starting to bother me. Tutorials let you practice in nice little environments that provide three fields: One for the tutorial’s instructions, a second for you to write code, and a third to show the results of your programs.

The problem is…This all happens on a webpage, and I couldn’t figure out how that translates to writing actual code and having it do something on my real computer.  If I don’t know this, I would bet that others as green as me don’t really know either.  Thus, I decided to figure it out (with help of course), and spell it out in this post.  Maybe this will be helpful to other novices out there, and I know it will be helpful to me in the future if I need a reminder.

I asked my most trusted advisor, the husband, how to program something for real, and he explained the steps you need to go through. The “Hello, world!” program seems to be an initiation ritual of sorts, so I decided to use my little “programming for real” lesson to make my computer say “Hello, world!”

Here’s what I learned:

First, you need to create a text file. (Inner monologue: Oh sure, I know what those are! Like a Microsoft Word document, right? Nope …of course not, that would be too easy!) Microsoft Word is a word processor.  To write and run a program, you need to create a plain text document with a text editor.

Screen Shot 2014-10-28 at 11.02.08 PM

A text editor is simply a program that is used for creating and editing plain text files, as opposed to document files created by word processors.  Word processors have a lot of fancy bells and whistles. For example, bolded and underlined fonts, and formatting for columns and tables. Files you create with text editors don’t need any of the fanciness, they just need lines of text that your computer can read. You use the text you can write in text editors to write code that your computer can then interpret into programs.

There are plenty of text editors you can choose from, and many are free. If you happen to be an extreme beginner like me, it’s not really going to matter which you choose.  I chose Sublime Text, because it came recommended by a couple of people, and figured I’ll learn more about the affordances of it and others in the future.

I opened Sublime Text, wrote some simple Ruby code, and saved a document to my desktop called hello-world.rb.

Then what?

Screen Shot 2014-10-28 at 10.52.18 PM
My Terminal is orange because orange is the prettiest color! I made it orange by changing my preferences.

Your Terminal is the most very basic way in which you can speak to my computer.  You can find and manipulate anything on your computer by talking to the Terminal. (Oh gosh, this is getting real…I hope I don’t screw anything up!)

If you have no idea how to find it, just search your computer for “Terminal”, and I promise it’s there!  Your Terminal is able to interpret and run the code you write in text files, such as my silly little hello-world.rb.

I called up the desktop through my Terminal (because the file was saved on my desktop), and typed in a command:

ruby hello-world.rb 

And presto…my program ran! It was neat, but I couldn’t help feeling that simply saying “Hello World” was a little dull and played out. So, I went back to the text file and added a limerick and some comments to make it more lively. I’m not feeling great about my poetry skills, but it feels pretty darn swell to get my computer to recite poetry to me!

Below you can see the plain text file I created (left), and the conversation I had with my Terminal (right). At a glance it might look like nonsense, but I bet you can figure out what I did by taking a closer look!

Screen Shot 2014-10-29 at 12.32.55 AM


One thought on ““Hello World”, and What the Heck is a Text Editor?

  1. Congratulations. That was beautifully explained. Next you should figure out how to get the program to ask you to enter data, and then process it. For example,

    ask for a number
    print the square of the number
    until the number you entered was 100

    This puts you more in control of what is happening.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s