Programming Basics
What is Source Code?
- Source code is a special kind of document in which a programmer can control a computer. It is usually made up of text, numbers and symbols
- Some source code can be viewed and edited using any text editor
- To execute, view and edit source code generally we use an IDE (Integrated Development Environment)
Processing
- Processing programs are called sketches which are comprised of one or more source code files.
- Sketches are edited and executed using the IDE Processing Development Environment
- The IDE has been installed on the school computers in room B32
- To download and install Processing on your laptop follow the instructions found here.
- Processing will not work on a tablet or Chromebook.
Syntax
- The Syntax of a computer language is the set of rules that defines the combinations of symbols that are considered to be correctly structured for that language.
- Things like keywords such as the keywords true, false, and null are part of a language Syntax.
- Other rules, like ending a statement with a semicolon (;) are also part of a language Syntax.
- Syntax errors occur when one of these rules are broken
Parts of Source Code
- Source Code is made up of many different parts including:
- Comments
- Statements
- Expressions
- Methods/ functions
- White Space
Statements:
- Statements are the sentences of code. They can perform many different actions.
- All statements end in a semicolon (;)
- This statement performs the action of writing Hello World to the terminal.
Expressions:
- Expressions are pieces of code that are evaluated to get a result
- mathematical expressions are evaluated to a numerical result
- Boolean expressions are evaluated to true or false
Methods:
- Methods are like commands that perform action
- Can be built-in or user-defined
- They are the verbs of programming languages
White Space:
- In many programming languages the amount of white space between elements of a program can be arbitrary.
- While programs ignore white space, we want our source code to be as readable as possible for other programmers.
- White space should make sense to the program and be easy to read and understand.