UAL CCI: Introduction to Creative Computing Intensive 2022: 🔢 & 🐘: Lecture 2: Counting and Remembering.
Back to slide index.
By the end of this lecture, we'll have learnt about:
- Two references on how to help each other
- How computers remember things and Grace Hopper
- Counting, specifically counting in Binary
- Computer memory
- How JavaScript remembers different kinds of information also known as data types
- Two films - one about the scale of the universe and the other about really really really really big numbers
A pair of thoughts on how to help each other.
We are going to start this lecture series by learning about counting, specifically binary numbers, what they are and why computers use them.
Then we are going to learn about how computers remember information. Computers store this information in things called constants (if they never change) or variables (if they change). Constants are useful (for things like Pi or the number of days in a week), but we are going to use variables much more.
All that computers do is remember things by storing data (as constants or variables) and change those memories through commands. One thing they are very good at is remembering a number and then adding to it. If you want to read a great book on how computers work from the ground up, I recommend
Code by Charles Pertzold.
Now, finally, to counting. What is counting?
Counting is using groups of symbols to represent quantities or amounts. Let's count to 100 in
Decimal. When do
we need an extra digit?
Let's count to 10 in
Unary.
Let's count to 20 in
Binary. When
do we need an extra digit?
What's the biggest number you can count to on your fingers in unary (or the way you were taught as a child)? What about in binary? What about if you use your fingers AND toes?
Tell the binary joke Joel!
I loved this visualisation of a mechanical binary counter:
Words for different quantities of binary numbers, that you might have heard of before:
- A bit is a Binary digIT.
- A byte is eight bits. (BEight).
- A kilobyte is 1,024 (2^10) bytes, mostly.
- A megabyte is 1,048,576 (2^20) bytes, mostly.
- One megabyte is approximately one minute of 128 kbit/s MP3 compressed music.
- One megabyte is six seconds of uncompressed CD audio.
- One megabyte is a typical English book volume in plain text format (500 pages × 2000
characters per page).
- The human genome consists of DNA representing 800 MB of data. The parts that differentiate one person from another can be compressed to 4 MB!
- There are different ways of storing numbers and words in computers, as a whole these values
are known as Data types. Data types can be variable or constant - as mentioned earlier.
- Whole numbers or Integers are stored as ints. E.g. 0, 5,
-567.
- Numbers which are in between whole numbers are stored as Floating Points or
floats. E.g. 3.142 or -5.66343.
- As these numbers are stored in certain amounts of memory, if they get too big (or negative,
or precise) the computer can run out of memory to store them, or overflow. This is bad. See
the Y2K bug.
- You can also store individual characters of the alphabet as chars.
- However, there are different encodings of characters - ASCII and Unicode for example - which allow
different character sets to be displayed.
- You can store words (multiple characters) in strings - which are actually just lists of
chars.
- Another name for lists are arrays.
- Strings are one dimensional arrays.
We'll be discussing more about arrays or lists in lecture 5.
- Remember: data can be stored as fixed values (constants) or
values that can change (variables).
- Here is a fun Unicode example written in p5.js.
Let's try out some JavaScript variables by going through the
JavaScript basics page on the p5.js wiki, all the way up to the
Math (sic) functions section. You are going to encounter "functions" while I go through the page - they are just ways of packaging up several commands in one bigger command - remember that computers only remember things and change those memories with commands.
All lines in JavaScript must finish with a ";" - it's just a way that the computer works out which line is which.
The two really important things I want you to remember from that is that you can use the "let" keyword to make new data (or variables) - e.g. let myName = "Joel"; and that you can do things with data using commands (or functions) - e.g. console.log(myName);, which prints out the value of myName ("Joel") to the JavaScript console.
Let's finish with two films about the scale of the universe and the scale of numbers.
Artwork: Powers of Ten by the Eames Office