views:

305

answers:

5

Know any good stories that describe how a keyword or an operator got it's name?

For example, why is main() the starting point on so many programs? Or why is the pipe (|) used as an OR operator in some languages? Most are derived from older syntax, but why were these chosen to begin with?

I was just reading about why we use an asterisk in regular expressions to denote zero or more repetitions and wondered about the stories behind other operators and keywords.

+1  A: 

There's a simple explanation for most of the things you bring up: because that's the way it is in C. I would imagine that the biggest reason for a lot of these is because C was invented in the day of monochrome 80-char wide screens. Thus, terseness was probably a big factor (hence why we use the curly brace instead of a word like START).

Jason Baker
Which begs the next question: how were the C operators chosen?Also, there were plenty of languages that used words like START and BEGIN long before C's curly braces appeared. I'm thinking about ones like Pascal and FORTRAN. FORTRAN was designed for use on punchcards.
Barry Brown
@Barry - That's what I'm looking for - the starting point and the reasoning behind the choices of the more "obscure" keywords and operators.
robDean
+3  A: 

Here is a bit of C prehistory, about its predecessor B where the basic syntax originates.

starblue
Interesting article. Thanks for pointing it out.
robDean
+2  A: 

Yep, C and Unix are the roots of everything :)

On one-character operators: Two other practical reasons that came to my mind (aside of 80x25 char - or even smaller? - screens that Jason mentioned):

  • The baud rate of ancient terminals. First Unix boxes were operated through teletype lines and each character in a code could add some waiting time.
  • The size of RAM needed to edit (and parse) the code.

C was (unlike FORTRAN or Pascal) intended for writing large programs - IMO that was why these (or simillar) factors were taken into account.

david a.
-1 Complete nonsense not diluted by any knowledge. Older languages were more verbose, and the programs in C were comparatively small because the PDP machines were small.
starblue
A: 

Because they had to choose something. I doubt the stories are interesting. Pipes were probably chosen because whoever made the decision thought they looked better or made more sense than the alternatives.

Dan Dyer
+1  A: 
<=>

I don't know who first named it, but Ruby's comparison operator (above) is often called the 'spaceship' due to its appearance.

AShelly
It originally came from Perl.
Brad Gilbert