So, we always start all programming classes with hardware architecture.
I, I don't think it's essential, so don't get too excited about it.
It's a good
use of terminology so we can have some words
like, say, like CPU and you don't freak out.
Or memory, or RAM, or disk drive and you don't freak out.
I don't want to turn you into a hardware nut. I just want you
to kind of have a few words so we can talk about what's going on inside.
Because, in a sense, we're going to be writing
programs to do stuff, both data, instructions, et cetera.
So, here's some hardware that I just bought
a couple weeks ago and I'm really in love with,
and that is the Raspberry Pi.
This is a single-board computer.
It's got storage on an SD card right there.
That's the operating system and the data.
And it's got the both a microprocessor and the memory is in
here, as well, and it hooks up with USB and HDMI and
various things, and if you want, in this course, you probably can
do all of the homework using a Raspberry Pi if you so desire.
So, this is what hardware really looks like.
It's kind of the inside of something.
Normally, it's in some kind of case and you don't get to see it.
And that's what it looks like.
It's kind of got this green and little silver and gold.
I think they're very beautiful.
They're very pretty.
A lot of engineering goes into making these things.
And and so we kind of have a block diagram of
what's going on in here, and there's some, just some terminology.
The, the brains of it all, well.
We draw this black diagram partly because, and this is
a, from a, oh, parts are coming off of this.
Eh.
I don't know what that was.
It's okay, it's broken anyways.
And if you have a desktop computer, this is more like what it looks like inside.
This part is called a motherboard, and it's kind
of like the thing that connects and brings everything together.
It's got a bunch of wires.
Each one of those little lines here is a wire.
It's covered with sort of a lacquer.
And then there are things that penetrate
the board, and then connect to various chips.
And this whole thing is what this picture is.
But it really is connecting a number of different components.
The central processing unit that I've spoken of before.
Put that back down.
[SOUND] Central processing unit is the closest thing a
computer has to a brain, but it's barely a brain.
It's really just a super fast programmable calculator.
It, we make it flexible by our creativity when we write programs.
We make it seem intelligent.
It's people that make it intelligent by taking our own knowledge
and putting it in.
This is not itself intelligent, there's nothing to fear from this.
It's just not that smart.
So, this is the thing that's programmed to ask the question "what's next?"
And then we have to have a set of instructions
that feed this thing really fast, billions of times a second.
And that's what this is, this is the random access memory.
And we have memory chips and
they're connected together through the motherboard.
So, we have the main memory and we have the central processing unit.
And this is where our high-speed instructions come
from, this is where our high-speed data is stored.
And this is the thing that asks "what next?" and it reads its instructions from here.
And you'll see that kind of like, oop, they're not
quite connected together but eventually they're kind of connecting together.
Don't feel too bad about this hardware it's all
old and it's all broken and it can't be hurt.
So, the next thing we got is input/output device.
So I'll go back to my Raspberry Pi.
So the Raspberry Pi has a USB
that you can connect a mouse or a keyboard.
It has a HDMI that you can connect a monitor to.
I has an Ethernet connector.
So these are all examples of
input/output devices.
And then the last thing on the screen is the secondary memory.
So, this RAM [SOUND] on the Raspberry Pi, the CPU, the central processing
unit and the RAM are all on this one chip in the middle.
It's called SOC or system on a chip where they put more parts there.
So in a sense it collapsed
this, and this, and a lot of this all down in the Raspberry Pi
to one little guy.
But it's still architecturally the same thing.
There's a central processing unit.
There's main memory.
There's graphics cards, etc.
[SOUND] So, input/output devices.
Oh, this big
this guy has input/output devices too, like USB and keyboard, monitor, etc.
So they're, they're very similar.
It's just, this is new, and this is old.
Everything gets smaller when it gets newer.
Okay.
[SOUND] Okay.
So the last thing we gotta talk about is the secondary memory.
Well,
when the power goes off, these things sort of go away.
The data in this RAM goes away.
It's just designed to be really fast.
But not permanent.
So we need a place that's permanent, that's what secondary storage is.
That's what, that's what this secondary storage is for, this is permanent.
This is fast, and it cha cha cha cha cha really fast.
And but this is permanent, and this is slower.
Okay?
So the secondary memory.
[SOUND] I've got two kind of secondary memory.
Oh, dropped it on the floor.
[SOUND] Two kinds of secondary memory.
I'll start with the Raspberry Pi.
The secondary memory of the Raspberry Pi is this SD card.
It's like a disk drive.
It still is permanent.
Does not require power to maintain its data.
The data stays permanent.
So, in the future we will see more
of these flash-style drives and SD-style drives.
So the Raspberry Pi is kind of alluding to the future.
[SOUND] There's a disk drive in here.
It's not really a disk.
It's also flash memory.
But in the old days, in the good old days, back when I was a kid,
we, our secondary memory was [SOUND] a disk drive,
and it had [SOUND] platters, and it spun, and it made a satisfying noise.
And it would move in and out to read data, and
I'll show you a video of this just in a bit.
[SOUND] And so these would record the data on the magnetic platters
and then when the power's taken off, the data would still be magnetized.
And then it would go and move to the
right spot, [SOUND] spin it around, and read the data.
And again, this is kind of messed up in a pretty bad way.
So, there we go.
Central processing unit, brains of the operation, main memory, fast,
but goes away when we power on, input output devices, keyboards, et cetera.
And then storage, that has, maintains its data across power cycles.
Okay, and I just said all that.
Okay?
So then the question is, where do you belong in this?
Where do programs live?
Where do we write?
And the answer is, we kind of live in the memory, right.
What we do is we put our programs into the
memory and then the CPU pulls the programs out of the memory.
So we have to write our programs and put them into the memory.
When we start them and run them we're really loading them
into the memory so they can be fed rapidly to the CPU.
Now the computers don't really execute Python, like "if x less
than three print", but that's what we tend to want to write.
Because what the computers really execute is a thing called
machine language, which is a series of zeroes and ones
that pretty much translate directly to what's on these pins.
There's voltages that go up and down.
That's called machine language.
Source code, like Python, is written in a
way that's most convenient, well, at least more convenient.
Machine language is what's most convenient
for the hardware.
So we either, we have to translate from source code to
machine language, and that's what the Python program does for us.
We write in Python, and Python translates to machine language for us.
So, I got a couple of videos that give you a sense of how this all works.
We'll start with CPU.
And what this is going to do is, this is going to show you the intensity of
how much electricity, the thing that gets hot
inside your computer is this little guy right here.
And we're going to see in this video just how hot it can get.
[SOUND].
Okay, so welcome back.
So the next thing I'm going to show you
I showed you a hard disk that sort of didn't work.
But we're actually going to show you a real short video on how a hard
disk works [SOUND] that someone took the
cover off and actually applied power to it.
You don't want to do this yourself if you have a
hard drive, I've read, and some people say that you can do
it for a, for a few minutes and then the drive
kind of destroys itself if you run it with the cover off.
So let's take a look at this.