An IDE provides not only a place to write code, but also to run that code and see the result. There are many features the Processing IDE offers, here are some:
Take a look around when you open up Processing. The environment is very minimalist. The play button will run your sketch and the stop button will stop it.
There are some extras you should learn right away:
Processing will automatically create a folder for your sketch where you save it.
All sketches must exist inside a folder with the same name as the sketch.
Here are a few golden rules about saving sketches:
Printing a message to "Hello World" is one of the quintessential programming lessons of any language. Here's how we print out a message to the console with Processing:
And if we'd like the next thing we print to be on the next line:
println is short for print line
It is highly recommended you comment your code. This will increase your understanding by providing you with hints and tips about what the code is doing. Here's how to write comments:
//This is a single line comment
Comments are ignored by Processing when you press the play button.
RUN YOUR CODE OFTEN! This will help you identify when something is not working (the last thing you were working on). Do not try and implement a bunch of features in your sketch and then hit run at the end only to find out something went wrong.
Build a little, run, test, build more...
If something doesn't work. Change one and only ONE thing at time! This practice alone will save you hours of debugging time.
Debugging stands for removing errors from your code. Bugs in your code come in two varieties:
Bugs are called bugs because the first computers used vacuum tubes and when something went wrong, there usually was a bug in one of the tubes.
Always print out the value of variables in your program when things are not behaving as you would expect. This is incredibly useful for finding the cause of runtime errors.
Tracing code is a valuable skill. To practice follow some code through it's execution and watch the variables by printing out their values.
ALWAYS CLOSE BRACKETS IMMEDIATELY WHEN YOU OPEN THEM!!!
Bracket errors are the most difficult to find. Matching brackets for hours is a pointless and exhausting exercise.