text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
>> Meanwhile, we've seen this before, printf or print formatted, that's
596.97
4.16
going to be a function that comes with C, along with a whole bunch of others,
601.13
4.49
that will from time and time again, in order to do exactly
605.62
4.52
as its name suggests, print something.
610.14
2.31
What do we want to print?
612.45
1.05
Well, we'll see that by enclosing characters
613.5
2.27
like these-- hello world, backslash n in double quotes,
615.77
2.91
we can tell printf exactly what to print on the screen.
618.68
4.36
>> But in order to do that, we unfortunately
623.04
3.39
need to take something that is already cryptic to us humans,
626.43
3.58
but at least it's somewhat readable-- sharp include, standard io.h, int,
630.01
4.5
main, void, printf, all of the magical incantations we just saw on the screen.
634.51
4.83
But we actually have to go more arcane still.
639.34
3.13
We first need to translate the code that we write into machine code.
642.47
4.67
And recall from last week that machines, at least the ones we know here,
647.14
4.23
at the end of the day only understand zeros and ones.
651.37
3.08
>> And my God, if we had to write these zeros and ones to actually program,
654.45
3.65
it would very, very quickly take the fun out of anything.
658.1
3.16
But it turns out, per last week, that these patterns of zeros and ones
661.26
3.89
just have special meaning.
665.15
1.25
In certain contexts, they might mean numbers.
666.4
2.1
>> In some contexts, they might mean letters, or colors, or any number
668.5
3.34
of other abstractions there upon.
671.84
2.87
But just as your computer has a CPU, Central Processing Unit,
674.71
3.74
or the brains inside of your computer.
678.45
1.94
It's usually Intel inside, because that's
680.39
1.85
one of the biggest companies that makes CPUs for computers.
682.24
2.66
>> Well, Intel CPUs and others simply have decided in advance
684.9
4.01
that certain patterns of zeros and ones shall mean specific things.
688.91
5.06
Certain patterns of zeros and ones will mean, print this to the screen,
693.97
3.07
or add these two numbers, or subtract these two numbers,
697.04
2.67
or move this piece of data from my computer's memory over here,
699.71
3.6
or any number of other very low level, but ultimately useful, operations.
703.31
4.56
But, thankfully, we humans are not going to need to know this level of detail.
707.87
5.152
Indeed, just like last time, where we abstracted again, and again, and again,
713.022
3.208
building from very low level primitives like zeros and ones
716.23
2.7
to higher level concepts like numbers, and letters,
718.93
2.23
and colors, and more, so can we as programmers
721.16
3.17
stand on the shoulders of others who have come before us
724.33
2.75
and use software that other people have written before us--
727.08
4.18
namely programs called compilers.
731.26
3.08
>> C is a language that is usually compiled,
734.34
3.43
which means converted from source code to machine code.
737.77
4.36
In particular, what this means is that if you've got your source
742.13
3.1
code that you yourself write, as we soon will in just a moment on the screen,
745.23
4.3
and you want to convert it ultimately to machine code--
749.53
3.61
those zeros and ones that only your Mac or your PC
753.14
3.96
understands-- you've got a first feed that source code in as
757.1
4.13
input to a special program called a compiler,
761.23
5.11
the output of which we shall see is machine code.
766.34
2.634
And, indeed, last time we talked about, really, at the end of the day,
768.974
2.916
problem solving.
771.89
0.72
You've got inputs.
772.61
0.75
And you've got outputs.
773.36
0.958
And you've got some kind of algorithm in the middle.
774.318
2.242
>> Algorithms can surely be implemented in software,
776.56
3.27
as we saw with pseudocode last week and as we'll see with actual code
779.83
3.07
this week.
782.9
0.59
And so a compiler really just has a set of algorithms inside
783.49
2.94
of it that know how to convert the special keywords,
786.43
3.63
like main, and printf, and others that we just
790.06
2.12
saw into the patterns of zeros and ones that Intel inside and other CPUs
792.18
5.44
actually understands.
797.62
2.4
So how do we do this?
800.02
2.44
Where do we get a compiler?
802.46
2.01
>> Most of us here have a Mac or a PC.
804.47
1.93
And you're running Mac OS, or Windows, or Linux, or Solaris,
806.4
2.752
or any number of other operating systems.
809.152
1.708
And, indeed, we could go out onto the web
810.86
1.708
and download a compiler for your Mac or your PC
812.568
3.142
for your particular operating system.
815.71
1.65
But we would all be on different pages, so to speak.
817.36
2.257
We'd have slightly different configurations.
819.617
1.833
And things wouldn't work all the same.
821.45
1.76
And, indeed, these days many of us don't use
823.21
2.07
software that runs only on our laptops.
825.28
2.236
Instead, we use something like a browser that
827.516
1.874
allows us to access web-based applications in the cloud.
829.39
3.54
And later this semester, we will do exactly that.
832.93
2.7
We will write applications or software using code-- not C,
835.63
4.03
but other languages like Python and JavaScript-- that run in the cloud.
839.66
3.2
>> And to do that, we ourselves during the semester
842.86
3
will actually use a cloud-based environment known as CS50 IDE.
845.86
6.03
This is a web-based programming environment, or integrated development
851.89
4.14
environment, IDe, that's built atop some open source software called Cloud 9.
856.03
4.58
And we've made some pedagogical simplifications to it
860.61
2.356
so as to hide certain features in the first weeks that we don't need,
862.966
2.874
after which you can reveal them and do most
865.84
1.93
anything you want with the environment.
867.77
1.63
>> And it allows us, too, to pre-install certain software.
869.4
3.07
Things like a so-called CS50 library, which we'll soon see
872.47
2.86
provides us in C with some additional functionality.
875.33
3.88
So if you go to, ultimately, CS50.io, you'll be prompted to log in,
879.21
5.182
and once you do and create an account for free,
884.392
1.958
you will be able to access an environment that looks quite like this.
886.35
5.8
>> Now, this is in the default mode.
892.15
1.61
Everything is nice and bright on the screen.
893.76
1.89
Many of us have a habit of working on CS50 piece that's
895.65
2.291
quite late into the night.
897.941
1.209
And so some of you might prefer to turn it into night mode, so to speak.
899.15
3.25