The Byte Illusion

Theo Gregory
2 min readJan 14, 2021
Photo by Yannick Pipke on Unsplash

Recently I was writing my first custom stream with NodeJS, and when reading the documentation thought I’d discovered that one of my foundational computer science understandings was incorrect.

Until then I’d taken it to heart that 1 byte === 8 bits.

Reading the documentation, I came across this section analysing the performance of a simple program they had written:

The maximum byte size occupied by virtual memory turns out to be approximately 87.81 mb. [NodeJS]

To me, this implied that Node believes it has the power to decide what size a byte should be at runtime. Simplifying the sentence surfaces the contradiction:

Accoring to Node: 1 byte === 87810 bytes // Finally, the secret to infinite memory!

Call in the experts

Following a discussion with some of my eng colleagues, it became clear that what the docs mean to say is more like the following:

The maximum number of bytes occupied by virtual memory turns out to be approximately 87.81 mb. [Theo vs NodeJS]

I confirmed that, at least with them, “byte size” was not common terminology that I needed to commit to memory. Glad of this, given its confusing nature, one of the devs then highlighted something to me that I’d previously passingly pondered over but never researched:

A byte is not always 8 bits.

While modern systems widely adopt a byte to mean 8 bits, this is by no means a unanimous agreement. A short Google and Wikipedia will tell you:

Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit of memory in many computer architectures.

The size of the byte has historically been hardware-dependent and no definitive standards existed that mandated the size. Sizes from 1 to 48 bits have been used. [Wikipedia]

So in seeking answers to one thing, I learned something else altogether and thought you might like to know it too.

Tl;dr: A byte is most commonly 8 bits, and NodeJS need to hyphenate “byte size” in their docs.

--

--

Theo Gregory

dubious dev, fintech friend, sloppy skier | he/him