Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Digital Literacy Computer Basics Computer Basics Data

Data is consists of 0 and one, what does the program consist of?

Programs control receiving and sending data. and data consists of 0 and 1. What does program consist of?

2 Answers

Hi there!

What you're talking about is machine code - the 0's and 1's of how a computer runs.

Put simply, it's all one long stream of numbers, either 1 or 0. Whether it's stored on your hard drive, a DVD, USB or RAM, it's just a long stream of number and those numbers can only be 1 or 0.

The way it works however is that we give meaning to the numbers by grouping them together and creating chips that read and write the numbers exactly how we intend them to.

The way this works is chip instructions. You may have heard of the term "instruction set" when people talk about say intel processors or ARM processors. The instruction set of a chip is, not surprisingly a list of the operations a chip can do, and each of those instructions is mapped directly to a specific number. So, once you start your chip, it reads the first set of numbers as an instruction, then the next set(s) of numbers based on how that instruction tells the chip to read them. They're still just a long stream of 1's and 0's but meaning is given to them for the chip by the instruction that preceeds them.

That's why ARM and Intel chips can't run the same 1's and 0's - the instructions are different.

However, for the sake of sanity, we have commonality when it comes to data - things like ASCII and UniCode encoding mean that whatever chip you have, they'll store characters in the same way. And we have the same with numbers - floats and ints are stored only a handful of ways.

So basically all the 1's and 0's are are a series of operations for the computer to do and data. The operations tell the chip what to do with the data, and now the long line of numbers is usable.

When you program in a language that is not machine code (manually entering 1's and 0's into a computer), your code has to be converted from strings into 1's and 0's. If you program in assembly language, each command you type is just an instruction for the processor to do. However, all other languages need to be compiled into machine code.

Whether you program in C, C++, Java, Python, Ruby, Javascript, your code is compiled into instructions and data. If you are using what's called a "compiled language" then the whole program is compiled before running, if you are using an interpreted language, it's compiled at run time, but either way it's compiled into instructions and data. Some are obvious - whatever landuage you're using, it's pretty obvious that 3 + 3 will result in the chip's add instruciton being called, others take many many operations to complete. The beauty of the compiler is that you can make one for any chip, so you could write the same C program and compile it for Arduino, or Pi, or Windows, or iPad, etc. Because the compiler decides which instructions are required for each platform.

Thank you for your answer. I apprecite the effort in explaining in details but I would like to tell you that there some parts that are still vague to me because I still do not have a strong background in this field.

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Maisa. Welcome to Treehouse.

Everything in the Internet of Things is made up with 1s and 0s. A program really is just data too. It's data that is used by a system to execute a series of instructions. Data can be many things and come in many forms, but it's all just ones and zeros (otherwise known as Binary).

Hope that helps and Keep Coding! :) :dizzy:

Thank you for your simple and clear answer.