Programming: Primitive Data Types

    Programming: Primitive Data Types

      Let's talk about your room for a minute, Shmooper, because organization matters. We don't mean to pry, but chances are good that you have a dresser (or is it a bureau?), with drawers that hold clothes.

      Were we right? This stuff just comes naturally to us.

      Chances are that you also have some knick-knacks above the dresser. Hey, just because you're a Shmooper doesn't mean you aren't entitled to look at a nice porcelain tchotchki every now and then.

      While the top of the dresser might be a great place for your collection of German Existentialist bobble heads, it doesn't have nearly enough space to store all your clothes. Just like a dresser, your computer has some space for things to access quickly, but it doesn't have much.

      Collections of data like objects sit inside the "chest of drawers," but primitives—the smallest pieces of data by programming language standards—sit on top, just like good ol' bobblehead Nietzsche.

      Primitives can be broken into three broad categories:

      1. Numbers: pretty self-explanatory
      2. Booleans: true or false values
      3. Characters: usually letters but could also include numbers

      These primitives are the foundation of pretty much anything you'll build in a computer program. Every other piece of data you'll deal with will be a combination of these types—if they aren't just purely one of them (we're looking at you, Strings).

      Whenever you assign a variable to a primitive, it sits in the most easily accessible piece of computer memory. Anything that isn't sits down below in the harder-to-access memory.