Getting Started with a “Hello World!” program

In every new activity, there has to be a starting point.  We, as human beings, aren’t born with the immediate ability to run a marathon, or to play something even as simple as “Old McDonald had a Farm” on the violin.  Even walking doesn’t come without the intermediate steps of crawling, then standing up.  Writing software follows much the same pattern, and that first intermediate step is called the “Hello World” program.

If you pursue software development over any length of time, you won’t write just one “Hello World”.  Every time you try a different language, you start with “Hello World”.  Anytime you find yourself learning something new and you don’t have a starting point, “Hello World” is your best friend.

What does a “Hello World” program do?  It simply outputs the phrase “Hello World!”.  Generally this means writing it the screen.  There are a few reason that writing something to the screen is the first thing you do.  For starters, it checks that your basic development tools are working.  You can write a program, you can run that program.  The second thing it tests is that you can output.  Output is sort of a generic term, it could mean writing to the screen, writing to a file on the computer, printing something on paper from the printer… etc.  What’s important is that output, regardless of the form, is your feedback from your program.  Without output, you don’t know what’s going on.

A simple program can be broken down into three components: input, process, and output.  Input is, as you probably expect, what you put in.  It could be text that you type, actions that you take with your mouse, maybe a file.  Output, as I said, is the feedback from the program.  The process is the bulk of the program, it’s the set of rules or instructions for what to do with the input, and what output to supply.  If you don’t have output, you don’t know if your input and your process are working.  It’s like stepping onto the basketball court and shooting some free-throws without the ability to see or hear.  Once you let go the ball, you don’t know what happens.

So I’ll post some examples below, go ahead and open your code editor of choice and write your first program: “Hello World!”.

Java:

public class HelloWorld {
public static void main(String[] args) {
//everything above this is setup,
//the actual procedure only has two lines of code
//1. declare the variable
//	the format is "[type] [name] = [initial value];"
String myVariable = "Hello World!";
//2. output the variable (referenced by name) to the console
//this is essentially a procedure called "println"
//which we reference through this System.out path*
//and we supply with one parameter (or argument)
//which is our variable
System.out.println(myVariable);
//*will elaborate more on this in a later post,
//for now just be aware that the periods "." separate
//the levels in a hierarchy "grandparent.parent.child"
}

C#:

using System;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //Nearly identical to the Java version
      		//everything above this is setup,
		//the actual procedure only has two lines of code
		//1. declare the variable
               //	the format is "[type] [name] = [initial value];"
            String myString = "Hello World!";
            //2. output the variable (referenced by name) to the      //console
		//this is essentially a procedure called "WriteLine"
            Console.WriteLine(myString);
        }
    }
}