User Name
Password
AppleNova Forums » Programmer's Nook »

The other day my friend asks me "how does a computer work?" and I couldn't explain it


Register Members List Calendar Search FAQ Posting Guidelines
The other day my friend asks me "how does a computer work?" and I couldn't explain it
Page 1 of 2 [1] 2  Next Thread Tools
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-08-03, 15:11

It's not that I don't understand it myself, it's that I couldn't explain it in a way which made sense to him. But that probably speaks to my understanding of it as well, which is why I'm here.

Long story short, I'm driving into Boston for happy hour the other day with my two friends Matt and Chris. Chris got an iPhone for his birthday and now he really wants a MacBook for his next computer. Chris has never really been into computers but he loves his iPhone, and the entire thing has gotten him really interested in computers in general.

So we're about to get on the pike and Chris goes, "so, how does a computer work?"

I look at him and say "that's a very broad question. Can you be more specific?"

So he goes, "well, you write code, right? And it's words and symbols, it's something that a human could read. But then you feed that code to the computer and it does stuff. I thought that computers can only read ones and zeroes?"

"That's right, computer hardware itself operates with binary code. I typically write code in what's called a high level language, which gets converted into ones and zeroes before the computer executes it."

"Why don't you write in ones and zeroes?"

"Well, I could, but it would be unimaginably tedious. We write in higher level languages because they provide abstraction, which means I can tell the computer what I want it to do using language that is more familiar to humans. Writing even the simplest command in binary would require lots of ones and zeroes and I only have to screw up one digit to make the whole thing crash and burn. You would have to be very talented to write something interesting in binary and it would take forever."

"So if the computer can take the high level code you write and execute it, why do computers still have to work in binary?"

"Because it's all the computer can understand. At it's most basic level, a computer is just a gazillion switches, and depending on how the switches are arranged, the computer does things. When we say ones and zeroes it would be more apt to say 'on' and 'off,' because whether or not certain switches are on or off is what determines the output. It sounds crazy but you have to take into account that we are talking about a lot of switches. You need a group of thirteen switches just to add numbers less than eight."

"Yeah, but, as the programmer, you're still typing high-level code into the computer and the computer executes it. If I know Spanish and English and someone is speaking to me in Spanish, I don't need to write it down and translate it to English to understand it."

"Well, the natural language analogy fails there, I guess. That's not how a computer operates; it has to convert code to machine code before it can do anything with it."

"But if the computer itself is doing the converting, then why does it need to convert to begin with? If it knows how to convert it, then that means it understands it, and conversion shouldn't be necessary."

At that point I didn't really know how to keep going with it. I couldn't come up with another analogy that would explain it to him. Has anyone successfully explained this to someone who hasn't studied it? It occurs to me that it may be a lost cause, and that this may just be one of those things that is too complicated for someone to understand after a 20 minute conversation, but I'm curious anyway. Strangely enough I've been asked this question before and I'd be nice to have a short explanation even if it isn't thorough.

Logic, logic, logic. Logic is the beginning of wisdom, Valeris, not the end.

Last edited by Kraetos : 2009-08-03 at 18:33.
  quote
bassplayinMacFiend
Banging the Bottom End
 
Join Date: Jun 2004
 
2009-08-03, 15:20

Explain that the code is in text, then converted to a processor-specific binary format. The compiler translates from human into binary as the CPU only understands binary; you hired a translator (compiler) because the computer doesn't understand human.
  quote
709
¡Damned!
 
Join Date: May 2004
Location: Purgatory.
 
2009-08-03, 15:26

Nobody inherently "understands" anything. Any information received by the senses is broken down into electrical synapses (that would be the on/off part) and "recompiled" into something our brain can react to, be it temperature, voice, pain, etc.

So, in my analogy, "high-level" code could be the sound of a bee buzzing nearby. My brain breaks down the input into electrical jolts, recompiles it, then triggers the appropriate action to my arm/hand to shoosh it away.

So it goes.
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-08-03, 15:30

Quote:
Originally Posted by bassplayinMacFiend View Post
The compiler translates from human into binary as the CPU only understands binary; you hired a translator (compiler) because the computer doesn't understand human.
That's where he's getting hung up. He sees the compiler and the CPU as one in the same and I don't know how to make that distinction clear. To him, it's just "the computer."

Logic, logic, logic. Logic is the beginning of wisdom, Valeris, not the end.

Last edited by Kraetos : 2009-08-03 at 15:45.
  quote
Banana
is the next Chiquita
 
Join Date: Feb 2005
 
2009-08-03, 15:41

Maybe this relic will give you some idea as this is basically another guy same similar question.

As for the compiler/CPU, make sure you point out that compiler is a software itself. Furthermore, ask him how he would write a compiler. Maybe it'll help him thinking about how it had to come from a even more primitive version (e.g. assembler) and using assembly language was valuable when resources were scarce but now it's not so scarce, we can be more productive using high level language.
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2009-08-03, 15:42

Stick to the natural language thing. Even if English is your "native" language, it's not the one your body works with. Organs communicate with each other by sending hormones, electric impulses, etc. — not by using the English language. And while humans appear to communicate with each other only with words, body language plays a big role as well.

In a sense, English compiles down to our truly native language the same way a programming language does to machine code.
  quote
Mugge
Thunderbolt, fuck yeah!
 
Join Date: Jan 2005
Location: Denmark
 
2009-08-03, 15:45

Well, that's simple:

The compiler is a piece of software that in itself is is made up of binary code. It's capable of translating your high level language into a binary language that the CPU understands.

The CPU is a piece of hardware that only understands binary language. The CPU (along with the rest of the hardware) uses the binary code to execute software, such as a compiler.

Yes?
  quote
Banana
is the next Chiquita
 
Join Date: Feb 2005
 
2009-08-03, 15:53

One more point though I would hesitate to share if it's more likely to confuse: Even though all computer uses binary, how the CPU use binary is not universal, kind of akin to how Latin alphabet can be used among several languages but knowing the alpahbet does not enable you to understand the other languages. Every CPU (family) has their own instruction set (e.g. their native language) that may be similar but not identical to others' instruction set. Writing high-level language allow us to share the same function among several possible instruction sets. So yes, you could write in binary directly but that would mean you are now tied to a specific CPU. There's no guarantee that even the next generation CPU from same manufacturer will use the same instruction set, and that would seriously crimp on our productivity.

But this may end up confusing some people more, though.
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-08-03, 15:58

Quote:
Originally Posted by 709 View Post
Nobody inherently "understands" anything. Any information received by the senses is broken down into electrical synapses (that would be the on/off part) and "recompiled" into something our brain can react to, be it temperature, voice, pain, etc.

So, in my analogy, "high-level" code could be the sound of a bee buzzing nearby. My brain breaks down the input into electrical jolts, recompiles it, then triggers the appropriate action to my arm/hand to shoosh it away.
Quote:
Originally Posted by chucker View Post
In a sense, English compiles down to our truly native language the same way a programming language does to machine code.
I'll try this line of reasoning out. For whatever reason I'm determined to be able to explain this to my friend

Quote:
Originally Posted by Mugge View Post
Well, that's simple:

The compiler is a piece of software that in itself is is made up of binary code. It's capable of translating your high level language into a binary language that the CPU understands.

The CPU is a piece of hardware that only understands binary language. The CPU (along with the rest of the hardware) uses the binary code to execute software, such as a compiler.

Yes?
I tried something similar. Paraphrasing, I said "a compiler is just a piece of software written by humans because the computer can only follow explicit instructions. So we write code in a language devised by humans, feed it to a compiler which was written by humans, and once the compiler converts it to binary, it can be executed by the computer's hardware via electrical signals."

I don't remember his response but it didn't get the point across.

Quote:
Originally Posted by Banana View Post
One more point though I would hesitate to share if it's more likely to confuse: Even though all computer uses binary, how the CPU use binary is not universal, kind of akin to how Latin alphabet can be used among several languages but knowing the alpahbet does not enable you to understand the other languages.
The whole "binary is an alphabet, not a language" thing came up once but I didn't expand upon it because I thought it would just be more confusing.

Logic, logic, logic. Logic is the beginning of wisdom, Valeris, not the end.
  quote
zippy
Veteran Member
 
Join Date: Jul 2005
Location: Unknown
 
2009-08-03, 16:03

Quote:
Originally Posted by Kraetos View Post
"Yeah, but, as the programmer, you're still typing high-level code into the computer and the computer executes it. If I know Spanish and English and someone is speaking to me in Spanish, I don't need to write it down and translate it to English to understand it."
Just tell him he's missing a step here. He's going right from the programmer (speaking Spanish) to the Computer understanding both Spanish and English. Tell him it's more like this:

One person knows Spanish (programmer) - and he speaks this to another person who knows Spanish and English (compiler). The Compiler converts the Spanish to English (1's and 0's) and gives this to the CPU - which doesn't natively know Spanish.

If that fails, tell him that once upon a time, someone had to sit down and write an English-CPU translation dictionary, and that this was all done in 1's and 0's. It took a very long time, and we never want to have to do it again. From now on, programmers just funnel everything through the translation dictionary. The End.

Do you know where children get all of their energy? - They suck it right out of their parents!
  quote
Banana
is the next Chiquita
 
Join Date: Feb 2005
 
2009-08-03, 16:04

One more thought. Could it be that your friend has mistakenly and unintentionally attributed some kind of intelligence or sentience to the computer? I remembered some people having the impression that the computer was "smart" when in reality it was just a cleverly designed program, in which case I would point out that computer is nothing but an automata carrying out orders mindlessly; it just seems creative only because it's reflective of the programmers behind it.
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-08-03, 16:08

Quote:
Originally Posted by zippy View Post
One person knows Spanish (programmer) - and he speaks this to another person who knows Spanish and English (compiler). The Compiler converts the Spanish to English (1's and 0's) and gives this to the CPU - which doesn't natively know Spanish.
The problem here is that he is having trouble separating the CPU from the compiler. To him, it's just "the computer." It seems super obvious to those of us who have studied it but for the average person, the computer is just a magic box.

Here is the part of the conversation he appeared to be the most hung up on:

Me: "The compiler has to convert things from high-level code to binary so the CPU can execute it."

Him: "But if the computer does both the converting and the executing, why does it need to convert it? If the computer converts high-level code to binary code, why can't we make a computer which understands high-level code?"*

I like 709 and chucker's analogy. Computers "think" in binary and have to "learn" programming languages, like a human thinks with electrical impulses and has to learn natural languages.

You can't make a CPU which understands high-level code for the same reasons why you can't make a baby which can speak English at birth. Babies learn, computers have software installed on them.

Quote:
Originally Posted by Banana View Post
One more thought. Could it be that your friend has mistakenly and unintentionally attributed some kind of intelligence or sentience to the computer? I remembered some people having the impression that the computer was "smart" when in reality it was just a cleverly designed program, in which case I would point out that computer is nothing but an automata carrying out orders mindlessly; it just seems creative only because it's reflective of the programmers behind it.
I believe he has. I was trying to emphasize this isn't the case when I said that computers can only follow explicit instructions, but it didn't get the point across.

Unfortunately the electrical impulses analogy may cement the "computers are smart" misconception. Maybe not, though, since I could point out that while humans can learn things on their own, computers are helpless without software written and installed by humans.

*He then proceeded to tell me that there are clearly billions to be had if I could devise such a CPU. I told him he should stick with philosophy

Logic, logic, logic. Logic is the beginning of wisdom, Valeris, not the end.

Last edited by Kraetos : 2009-08-03 at 18:38.
  quote
Swox
OK Mr. Sunshine!
 
Join Date: Oct 2006
Location: Toronto
 
2009-08-03, 16:15

I don't understand this stuff too much (but I've found this discussion to be really interesting), but this seems to make sense to me: You have three people. One speaks English, one Spanish, and one speaks both. There is basically a translator in between the two parties that converts their native languages so that they can understand each other.

That's what I understood, anyway.

Edit: What zippy said.

If he doesn't get it, open up a computer for him and show him the parts.

Do not be oppressed by the forces of ignorance and delusion! But rise up now with resolve and courage! Entranced by ignorance, from beginningless time until now, You have had more than enough time to sleep. So do not slumber any longer, but strive after virtue with body, speech, and mind!
  quote
Banana
is the next Chiquita
 
Join Date: Feb 2005
 
2009-08-03, 16:28

An alternative analogy to work is to go back to older form of computing where instructions was given by feeding in punch cards. Make the point that the Word, Excel, Safair, whatever are basically a bunch of punch cards that puts the computer in a state where it can understand input expected for each program (e.g. text, financial data, URLs) and act upon it & return result, then make the point that compiler is just a punch card that enables the computer to create new software (new punch cards created as a output) that can then be used as an application.

Maybe the usage of something more concrete than software will help illustrate the role of software (and consequently the compiler's role) more clearly?
  quote
zippy
Veteran Member
 
Join Date: Jul 2005
Location: Unknown
 
2009-08-03, 17:13

The only other options I can think of are:

1) Go ahead and just reinforce that it IS just a magic box and that it's best not to try and understand something that isn't understandable

2) Tell him that we don't want the 'machines' to understand high-level language, or they will soon takeover the world. We only let them know 1's and 0's to keep them 'stupid'.

Do you know where children get all of their energy? - They suck it right out of their parents!
  quote
709
¡Damned!
 
Join Date: May 2004
Location: Purgatory.
 
2009-08-03, 17:50

Quote:
Originally Posted by Kraetos View Post
Unfortunately the electrical impulses analogy may cement the "computers are smart" misconception. Maybe not, though, since I could point out that while humans can learn things on their own, computers are helpless without software written and installed by humans.

*He then proceeded to tell me that there are clearly billions to be had if I could devise such a CPU. I told him he should stick with philosophy
Philosophy major? That explains it. Those cats are always looking for a Deus in the friggin Machina (), which I guess may explain his "but if it understands" comment.

Maybe a better analogy, though a little different, would be a Lite-Brite. You, as a programmer, provide the coordinates and colors of each peg. You may write "red" in the code, but the compiler (ostensibly a human, yes, but let's stretch it to say computer, since the human is just following your directions as a computer would) doesn't understand "red," being a human construct and all. Instead, it searches its databank for <red> and converts it into "its" language, which is 01101000100011. It sends the command to insert 01101000100011 at coordinate 000,001,057.

Ad infinitum until the desired end is achieved. It could be a flower, a bunny, or the letter G. The compiler doesn't know, and more importantly, doesn't care. There is no sense of beauty or satisfaction of a job well done. It does. Because you told it to.

So it goes.
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-08-03, 18:24

Alright, well, when my friends come over later tonight for our nightly "get stoned and play Halo" marathon, I'll see which explanation works best.

  quote
709
¡Damned!
 
Join Date: May 2004
Location: Purgatory.
 
2009-08-03, 18:36

"See, the Gravemind acts a the compiler, whereas the Flood act as..."
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2009-08-03, 18:46

Magic.

Or gnomes.

And say it with a dead serious look on your face and after a second or two of silence, grimace and sigh softly as you slowly shake your head and walk away.

That always gets 'em.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2009-08-03, 18:47

Oooh, or better yet: tell them to rent or Netflix a copy of Tron. Explain that the movie is a dramatic telling of what really happens inside computers... because it is, after all.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
Swox
OK Mr. Sunshine!
 
Join Date: Oct 2006
Location: Toronto
 
2009-08-03, 19:45

It's funny, because I understand your friend's line of questioning. He's obviously not a dumb dude, though he clearly doesn't know a thing about technology. I really could have answered his questions at all until I read this thread, and I even know a bit about computers.

Do not be oppressed by the forces of ignorance and delusion! But rise up now with resolve and courage! Entranced by ignorance, from beginningless time until now, You have had more than enough time to sleep. So do not slumber any longer, but strive after virtue with body, speech, and mind!
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-08-03, 20:27

Quote:
Originally Posted by Brad View Post
Magic.

Or gnomes.

And say it with a dead serious look on your face and after a second or two of silence, grimace and sigh softly as you slowly shake your head and walk away.

That always gets 'em.
When most people ask me how computers work, I do exactly that.

"You're good with computers, right? I've always wondered, how does a computer work?"

"Magic."

"Seriously?"

"Unless you have several hours to spare, and are willing to learn boolean algebra right now, yes. Magic."

"Sounds good."

Quote:
Originally Posted by Brad View Post
Oooh, or better yet: tell them to rent or Netflix a copy of Tron. Explain that the movie is a dramatic telling of what really happens inside computers... because it is, after all.
I have Tron on my computer, and now all I want to do is get my friends really high and then try and convince them that yes, Tron is a 100% accurate depiction of how computers work. Except Tron is 25 years old so now, everything is smaller and faster. And instead of Bruce Boxleitner, it's now Chris Pine.

Logic, logic, logic. Logic is the beginning of wisdom, Valeris, not the end.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2009-08-03, 21:01

Quote:
Originally Posted by Kraetos View Post
I have Tron on my computer
Whoa shit bro. Watch out! That's like recursion or something. Don't want to open up a black hole or some inter-dimensional vortex.
  quote
709
¡Damned!
 
Join Date: May 2004
Location: Purgatory.
 
2009-08-03, 21:16

Quote:
Originally Posted by Kraetos View Post
Except Tron is 25 years old so now, everything is smaller and faster.
Try telling that to Jay Maynard.

He has recurring dreams about catching Gordon Moore's light cycle, pulling him out and beating his ass.
  quote
Kraetos
Lovable Bastard
 
Join Date: Dec 2005
Location: Boston-ish
 
2009-08-03, 21:21

"So for the same reason you cant have baby which knows English when it's born, you can't make a CPU which understands C."

"Makes sense. So now all you need to do is make a baby which understands English."

"I'm on it."

He seems to have a pretty firm grasp on it now. Thanks guys!

Logic, logic, logic. Logic is the beginning of wisdom, Valeris, not the end.
  quote
alcimedes
I shot the sherrif.
 
Join Date: May 2004
Send a message via ICQ to alcimedes  
2009-08-03, 21:41

Actually the human body analogy is a good one.

You write code that says "move your finger" and the computer translates that to the equivalent of the electrical impulses necessary to make that happen.

At the end of the day, we have designed computers that understand high level language, via software, compilers, assemblers etc.

That doesn't change the underlying physical nature of the computer though, which is limited to electrical impulses.

Just like simple computers can't understand complex programs, simple organisms can't understand language etc.

They still operate using the same basic biology though, which is what he doesn't get. What he's saying is that you should invent a new computer at the cellular level, which isn't happening.

Google is your frenemy.
Caveat Emptor - Latin for tough titty
I tend to interpret things in the way that's most hilarious to me
  quote
zippy
Veteran Member
 
Join Date: Jul 2005
Location: Unknown
 
2009-08-03, 23:29

Quote:
Originally Posted by Brad View Post
Magic.

Or gnomes.

And say it with a dead serious look on your face and after a second or two of silence, grimace and sigh softly as you slowly shake your head and walk away.

That always gets 'em.
Magic gnomes FTW!
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2009-08-04, 00:48

nerds

I'm going to beat you up and steal your lunch money.




...
  quote
Partial
Stallion
 
Join Date: Feb 2006
Location: Milwaukee
 
2009-08-04, 00:58

Quote:
Originally Posted by Brad View Post
Whoa shit bro. Watch out! That's like recursion or something. Don't want to open up a black hole or some inter-dimensional vortex.
  quote
PKIDelirium
Veteran Member
 
Join Date: Oct 2005
 
2009-08-04, 02:47

Your topic title would look better if it ended in "FML".
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Page 1 of 2 [1] 2  Next

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
"Wireless game adapter" + wired router: will this work? Wyatt Genius Bar 0 2008-10-09 10:01
Does the Apple Remote work with the "EyeTV for DTT USB Stick" IR sensor? Roberto Alvarez Apple Products 1 2008-05-25 14:27
Parallels Desktop getting Stuck on "Applying Computer Settings" jcoley2 Genius Bar 11 2006-10-28 16:20
Please explain "index" in MySQL nassau Programmer's Nook 7 2006-10-04 16:49
Feb 28: 13-in MacBook Core Duo confirmed. (according to some guy's "friend" at Apple) AlexN Speculation and Rumors 32 2006-02-25 18:20


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 13:56.


Powered by vBulletin®
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2022, AppleNova