Processing Language Selective Overview

What is Processing?


Processing is a language for teaching computer programming.
Processing is Java.
Processing provides a simpler environment than Java.
Processing is especially useful for working with graphics and media.
Processing provides a double-buffered display.
Processing provides some simple export capabilities.
Processing is free software.

Elements of Processing


Comments
// for single line comment, may occur inline
/* */ for multiline comments, commenting out code, section marking
/** */ for Javadoc comments, before method declarations
"Code that you haven't read for six months was written by somebody else."

Punctuation
; end of every statement
, between variables in a method signature or variable assignment
{} separately exectuable block of method, conditional, loop
() method definitions, method calls, and to control execution order
[] array index

Operators
See http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html for complete list
Operator Precedence
Postfix ++ --
Logical negation !
Multiplicative * / %
Additive + -
Relational < > <= >=
Equality == !=
Logical AND &&
Logical OR ||
Assignment =

Literals
1, 1.0, 1.0f, -7, 123L
"Hello"
'W'

Types
See http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html for complete list
Primitive types: int, float, long, double, boolean, char
Character and String literals: "Boo" 'h'
Wrapped Primitives: Integer, Float, Long, Double

Variables and Declarations
int x;
int total = 50;
long bignumber = 9223372036854775807;
float radius = 4.7;

Expressions
x = 12;
radius = 5.5;
x < 7
x++
total * radius

Methods
See http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
Also called functions or procedures
Method names: begin with lower case and capitalize words internally:
doEndRun, goBackHome, eatCheese
Method return type, declared with type before the method
float circleArea(float radius) {
	float area;
	// body of method
	return area;
}
Use "void" if there is no return type
Method arguments, declared with types in parenthesis ()
Method body, surrounded by curly brackets {}
Method signature: the term applied to the method's return type + name + argument list
Two methods in a class (or a Processing application) cannot have the same signature.
Methods can have the same name and return type with different argument lists.

Control Flow: see http://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html and pages after it for complete list.

Conditionals
if (<condition>) <statement>;

if (<condition>) { <statement>; }

if (<condition>) { 
  <one or more statements>; 
}

if (<condition>) { 
  <one or more statements>; 
}
else {
  <one or more statements>; 
}

if (<condition>) { 
  <one or more statements>; 
}
else if {
  <one or more statements>; 
}
else {
  <one or more statements>; 
}

Loops
for (int i = 0; i < total; i++) {
  <one or more statements>; 
}

for (int i = total; i > 0; i--) {
  <one or more statements>; 
}

int count = 13;
while (count-- > 0) {
  <one or more statements>; 
}

do {
  <one or more statements>; 
} while (<condition>);

Case Sensitivity: case matters

Console
println() and print() statements output to Console
They can be used for testing values
println("Current position is "+ mouseX +", "+ mouseY);