text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
So those things happen first during preprocessing.
7,464.69
2.7
>> And Clang does all of this for us.
7,467.39
1.49
And it does it so darn fast, you don't even
7,468.88
1.63
see four distinct things happening.
7,470.51
1.49
But that's the first such step.
7,472
2.1
>> What actually happens next?
7,474.1
1.46
Well, the next official step is compiling.
7,475.56
2.76
And it turns out that compiling a program
7,478.32
2.065
technically means going from source code, the stuff we've
7,480.385
3.675
been writing today, to something called assembly code, something
7,484.06
3.83
that looks a little different.
7,487.89
1.37
>> And, in fact, we can see this real fast.
7,489.26
1.79
Let me actually go into my IDE.
7,491.05
2.84
Let me go ahead and open hello.c, which is the very first program with which we
7,493.89
4.16
began today.
7,498.05
1.07
And let me go ahead and run Clang a little differently, Clang-s, hello.c,
7,499.12
5.01
which is actually going to give me another file hello.s.
7,504.13
3.59
>> And we will probably never again see this kind of code.
7,507.72
2.61
If you take a lower level systems class like CS61,
7,510.33
2.7
you will see a lot more of this kind of code.
7,513.03
1.89
But this is assembly language.
7,514.92
2.1
This is X86 assembly language that the CPU that is underlying
7,517.02
5.03
CS50 IDE actually understands.
7,522.05
2.41
>> And cryptic as it does look, it is something
7,524.46
2.6
the computer understands pretty well.
7,527.06
2.12
Sub q, this is a subtract.
7,529.18
1.61
There's movements.
7,530.79
0.87
>> There's calling of functions here, x oring, a movement, an add, a pop,
7,531.66
4.07
a return.
7,535.73
0.7
So there's some very low level instructions
7,536.43
2.42
that CPUs understand that I alluded to earlier.
7,538.85
2.43
That is what Intel Inside.
7,541.28
1.82
>> There are patterns of zeros and ones that
7,543.1
1.93
map to these arcanely worded, but somewhat well-named, instructions,
7,545.03
6.77
so to speak.
7,551.8
0.98
That is what happens when you compile your code.
7,552.78
2
You get assembly language out of it, which
7,554.78
3.78
means the third step is to assemble that assembly code into, ultimately,
7,558.56
6.12
machine code-- zeros and ones, not the text that we just saw a moment ago.
7,564.68
4.4
>> So pre-processing does that find and replace, and a few other things.
7,569.08
4.29
Compiling takes your source code from C, source code
7,573.37
3.06
that we wrote, to assembly code that we just glanced at.
7,576.43
2.55
Assembling takes that assembly code to zeroes and ones
7,578.98
3.19
that the CPU really will understand at the end of the day.
7,582.17
2.51
And linking is the last step that happens for us-- again,
7,584.68
2.95
so fast we don't even notice-- that says,
7,587.63
2.2
hey computer, take all of the zeros and ones that
7,589.83
2.63
resulted from compiling David's code, and his main function in this case.
7,592.46
4.29
>> And hey computer, go get all of the zeros and ones
7,596.75
2.41
that the CS50 staff wrote inside the CS50 library.
7,599.16
3.02
Mix those in with David's.
7,602.18
1.26
And hey computer, go get all the zeros and ones that someone else wrote years
7,603.44
3.208
ago for printf.
7,606.648
0.822
And add those into the whole thing, so that we've
7,607.47
2.41
got my zeros and ones, the CS50 staff's zeros and ones,
7,609.88
2.99
the printf zeros and ones, and anything else we're using.
7,612.87
2.5
>> They all get combined together into one program called, in this case, hello.
7,615.37
5.04
So henceforth, we will just use the word compiling.
7,620.41
2.731
And we will take for granted that when we say, compile your program, it means,
7,623.141
3.249
hey do the pre-processing, assembling, and linking.
7,626.39
2.459
But there's actually some juicy stuff going on there underneath the hood.
7,628.849
3.041
And especially if you get curious some time,
7,631.89
1.833
you can start poking around at this lower level.
7,633.723
2.177
But for now, realize that among the takeaways for today
7,635.9
3.76
are quite simply the beginning of a process,
7,639.66
3.76
of getting comfortable with something like hello world.
7,643.42
3.28
Indeed, most of what we did today certainly won't sink in super fast.
7,646.7
2.875
And it will take some time, and some practice.
7,649.575
1.916
And odds are, you will sort of want to hit your keyboard
7,651.491
2.373
or yell at the screen.
7,653.864
0.916
And all of that's OK.
7,654.78
1.1
Though, perhaps try not to do it in the library so much.
7,655.88
2.44
>> And ultimately, you'll be able though, to start
7,658.32
2.5
seeing patterns, both in good code that you've written and in mistakes
7,660.82
3.76
that you've made.
7,664.58
0.79
And much like the process of becoming a TF or a CA is like,
7,665.37
3.595
you'll start to get better and better at seeing those patterns,
7,668.965
2.625
and just solving your own problems ultimately.
7,671.59
2.184
In the meantime, there will be plenty of us to lend you support, and get you
7,673.774
3.166
through this.
7,676.94
0.541
And in the write-ups for all of the problems
7,677.481
1.969
will you be guided through all of the commands
7,679.45
1.916
that I certainly know from a lot of practice by now,
7,681.366
3.964
but might have flown over one's head for now.
7,685.33
2.05
And that's totally fine.
7,687.38
1.2
>> But, ultimately, you're going to start to see patterns emerge.
7,688.58
2.65
And once you get past all of the stupid details, like parentheses,
7,691.23
3.03
and curly braces, and semi-colons, and the stuff, frankly,
7,694.26
2.45
that is not at all intellectually interesting.
7,696.71
2.65
And it is not the objective of taking any introductory class.
7,699.36
3.33
It's the ideas that are going to matter.
7,702.69
1.72
>> It's the loops, and the conditions, and the functions,
7,704.41
2.249
and more powerfully the abstraction, and the factoring of code,
7,706.659
3.893
and the good design, and the good style, and ultimately the correctness
7,710.552
2.958
of your code, that's ultimately going to matter the most.
7,713.51
3.82
So next week, we will take these ideas that we first saw in Scratch
7,717.33
3.595
and have now translated to C. And we'll start
7,720.925
1.875
to introduce the first of the course's real world domains.
7,722.8
2.94
>> We'll focus on the world of security, and more specifically cryptography,
7,725.74
4.4
the art of scrambling information.
7,730.14
1.84