Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Somewhat off-topic, but: why semicolons?

C, Pascal, and ALGOL (1958) use semicolons as a statement delimiter. Why was the semicolon chosen instead of, say, the period or newline? BCPL (like JS and Go) allows semicolons to be omitted if a statement ends unambiguously on one line.

Was the semicolon a QWERTY home row key before or after ALGOL?



Was the semicolon a QWERTY home row key before or after ALGOL?

Before, well before. Take a look at http://www.etsy.com/listing/10230221/immaculate-1930s-reming... for a picture of an old typewriter. The ; is exactly where it is today.

As for why semicolons are used, see http://programmers.stackexchange.com/questions/139482/why-ar... for a bunch of speculation on it. The one that seems most reasonable to me is dan04's answer (which was not voted up much because he put it lately.

Start with ASCII. Now take out the characters which did not reliably appear in character formats, take out characters that have meaning to us in mathematical expressions, have obvious utilities as delimiters in other context, or which convey mood. You're left with ; and :. Of the two, ; is more visible and easier to type. So ; it is.


For what it's worth, there's a precedence for it in formal, legal-style writing. UN resolutions, for example, are always written as a single sentence[1].

It makes sense when you think of an entire resolution (program) as a single goal (output/result), which involves many separate steps/clauses (statements) that need to be executed.

A period is a terminator; it says 'This thought ends here', while a semicolon is a delimiter (ie, the clauses it separates are independent grammatically, but not contextually).

[1]http://web.utk.edu/~modelun/resolutions.htm (Model UN rules, but you get the idea).


I have seen the same thing in mayoral declarations or the like.

   Whereas John Q. Doe is an upstanding citizen who has contributed to the city, and
   Whereas aforementioned Mr. Doe is an awesome dude, and
   Whereas some people who happened to contribute to my campaign are fans of Mr. Doe,
   Therefore, I, Mayor Wile E. Coyote do hereby declare Octember 31st, 2012 as John Q. Doe Day in the city of Acme, CO.

In this context, the UN resolution is actually similar to the comma-style used here by Twitter. We don't want the statement/sentence to end, so we use semicolons/commas to make it continue, and end up breaking browsers/non-lawyer readers.


> A period is a terminator; it says 'This thought ends here', while a semicolon is a delimiter

Pascal takes this literally: semicolons separate statements, and a full stop ends the unit contained in a file ("end.").


> A period is a terminator

A period is indistinguishable from a decimal point.

So if you have a = 4. is that the end of the thought or the end of the integer? It's obvious in context to a human, but a bad idea for a computer.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: