programming_fundamentals_with_processing:ch02-getting-going.html
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
programming_fundamentals_with_processing:ch02-getting-going.html [2017/07/26 16:03] – [Entry points] mithat | programming_fundamentals_with_processing:ch02-getting-going.html [2017/07/26 16:47] – [Program statements] mithat | ||
---|---|---|---|
Line 90: | 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