programming_fundamentals_with_processing:ch02-getting-going.html
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
programming_fundamentals_with_processing:ch02-getting-going.html [2017/07/26 15:52] – [Source code] mithat | programming_fundamentals_with_processing:ch02-getting-going.html [2017/07/26 16:47] – [Program statements] mithat | ||
---|---|---|---|
Line 18: | Line 18: | ||
Below is one of the simplest Processing programs you can write. When executed, it will print an important message about cranberries. | Below is one of the simplest Processing programs you can write. When executed, it will print an important message about cranberries. | ||
- | **program '' | + | <file |
- | + | ||
- | <code java> | + | |
println(" | println(" | ||
- | </code> | + | </file> |
- | This is an example of a program written in what Processing calls its Basic Mode. In Basic Mode, the program' | + | |
- | **program | + | This is an example of a program |
- | <code java> | + | Here's a program with two statements: |
+ | |||
+ | <file java cranberries_and_more.pde> | ||
println(" | println(" | ||
println(" | println(" | ||
- | </code> | + | </file> |
- | Processing' | + | |
+ | Processing' | ||
=== Processing with an entry point === | === Processing with an entry point === | ||
- | Processing will automatically switch to Continuous Mode when you define at least one function in your program. (This is why you are not allowed to define functions in Basic Mode.) In Continuous Mode, Processing will look for a definition of a function called **'' | + | Processing will automatically switch to Continuous Mode when you define at least one function in your program. (This is why you are not allowed to define functions in Basic Mode.) In Continuous Mode, Processing will look for a definition of a function called **'' |
- | **program '' | + | <file java cranberries_continuous_mode.pde> |
- | + | ||
- | <code java> | + | |
void setup() { | void setup() { | ||
println(" | println(" | ||
} | } | ||
- | </code> | + | </file> |
This program consists of a definition of the '' | This program consists of a definition of the '' | ||
Line 50: | Line 49: | ||
<code java> | <code java> | ||
void setup() { | void setup() { | ||
- | | ||
} | } | ||
</ | </ | ||
Line 92: | Line 90: | ||
</ | </ | ||
- | ---- | ||
+ | <WRAP center round box 80%> | ||
=== Geek break: Why semicolons? === | === Geek break: Why semicolons? === | ||
If a statement is the programming equivalent of a sentence, why are semicolons used to mark the end of statements rather than periods? | If a statement is the programming equivalent of a sentence, why are semicolons used to mark the end of statements rather than periods? | ||
- | The biggest reason for this is that the language on which Processing is based, Java, uses semicolons to mark the end of statements. But why does Java do this? Because the language on which a lot of Java syntax is based, C++, also uses semicolons. Why does C++ do this? Because ..., you get the idea. The language ALGOL, whose development began in the late 1950' | + | The biggest reason for this is that the language on which Processing is based, Java, uses semicolons to mark the end of statements. But why does Java do this? Because the language on which a lot of Java syntax is based, C++, also uses semicolons. Why does C++ do this? Because ... , you get the idea. The language ALGOL, whose development began in the late 1950' |
- | One of the things that makes the semicolon well-suited to marking the end of statements is that the semicolon has little semantic value otherwise. A period is commonly used with floating point numbers (e.g., 3.14159, 22.5, 98.6) and so marking the end of program statements with a period would mean that whatever tries to understand the code would have to do additional work to figure out whether the dot means "end of statement" | + | One of the things that makes the semicolon well-suited to marking the end of statements is that the semicolon has little semantic value otherwise. A period is commonly used with floating point numbers (e.g., 3.14159, 22.5, 98.6) and so marking the end of program statements with a period would mean that whatever tries to understand the code you're written |
)) | )) | ||
- | You might now be asking why you need to mark the end of a statement all. Isn't it obvious that the statement ends at the end of the line? Some languages actually do this. There are advantages and disadvantages either way, which you might gain an appreciation for when we cover the subject of whitespace. The debate over which is indeed " | + | You might now be asking why you need to mark the end of a statement all. Isn't it obvious that the statement ends at the end of the line? Some languages actually do this. There are advantages and disadvantages either way, which you might gain an appreciation for when we cover the subject of //whitespace//. The debate over which is indeed " |
+ | </ | ||
- | ---- | ||
==== Comments ==== | ==== Comments ==== |
programming_fundamentals_with_processing/ch02-getting-going.html.txt · Last modified: 2017/07/26 17:44 by mithat