User Tools

Site Tools


programming_fundamentals_with_processing:ch02-getting-going.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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] mithatprogramming_fundamentals_with_processing:ch02-getting-going.html [2017/07/26 16:47] – [Program statements] mithat
Line 90: Line 90:
 </code> </code>
  
----- 
  
 +<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's, may have been the first language to use the semicolon as the statement terminator. While the semicolon is widely used for this purpose, you should note that this is by no means universal.+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's, may have been the first language to use the semicolon as the statement terminator. While the semicolon is widely used for this purpose, you should note that this is by no means universal.
  
-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" or "decimal point."((In spite of this, the dot has recently been adopted by a number of languages for purposes other than marking decimal points--as we will soon see.+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 would have to do additional work to figure out whether the dot means "end of statement" or "decimal point."((In spite of this, the dot has recently been adopted by a number of languages for purposes other than marking decimal points---as we will eventually see.
 )) ))
  
-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 "better" can be counted as one of the many religious wars in programming.+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 "better" can be counted as one of the many religious wars in programming.
  
 +</WRAP>
  
----- 
  
 ==== Comments ==== ==== Comments ====
programming_fundamentals_with_processing/ch02-getting-going.html.txt · Last modified: 2017/07/26 17:44 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki