This is the sixth lesson in a series introducing 10-year-olds to programming through Minecraft. Learn more here.

All of us here speak English and probably some French as well; those are two languages that people use to communicate. Although technically computers only speak one language, binary, we can use many different programming languages to tell the computer what we want it to do.

How do we create an application?

  1. Pick a programming language
  2. Write some code
  3. Have the code compiled (translated) into instructions the computer can understand
  4. Run those instructions (the application)

Step 1: For working with Minecraft, we'll be using a language called Java.

Step 2: Source code is written in text files, except that instead of having a .txt extension, ours will have a .java extension. We're going to use an application called Eclipse to edit these files.

Step 3: Eclipse will also help us compile our code, using the Java compiler.

What does source code look like?

package mc.jb.first;

public class Application {

    public static void main(String[] args) {

        String myName = "Jedidja";
        int yearOfBirth = 1979; // wow I'm old

        /* Let's tell the computer
           what to display on screen */
        System.out.println("Hi, my name is " + myName);
        System.out.println("I was born in " + yearOfBirth);
    }   
}

That is perhaps one of the simplest applications you can write :) And it introduces us to some import fundamentals: statements, variables, methods, classes, and packages.

Fundamentals

Variable: A name for a place in the computer's memory where you store information. In Java, variables can store different types of information (e.g. numbers or strings). For instance, myName is a variable that stores a string.

Statement: A line of source code ending in a semicolon. The semicolon tells the compiler that the line is complete. If we forget the semicolon at the end of the line, it will confuse the compiler and it won't be able to generate an application for us. The following statement

String myName = "Jedidja";

creates a new variable called myName and assigns it a value of "Jedidja".

Method: A named group of one or more statements. main is a method in the above code.

Class: A named group of methods. Application is a class in the above code.

Package: A named group of classes. mc.jb.first is a package in the above code.

Comments: Comments are ignored by the compiler, but can be useful to other developers in understanding why something is happening. There are two ways to write comments in Java:

  1. single-line comments which start with //
  2. single- and multi- line comments which begin with /* and end with */