~ (Literally)

what is this symbol (~) called? is it actually used for anything other than decorative purposes? if so, what? if not, then why is it on the keyboard instead of the character map?

It’s called a tilde, and is often used to indicate an approximation.

It’s a tilde. It is used in languages such as Spanish; the word senor should have one over the “n” for instance. It changes the pronounciation from “see-nor” to “seen-your”.

It is also used in all sorts of other things, including URLs of personal web pages for some reason.

Here’s more on the tilde’s job in the age of computers.

That link doesn’t work for me, Ringo.

The tilde is also used in Perl programming in the search operator:

if $search_string =~ /‘search’/; {

&do_stuff;

}

Fixed link.

Tilde is also the bitwise NOT operator in C; it changes all the 1s in a binary number to 0s and vice versa.

On Unix systems, you can use “~” to refer to your own home directory, or “~someuser” to refer to someuser’s home directory.

AndrewT, no offense, caballero, but your Spanish pronunciation is way off.

You can type the n-with-tilde this way: (first make sure the Num Lock is on!):

  1. Hold down the Alt key.
  2. Type 0241 on the numerical keypad at the right end of your keyboard.
  3. Let go of Alt.
    And voilà! ñ

It’s used for destructors in C++ - ~MyClass() would be the destructor function for “MyClass”. This will be Greek to you unless you’re a C++ developer.

The key with “`” and “~” also functioned as the “quick kick” key in Duke Nukem, leading a colleague of mine to call C++ destructors “kick keys”.

It usefulness in programming languages or operating systems has - or certainly should have - nothing to do with why it is on a keyboard. I can think of several characters I would use more often than a tilde, e.g., the cent sign, trademark, bullet, small square, etc.

As for why it was put there in the first place - it appeared in ASCII 65 and there are some disagreements as to the reasons. Some people attribute it to the SHARE camp within IBM. Some histories of ASCII lump it in with a group of “diacritical marks” intended to modify other characters in the restricted 7 bit space:

From http://www.wps.com/projects/codes/index.html which I’ve referred to before in couple other “character” threads. The five diacriticals included the tilde.

Some more musing on the matter:

http://diveintomark.org/archives/2002/10/04/history_of_the_tilde.html

You also might want to do a search on “swung dash.”

Eh, first off, who do you think created ASCII, and what purpose do you think they created it for? Hint: Liberal arts majors weren’t high on the timesharing schedules of the 1960s.

Secondly, why do you think computer languages chose the characters they did to do the jobs they do? It’s not very convenient to have to use a space-cadet keyboard and/or nonstandard keymaps just to modify your source code.

Thirdly, why did keyboard makers all decide to put the same keys on their keyboard? Could it have something to do with standards such as ASCII?

I really don’t get your dismissive tone, bnorton. The whole industry (save some sectors of IBM) has standardized on ASCII, which isn’t perfect by any means but at least serves as a machine-independent way to transmit and store text. Such standardization is rare, as the fragmentation of `extended ASCII’ during the 1980s and pre-Unicode 90s proved. Unicode is quickly catching on, and when it’s ready, I suppose you’ll be able to have keyboards with Celtic runes on them if you so desire.

Interesting trivia: In the same vein as the tilde meaning it’s various programming meanings, IBM mainframes use a different symbol for the ! in != constructions (at least in PL/I and DB2 they do), the EBCDIC ¬ (looks like a dash with a hanging tail on the right if it’s not in your character set). I think it was a key on the IBM 3270 terminals which has since bit the dust.

Now that one, I don’t know which came first, the keyboard or the programming usage. I’ve never seen that used in any other context like the tilde is.

The tilde is definitely not decorative! It’s used in Spanish to change the letter “n” (ene) into a different letter altogether, ñ (eñe). The ñ phoneme sounds like ‘ny’ in English ‘canyon’.

The tilde is also used in Portuguese to indicate nasalization with the vowels a and o. My Portuguese isn’t very good, but I do know that a and ã, and o and õ don’t sound much alike.

Some other languages have probably also adapted the tilde as a diacritic, but I don’t have a specific example. Anyone?

Another use that I’ve thought of. When I took a formal logic class (i.e. if x then y, modus tollens, all that nonsense) last year, tilde was used as the negation operator. For example:

Let F= the proposition “Frank went to Chicago”
~F = “Frank did not go to Chicago” (the negation of F)

With regard to SmackFu’s bit of trivia/ponderment, the hook (¬) is used interchangeably to mean “NOT”. It seems to be more prevalent in mathematical and scientific contexts, so this could be why it was used in this context on the IBM 3270 and included on the keyboard.

On IRC, a tilde before someone’s address means their identity couldn’t be verified.

Some dictionaries use ~ to abbreviate the root word in the usage examples.

The reason is that on a Unix style system, the tilde is used as a shortcut to indicate the home directory. So “cd ~” might take me to /home/dylan73 and “cd ~someone” would take me to /home/someone.

Web servers running on these systems will sometimes adopt the same shortcut, so http://www.anywhere.com/~dylan73/ might get you files from /home/dylan73/public_html or whatever it’s set up for.

I prefer Alt+164… (ñ) But why would they have two different combinations to enter the same symbol?

Eh, who do you think were designing these programming languages? People writing on KEYBOARDS. Tildas got incorporated into programming languages BECAUSE they were on keyboards, not the other way around. The earlier reason was right, if you wanted to write an ñ ascii, you had to use ~n.