A Conversation for An Introduction to Programming: Variables
More stuff on data vs. info
Pete, never to have a time-specific nick again (Keeper of Disambiguating Semicolons) - Born in the Year of the Lab Rat Started conversation Oct 4, 2001
[If you decide to use this, bear in mind that this is just about the most verbose version of this argument possible. I just don't feel imaginitive enough to say it concisely. Feel free to abridge it.]
Imagine a blue square. No, not the bookmaker, just a square filled with blue colour.
Now, how can you represent this using a computer?
One way is as a bitmap. (This is a misleading term, since it is really a map of bytes or words. I'd guess the term originated in the days of mono displays.) You define the square as having a certain size - say, 100x100. The picture is stored as an array of ten thousand 'pixels'. These are really variables that store a number representing its colour, the length of which determines their possible values, like any other variable. Since the square is the same colour throughout, all the variables hold the same number.
If you think about it, this is a terrible waste of memory: it takes 10KB, plus two bytes for the size, to store the data neeeded to represent the square as a bitmap, assuming we use one byte for each pixel.
The other way to represent a blue square is as a vector object. A vector is a line with a start point and an end point. It takes only four variables to store this data for a single straight line (the x and y coordinates of each point). There are four sides to a square, making 4x4=16 bytes - again assuming one byte for each coordinate. If we merge these four points together to form what is known as a vector path, we can eliminate eight of these, since each line shares a point with another line. We then add one boolean variable to say that the path is closed, meaning that the last point is the start of a line which ends on the first point; and one byte for the object's fill colour. This is a grand total of 10B.
The bitmap square contains over a thousand times as much data as the vector square due to the way in which the two are defined. However, they contain the same amount of information, which boils down to "This is a blue square of dimensions 100x100".
Key: Complain about this post
More stuff on data vs. info
More Conversations for An Introduction to Programming: Variables
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."