Purpose of "Broken Bar" Character -- "|"

And in programming it pretty much still is as so many operators use a double syntax:

&& AND
|| OR

And not logic but following the double thing:
== EQUALS

Even a zombie might suspect that the | was on the type writer for the purpose of…
Putting vertical lines in reports… boxes, tables…

IBM included it in EBCDIC , at about the same time as ASCII was being devised… In IBM, the B stands for business… Their number one (and first computer) product is turning raw data into a “report” ! (census data into census reports…)

Designers occasionally use it as a quick and simple way to divide words (or whatever) with a vertical line.

To be fair, there are certainly other ways of doing that, but vs. drawing a line, it is automatically the right height, the spacing is easy to get correct, the line stays with the text by default when moving it around, etc.

That really isn’t the reason it’s there, but that’s one way it gets used.

AIUI, the double = was a C language construct to differentiate between assignment (=) and comparison (==). The concept may pre-date C, but was important there because you can use the result of an assignment in a comparison:

if a=rand()

will take the ‘true’ branch if the rand() function returns a non-zero value, as well as changing the value of ‘a’. Causes no end of trouble for debugging, when you type ‘a=b’ instead of ‘a==b’.

That was one of the things we complained about when the C report came out. Out of laziness they used = for assign and not the Algol/Pascal :=. Those languages used = for equal the way it should be.

In particular, the Math section shows a large number of classical uses of the symbol. It’s little wonder it got added to keyboards. Once there, then came the other uses us computer folk adapted it for.

Eh, that would still cause problems when people forgot which one was which; it would just change which direction the mistake usually went. The real root of the problem is the fact that in C, assignments return a value, making if(a = b) { … } a grammatical statement. Nowadays, though, most compilers will throw a warning on that construction, to ask if you’re sure that’s really what you want to do.

First, responding to whoever brought up || and && and == Those were relatively “modern” usages compared to the older teletypes (and keypunches?) where the | character first appeared. FORTRAN had been around a lot longer, limited to the famous “48-character set” and used .OR. and .AND. for the boolean and logical operators; it used a single = for assignment and .EQ. for equal-comparison. The language made do with the most popular character set of the day.

Algol was the first language (at least the first well-known one?) to use := for assignment and = for comparison. This was supposedly easy to remember: They wanted to use the left-arrow ← for assignment, but chose := as the digraph to suggest that. And assignments returned a value, so could be used in multiple assignments and inside comparisons, just as in C.

C was the first well-known language to use the | and & characters at all, as far as I can remember. (C was largely based on two predecessor languages called BCPL and B, which might have used them too.) But | and & had become standard characters on Teletype machines well before that, I believe.

And if it’s what you really want to do, if((a = b)) { … } squelches the warning, at least with clang/gcc. if((self = [super init])) { … } is pretty common in my neck of the woods (hey, it’s still C).

Yep, it’s handy for text-to-columns in Excel since it wouldn’t be used for anything else.

But why is it shown as a broken bar on the keyboard? To differentiate it from I for newbies learning the layout? Seems narrow.

That’s not universal. On my keyboard it is an unbroken bar.

It often had a broken bar in earlier fonts. But now there’s an explicit broken bar character in Unicode, so it seems to mostly be solid.

I’ve only seen it as a broken bar on older keyboards.

“Originally” is a strong claim :slight_smile:

In ASCII, it was one of the extra characters thrown in because some systems had it, and there were a few spaces left in the ASCII map, and the competeing glyphs didn’t have stronger claims. It’s position at the end of the alphabet puts it in a position where extra “national alphabet” characters could go – an idea that turned out to be not very useful.

Part of the argument for including the \ and / characters was so that they could be used for /\ and / That is, for .AND. and .OR. I’m not aware of any similar discustion about the “vertical line” character.

And I should amend my earlier comment about C: The problem is also, in part, due to C’s usage of numbers to represent truth values. While the C expression(a = b) has a value, that value is usually a number. If numbers and Booleans were fundamentally different data types, then if(a = b) would still (usually) fail, because if() would be expecting a Boolean.

One of C’s famous problems, fixed in earlier languages before it ever even happened: FORTRAN use of = for assignment and .EQ. for comparison (and assignment didn’t produce a value like C does); Algol used := for assignment and = for comparison and had stronger type requirements. All subsequent languages that aspired to be taken seriously (e.g., Pascal, C++) likewise used one or both of these mechanisms. The most serious criticism of C here is that it carelessly introduced a problem that other older languages already didn’t have.

ETA: FORTRAN II used integers for logical values, but FORTRAN IV had a native LOGICAL data type.

We still haven’t gotten a clear answer to either of the OP’s questions: What this character was used originally used (or intended to be used) for, and why it was (and often still is) displayed as a broken bar. Then most nearly-plausible explanation given so far is the suggestion that business applications could use it for line-drawing, to produce printed tables of data.

The character clearly seems to pre-date any usage in programming languages.

But it also seems to post-date any early usage of computers for commercial (or any) applications. Early computers commonly used a six-bit character set that allowed for upper-case letters only, digits, and a small selection (12) of punctuation marks; and sensible early programming languages (to-wit, FORTRAN but not Algol) confined themselves to using just those standard few punctuation marks that were commonly available. Vertical bar was never one of those in those days.

My above post raises another related question: Why did early computers seem to standardize on a 48-character set? A six-bit byte (common then) allows up to 64 characters. It seems that there was a fairly standard selection of 48 characters (letters, digits, 12 punctuation), and various computers had some varied selection of additional characters. Languages of the time constrained themselves to using the standard 48 characters, thus the entrenched standard of using * for multiplication (and, in early languages including FORTRAN, the digraph ** for exponentiation).

Was the 48-character set due to some limitation on what could easily be encoded on IBM punched cards?

While we’re at it, I also wonder: What in the world was the backslash character intended for?

This pretty much confirms Melbourne’s explanation. It was for use with forward slash to make “and” and “or” operators.

The character was used in math before it any keyboard existed to put it on. For example |x| to mean “absolute value of x” was started in 1841 (Wikipedia) and that’s 20 years earlier than the first typewriters.

I assume there are even older uses in math (like the geometric parallel shorthand || and uses in matrices and statistics ), but I’m having trouble pinning dates on the character itself.

Other than satisfying the mathematicians, the character is definitely useful in both typewriters and early computers for creating vertical lines in tables, so it makes sense to pick it up once you have enough room in your character set.