Re: Binary v. Text, why is it faster?
- From: lucien0@xxxxxxxxx
- Date: 6 Feb 2006 19:36:35 -0800
Arctic Fidelity wrote:
I have constantly seen and heard that reading binary data is faster than
reading textual data. I have always presumed this to be a fact. But now I
am at the point where I would like to understand why.
I was trying to think about it, and it has rather confused me. To my
understanding, reading a text file is reading in the bytes which
correspond to, for example, ASCII character codes. But if we are dealing
with a 1-byte character encoding, how is it slower to read in 'a' rather
than some binary representation of that?
And in addition to this, what is the actual difference between binary and
textual files? I had always thought that a binary file was simply a file
composed of any combination of bytes, whereas a text file was a file
composed of a limited subset of the bytes available to a binary file. Am I
misunderstanding something here?
I guess I just don't see how reading in AF would be slower just because AF
appears in a text file instead of a "binary" file?
- Arctic
What is text? What is binary? Both are stored in a binary format
fundamentally and this may be confusing you. Text is usually (but not
always, just to confuse you) stored in ASCII format.
Any CPU will have an internal representation of its number system (all
different, go look up endian on the web), but if you can write and read
in the 'native' number language of the CPU and avoid any translation
then you've jumped the translation hurdle. You've got to read that
number back on a compatible CPU to make sense of it.
Now, consider writing 10 'native' English numbers. If I asked you to
translate them into Japanese before writing them to paper then that
would take you some time - you don't natively know how to do that (or
I'd be surprised if you could). Now at some time later you have to get
them back - read the Chinese numbers back from the paper and translate
them back English 'native' language. So much effort huh?
Same with computers - if you avoid the translation you avoid the
overhead of all the lookups.
Be aware though, because of endian and other issues, especially around
floating point number implementations, if you write a binary file it
may not be portable between different CPU designs (or even compilers).
That's why ASCII text has ruled the planet for umpteen decades. Slower
but more readable. Anyone got a date on that ASCII invention?
Lucien Kennedy-Lamb
.
- References:
- Binary v. Text, why is it faster?
- From: Arctic Fidelity
- Binary v. Text, why is it faster?
- Prev by Date: Re: Binary v. Text, why is it faster?
- Next by Date: Re: Binary v. Text, why is it faster?
- Previous by thread: Re: Binary v. Text, why is it faster?
- Next by thread: Re: Binary v. Text, why is it faster?
- Index(es):
Relevant Pages
|