Glossary#
| Term | Plain meaning | Chapter |
|---|---|---|
| bit | one on/off switch, written 0 or 1 | 1 |
| transistor | the microscopic electronic switch that stores/moves a bit | 1 |
| binary (base 2) | counting using only 0 and 1 | 2 |
| decimal (base 10) | normal human counting with 0–9 | 2 |
| byte | 8 bits; holds 0–255 | 2 |
| KB / KiB | 1,000 / 1,024 bytes | 2 |
| overflow | a number too big for its space wraps around | 2 |
| hexadecimal (hex) | base 16; one digit = 4 bits; 0x prefix | 3 |
| encoding | an agreement for what bytes mean | 4 |
| two's complement | the standard way to store negative whole numbers | 4.1 |
| floating point / IEEE 754 | the standard way to store fractions, with tiny rounding errors | 4.2 |
| ASCII | the old 128-character codebook, 1 byte each | 4.3 |
| Unicode / code point | the worldwide character codebook / a character's number in it (U+…) | 4.3 |
| UTF-8 | the way to turn code points into 1–4 bytes; the default everywhere | 4.3 |
| mojibake | garbled text from reading bytes with the wrong encoding | 4.3 |
| pixel | one dot on a screen, stored as R, G, B bytes | 4.4 |
| CPU / processor | the part that follows instructions | 5 |
| instruction / machine code | one tiny CPU step / the bits encoding it | 5 |
| register | a super-fast storage slot inside the CPU | 5 |
| program counter | the register holding the address of the next instruction | 5 |
| clock speed (GHz) | billions of CPU ticks per second | 5 |
| core | one independent instruction-runner inside the CPU | 5 |
| x86-64 / ARM | the two main CPU instruction sets | 5 |
| RAM | working memory; fast; lost on power-off (volatile) | 6 |
| SSD / HDD | persistent storage; chip-based / spinning disk | 6 |
| cache (L1/L2/L3) | small, very fast memory in the CPU holding copies of recently used RAM | 6 |
| cache line | the 64-byte block copied from RAM to cache at once | 6 |
| locality | programs tend to reuse nearby and recent data | 6 |
| ns / µs / ms | billionth / millionth / thousandth of a second | 6 |
| memory address | the number of one byte's position in RAM | 7 |
| pointer / reference | a value holding the address of other data | 7 |
| little-endian / big-endian | smallest-byte-first / biggest-byte-first order | 7 |
| source code | the program as humans write it | 8 |
| compiler / interpreter | translates before running / while running | 8 |
| bytecode / virtual machine | portable intermediate code / the program that runs it | 8 |
| JVM / JIT | Java's virtual machine / its live compiler for hot code | 8 |
| CPython | the standard Python interpreter | 8 |
| process | a program loaded into RAM and running | 8 |
| parsing / formatting | text → number / number → text | 9 |
Cheat Sheet#
Powers of two to memorise
2^8 = 256 2^10 = 1,024 (≈ thousand) 2^16 = 65,536
2^20 ≈ 1 million 2^30 ≈ 1 billion 2^32 ≈ 4.3 billionConversions
binary → decimal : add the position values where the bit is 1 (1101 = 8+4+1 = 13)
decimal → binary : subtract the biggest power of 2 that fits, repeat
binary ↔ hex : group bits in 4s from the right; each group = one hex digit
bits ↔ bytes : divide bits by 8 (100 Mbps ≈ 12.5 MB/s)Java number limits
int 32-bit ±2.1 × 10^9 → use long when sums can pass ~2 billion
long 64-bit ±9.2 × 10^18
safe midpoint: low + (high - low) / 2Rules
never == on floats compare with Math.abs(a - b) < 1e-9
never floats for money integers in the smallest unit, or BigDecimal / Decimal / NUMERIC
always UTF-8 and declare it at every boundary (files, DB, HTTP)
characters ≠ bytes "Hi 😀" = 4 characters, 7 UTF-8 bytes; Java length() = 5Latency ladder (roughly)
L1 1 ns → L2 4 ns → L3 15 ns → RAM 100 ns → SSD ~50 µs → HDD ~5 ms
→ same-datacentre network 0.5 ms → India↔USA ~200 msTry This Yourself#
Watch overflow happen. In Java (install a JDK, or use an online Java runner), run:
Java public class Main { public static void main(String[] args) { int x = Integer.MAX_VALUE; System.out.println(x + 1); System.out.println(0.1 + 0.2); System.out.println("Hi 😀".length()); } }Explain each output using Chapters 2, 4.2 and 4.3. (The last one prints 5:
H,i, space, and two UTF-16 units for 😀.)See the bytes of text. On a Mac terminal:
echo -n "Hi 😀" | xxd. You should see4869 20f0 9f98 80— the exact 7 bytes from Chapter 4.3. Trycaféand find thec3a9.Measure your memory ladder. Run
sysctl -a | grep -E "cachesize|memsize"on your Mac (or check "About This Mac") and write down your L1, L2 cache and RAM sizes next to the table in Chapter 6.