When David was a freshman, he was too intimidated to take any computer science classes. But even if the topic feels out of your comfort zone, know that we’ll fill in all the blanks along the way, until we are all on the same page.
In fact, 68% of CS50 students have never taken a CS course before.
To support you, there is an amazing staff, sections, and office hours.
And importantly, too:
what ultimately matters in this course is not so much where you end up relative to your classmates but where you, in Week 10, end up relative to yourself in Week 0
Computer science is fundamentally problem-solving, and programming alone or (more likely) collaboratively is one way to do that.
We can think of problem-solving as the process of taking some input (details about our problem) and generate some output (the solution to our problem). The “black box” in the middle is what we’ll gradually learn more and more about in this course.
We need a way to represent inputs in some standard way, and if our problem were to simply count the number of people in the lecture hall, we’d have many options. We could write tally marks on a board, or use our hands. In fact, with just one hand, we can use our fingers creatively: with just our thumb up, we could represent one; with our just index finger up, we could represent two; with both our thumb and index finger up, we could represent three. And by continuing to use a pattern of permutations, we could represent 32 different values with just five fingers!
A computer, at the lowest level, stores data in binary, where there are just two digits, 0 and 1. And that maps to how our computers use electricity, which is easy to turn off or on.
As humans, we know the following represents one hundred and twenty-three.
1 2 3
3
is in the ones column, the 2
is in the tens column, and the 1
is in the hundreds column.123
is 100×1 + 10×2 + 1×3 = 100 + 20 + 3 = 123.In binary, with just two digits, we have powers of two for each place value:
4 2 1
0 0 0
Now if we change the binary value to, say, 0 1 1
, the decimal value would be 3.
4 2 1
0 1 1
With enough bits, or binary digits, computers can count much higher.
To represent letters, all we need to do is decide how numbers map to letters. Some humans, many years ago, collectively decided on a standard mapping called ASCII. The letter “A”, for example, is the number 65, and “B” is 66, and so on.
And computer programs know, based on the context of its code, whether the binary numbers should be interpreted as numbers, or letters, or even other media.