An area of Software Development I have derived a great deal of pleasure from is communications.
However one day when sending a message from a program running on a Windows computer to a program running on a Linux computer I was baffled to discover that one of the fields in the message, which was a number, did not come out on the other end the same as it went in.
I did not know it at the time, but I had run head long into an age old conflict. This conflict can be characterised by two sides having opposing views. Each side then engages in a bitter struggle to hit the other side over the head with their view in an effort to prove their view is right no matter the cost.
I had stumbled on a Holy War which took the form of bits, bytes and words and had raged for the better part of a decade around the time I was born until 1980 when Danny Cohen wrote an article titled ‘On Holy Wars and a Plea for Peace’.
Bits are the fundamental building blocks of data in computers. One bit can either be on or off, zero or one and typically referred to as binary.
A string of bits can be used to express more complex data like a character on a screen. For example a byte is made up of eight bits. One way of expressing bits on paper is to address them from right to left starting with the first position being labelled with an index of 0.
0 1 0 0 1 0 0 0 A byte made up or eight bits expressing the decimal value 72 7 6 5 4 3 2 1 0 Bit position starting at 0 from right to left
Two bytes make up a word on a 16 bit machine and it is the ordering of the bytes in a word when serialised for storage or transmission over the wire which was the subject of this particular Holy War.
Even today on 32 bit and 64 bit computers with word sizes of 4 and 8 respectively the byte ordering challenge continues.
The ordering of the bytes within a word can either be Big-Endian or Little-Endian which were terms proposed by Cohen in his article.
Big Endian - Example 1 - Most significant byte is on the left 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 1 A 16 bit word representing the decimal value of 18533 or an ASCII string 'He' 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Most significant byte is on the left Little Endian - Example 2 - Most significant byte is on the right 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 0 A 16 bit word representing the decimal value of 18533 or an ASCII string 'He' 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Most significant byte is on the right
Considering the two examples above, when the data in the first example is serialised for transmission over a network the bits are transmitted from left to right. Therefore the first byte to be received is 01001000 and the second byte transmitted is 01100101. Now, if this data is received on a Big Endian machine then all is good because the same byte ordering is used to make up the resulting word when the data is de-serialised back into a value, in this case in decimal as 18533.
The problem comes in when this data is received on a Little Endian machine. Each byte is received in the same order, but when de-serialising the bytes into a word the first byte received is used as the least significant byte making up the word. The result is that the Little Endian machine would interpret a value of 25928 as the decimal value of this word not the correct 18533 and the intended meaning is lost!
In 1980 Danny Cohen introduced the terms Big-Endian and Little-Endian to describe the different byte ordering in article titled ‘On Holy Wars and a Plea for Peace’. Big-Endian or ‘big end in first’ described the computers which the big end (most significant) bit is transmitted first.
Big Endian and Little Endian were terms he borrowed from Jonathan Swift who used them to describe the opposing views of two factions in the fictional nation of Lilliput.
In the story of Gulliver’s Travels, Big-Endians were a faction who broke their boiled eggs at the big end. They rebelled against the king who demanded that his subjects all broke their boiled eggs at the little end. The following is the relevant extract :-
It began upon the following occasion.
It is allowed on all hands, that the primitive way of breaking eggs before we eat them, was upon the larger end: but his present Majesty’s grandfather, while he was a boy, going to eat an egg, and breaking it according to the ancient practice, happened to cut one of his fingers. Whereupon the Emperor his father published an edict, commanding all his subjects, upon great penalties, to break the smaller end of their eggs.
The people so highly resented this law, that our Histories tell us there have been six rebellions raised on that account, wherein one Emperor lost his life, and another his crown. These civil commotions were constantly fomented by the monarchs of Blefuscu, and when they were quelled, the exiles always fled for refuge to that Empire.
It is computed, that eleven thousand persons have, at several times, suffered death, rather than submit to break their eggs at the smaller end. Many hundred large volumes have been published upon this controversy: but the books of the Big-Endians have been long forbidden, and the whole party rendered incapable by law of holding employments.
During the course of these troubles, the emperors of Blefuscu did frequently expostulate by their ambassadors, accusing us of making a schism in religion, by offending against a fundamental doctrine of our great prophet Lustrog, in the fifty-fourth chapter of the Brundecral (which is their Alcoran). This, however, is thought to be a mere strain upon the text: for their words are these; That all true believers shall break their eggs at the convenient end: and which is the convenient end, seems, in my humble opinion, to be left to every man’s conscience, or at least in the power of the chief magistrate to determine.
This extract is a satire on the conflict between the Roman Catholic church and the Church of England and the associated conflict between France and England which at some level revolved around the meaning of the sacraments.
The point that Jonathan Swift tries to convey is that the difference between breaking a boiled egg at the little-end or the big-end is trivial. Therefore he suggests that everyone does it in their own preferred way.
The main point Cohen is trying to convey is that sending eggs over the wire with the little or big end first is also trivial, but that when communicating everyone must do it in the same way to avoid anarchy. Either way can be chosen but a decision one way or the other must be made :-
Each camp tries to convert the other. Like all the religious wars of
the past, logic is not the decisive tool. Power is. This holy war is
not the first one, and probably will not be the last one either.
The “Be reasonable, do it my way” approach does not work. Neither does
the Esperanto approach of “let’s all switch to yet a new language”.
Our communication world may split according to the language used. A
certain book (which is NOT mentioned in the references list) has an
interesting story about a similar phenomenon, the Tower of Babel.
Little-Endians are Little-Endians and Big-Endians are Big-Endians and
never the twain shall meet.
We would like to see some Gulliver standing up between the two islands,
forcing a unified communication regime on all of us. I do hope that my
way will be chosen, but I believe that, after all, which way is chosen
does not make too much difference. It is more important to agree upon
an order than which order is agreed upon.
Personally I find my experience and the story behind it a gold mine for humour which looks like the main strategy Cohen used to lubricate the fixation each faction had on their view. It reminds me of the saying that Tragedy + Time = Comedy.
For example, Big-Endian and Little-Endian were often used to describe the sex of computers. Bytesexual was used to describe rare occurrences of computers willing to compute or pass data using either Big-Endian or Little-Endian. I also wonder if it was his Majesty’s grandfather’s little finger that got cut resulting in his father’s change to Little-Endian.
Today, Windows is Little-Endian and Linux is Big-Endian. But when communicating Network Byte Order is used, which happens to be Big-Endian.