Primitive

A primitive is a basic building block

What is a Primitive? 🧱

A Primitive is a basic building block of data, the smallest lego brick, the simplest type of data.

Characters & Strings πŸ’¬

A Character is a single letter and can also be a single symbol, or a single number.

  • 'a' '1' '?'

A String is a series of characters connected together.

  • "Hello World!" "jkh1?/5h51" "aaaaaaaaa"

Number βž• βž–

A Number is a unit apart of a mathematical system and subject to rules of addition, multiplication, etc.

Types of Numbers: integer, float, fixed, double, real, double precision, int, short, long, byte, etc... are commonly used data types.

  • Int = Whole Number = 42 πŸ”’

  • Float = Real Number = 3.14 πŸ₯§

  • Long = Big Number = 2,147,483,647 πŸ‹

Why are there so many types?: Storing numbers with the appropriate amount memory saves the computer from using extra resources.

  • Fraction = 1/3 = .3333333 ♾️

πŸ–₯️The fraction 1/3 would crash every computer ever built if stored as an infinite number because computers have limited spaceπŸ–₯️

Numbers are Not Equal to Strings or Characters πŸ‘¨β€βš–οΈ

A computer treats different types of data differently. The number 1 is not the same as the character 1.

  • 🚫Int "1" Not Equal Chr "1" 🚫

  • 🚫Chr "1" Not Equal Int "1" 🚫

  • 🚫Float "3.14" Not Equal String "3.14" 🚫

  • 🚫String "3.14" Not Equal Float "3.14" 🚫

Boolean & Binary 🌝 🌚

A Boolean has one of two possible values: True or False.

  • ▢️ music player (play, pause)⏸️

  • πŸ’‘light switch (on, off)πŸ’‘

  • 🚰water faucet (open, closed)🚰

Binary is a number built from two possible values: 1 or 0.

  • 1

  • 0

  • 1001001

  • 1111

πŸ–₯️ A computer converts all information into 1's and 0's stores/manipulates that data and spits back what you see. πŸ–₯️

Reference (Pointer)πŸ‘‰πŸ 

A Reference is where a piece of data is in memory.

Address =   1   2   3
          +---+---+---+
Data =    | a | b | c |
          +---+---+---+
  1. I want the data at address 2

  2. I use the reference number 2

  3. I get the data I want 'b'

A Reference can be thought of as a physical address, a bank account number, a bitcoin wallet, or venmo/cashapp/zelle address.

  • Citing original sources in a research paper πŸ“œ

  • Paying a friend back for pizza using venmo πŸ•

πŸ’Έ peer-to-peer mobile payment apps are good examples because you dont know whats in someone elses account but you do know how to request money or send money to that accountπŸ’Έ

Story Time: Ancient Atomic Theoryβš›οΈ

The inventor of atomic theory, Democritus, a Greek philosopherπŸ€”who lived in 500 B.C. He imagined continuously cutting an item in half. if he cut a rock in two, he knew the halves would have the same properties as the whole. If he continued cutting forever, he hypothesized a limit where his rock was uncuttable. The piece was as small as it could possible be (indivisible). These uncuttable pieces he called "atomos", the Greek word for indivisible.

"Nothing exists except atoms and empty space; everything else is opinion." Democritus

Last updated