You are learning two languages: Java and CS vocabulary. Of the two, the CS vocabulary is more important. Java is a high-level language, which means that it was designed to be easy for humans to read and write. At first, that claim will seem incredible, but it really is, compared to low level-languages, which are easy for computers to execute. What is a program? A sequence of instructions that specifies HOW to perform a computation. Instructions: input, output, simple math, comparison, repetition Specify HOW: in excruciating detail... beginning programmers often have the feeling of teaching an idiot, because the computer seems not to know many things that are obvious to people. Think of it as an exercise in inter-species communication. Computation: More general than just math -- anything a computer can do is considered computation in broad sense. Amazing thing #1: all computations are made up of the same set of simple instructions. Amazing thing #2: compilers are programs that translate other programs, sometimes improving them in the process! Is programming a walk in the park? Why, no. Sometimes it is frustrating and unpleasant, like all worthwhile things. Some things that go wrong: 1) Syntax errors: computer is a stickler for spelling and grammar. Syntax errors are discovered by the compiler, and prevent it from generating code. You can't run until you get rid of all the syntax errors. 2) Run-time errors: An unusual condition, like dividing by zero, can cause the program to stop executing at some point. Called "exception" in Java. 3) Logic errors: The program runs, but does not do what you expected. Really, these are not three kinds of errors, but three times when you might detect errors. There is only one kind of error --- the program does not do what you wanted it to do. Why? Because you did not specify the right computation. Computer interprets code quite literally, with no understanding of what you are trying to accomplish. Java syntax ----------- public class Hello { // main: generate some simple output public static void main (String args[]) { System.out.println ("Hello, world."); } } 1) a program includes a class definition, which is the words "public class Hello", plus everything between the squiggly braces 2) public is optional, class is not, Hello is a name you make up 3) comments can contain anything (until the next line) 4) this class definition contains one method definition, which is the words "public static void main (String args[])" plus everything between the squiggly braces. 5) Which squiggly brace goes with which? They nest. Indentation helps make it visually obvious. 6) public is optional, static and void are not, and the name "main" is special. It indicates the place in the program where execution begins. 7) System.out.println is the full name of the command to print things. There is no command named "pintln", but there is one named "print". 8) semi-colon at the end of every statement. What's a statement? What's the difference between "println" and "print"? What happens when you get these rules wrong? Mostly syntax errors, possibly a run-time error or two. If there is no method named main, that causes a run-time error. Same thing if you leave out "static". ----- Enough about syntax. Why are we learning to program, anyway? 1) Good way to learn to think like a computer scientist. 2) You might be a programmer. 3) Even if you're not, thinking like a programmer can make you a more productive user. 4) CS material reinforces some mathematics, introduces ideas of engineering, and dovetails with the natural sciences.