Re:Ask HN: Why use semicolons to terminate statements in mod...
by timknauf on Monday November 24, 2008 @02:35AM
(#374556)
Hah, do I detect a little light jab in your lack of punctuation?
I guess it partly depends on how you view the relationship between programming languages like Javascript and the typographical conventions of natural languages like English.
I tend to think of a series of statements in a programming language as more akin to a to-do list of imperatives than a paragraph from a recipe book. If you are writing a to-do list, you don't need to mark the end of the instruction; the end of the line functions for this purpose. Something like this would be sufficient for understanding:
break eggs into pan
fry the eggs
remove the eggs from pan
eat the eggs
As opposed to the recipe approach:
Break the eggs in the pan; now fry the eggs; next remove the eggs from the pan; now eat the eggs.
More syntactical marks are required for clarity (including many semicolons!), but the first approach (the to-do list) is arguably closer to how code is actually written.
I guess it partly depends on how you view the relationship between programming languages like Javascript and the typographical conventions of natural languages like English.
I tend to think of a series of statements in a programming language as more akin to a to-do list of imperatives than a paragraph from a recipe book. If you are writing a to-do list, you don't need to mark the end of the instruction; the end of the line functions for this purpose. Something like this would be sufficient for understanding:
As opposed to the recipe approach: More syntactical marks are required for clarity (including many semicolons!), but the first approach (the to-do list) is arguably closer to how code is actually written.