1 00:00:00,000 --> 00:00:00,500 2 00:00:00,500 --> 00:00:02,340 SPEAKER 1: Probably implementing a program. 3 00:00:02,340 --> 00:00:05,181 But let's just see now what it is we've been doing all this time 4 00:00:05,181 --> 00:00:05,930 and what some of-- 5 00:00:05,930 --> 00:00:07,930 SPEAKER 2: So again, we're going to sort of take 6 00:00:07,930 --> 00:00:13,405 one final peek at some abstraction here when we talk about compiling. 7 00:00:13,405 --> 00:00:15,780 SPEAKER 3: Yeah, this is a topic of always wrestled with. 8 00:00:15,780 --> 00:00:18,330 As to how low level to get and when to do it. 9 00:00:18,330 --> 00:00:22,460 we've oscillated over the years as to where this topic, if anywhere, goes. 10 00:00:22,460 --> 00:00:25,710 In recent years, I've really just kind of thrown it in the middle of the class 11 00:00:25,710 --> 00:00:28,121 when there's a gap and it never felt right there. 12 00:00:28,121 --> 00:00:30,870 And this was the first year where we've really done it this early. 13 00:00:30,870 --> 00:00:33,710 Talking about pre-processing, compiling, assembling, and linking. 14 00:00:33,710 --> 00:00:35,370 And I actually think it kind of worked. 15 00:00:35,370 --> 00:00:37,411 I mean, we allowed ourselves the luxury this year 16 00:00:37,411 --> 00:00:39,404 of having a variable length lectures. 17 00:00:39,404 --> 00:00:41,320 So we gave ourselves more time if we wanted it 18 00:00:41,320 --> 00:00:43,340 and less time if we didn't need it. 19 00:00:43,340 --> 00:00:45,870 I didn't want to scare too much, right, because we're only 20 00:00:45,870 --> 00:00:48,276 in the second week really of the class here. 21 00:00:48,276 --> 00:00:49,150 But I think it helps. 22 00:00:49,150 --> 00:00:51,300 So long as we don't dwell too much on it. 23 00:00:51,300 --> 00:00:55,050 I think it helps to go all the way down to where assembly meets, or really 24 00:00:55,050 --> 00:00:58,219 where machine code meets source code, and then just abstract on top of that. 25 00:00:58,219 --> 00:01:00,760 SPEAKER 2: Yeah, we don't really get into this sort of detail 26 00:01:00,760 --> 00:01:01,843 again later in the course. 27 00:01:01,843 --> 00:01:05,550 But like you said, knowing when pound include 28 00:01:05,550 --> 00:01:10,615 happens, when pound define happens, and how exactly the CS50s library when 29 00:01:10,615 --> 00:01:11,490 you do pound include. 30 00:01:11,490 --> 00:01:14,510 How those bytes get integrated into your program. 31 00:01:14,510 --> 00:01:17,832 it's something that's worth talking about early, but like you said, 32 00:01:17,832 --> 00:01:19,290 we want to abstract away from that. 33 00:01:19,290 --> 00:01:22,320 We don't want to make that the take away here. 34 00:01:22,320 --> 00:01:25,380 just this additional piece of understanding about what's going on. 35 00:01:25,380 --> 00:01:28,171 SPEAKER 3: And I actually feel now in retrospect it's now or never. 36 00:01:28,171 --> 00:01:31,644 Because it was always weird to do it mid-semester and sort of blow 37 00:01:31,644 --> 00:01:34,810 up the abstraction and go back down and look at what's really been going on. 38 00:01:34,810 --> 00:01:37,170 And there's just no contextual motivation for it. 39 00:01:37,170 --> 00:01:40,470 Here at least, I think just minutes after students 40 00:01:40,470 --> 00:01:44,054 have started seeing clang and make and seeing fairly cryptic commands 41 00:01:44,054 --> 00:01:46,470 or command line arguments appear on the screen giving them 42 00:01:46,470 --> 00:01:50,244 a sense of what those things are doing so that it's not so cryptic. 43 00:01:50,244 --> 00:01:52,410 SPEAKER 2: The first time they've compiled a program 44 00:01:52,410 --> 00:01:53,550 now they're actually doing it. 45 00:01:53,550 --> 00:01:53,730 SPEAKER 3: Yeah. 46 00:01:53,730 --> 00:01:54,600 SPEAKER 2: I would say the one tricky thing 47 00:01:54,600 --> 00:01:57,944 about explaining this is that compiling contains a step called compiling. 48 00:01:57,944 --> 00:01:58,610 SPEAKER 3: Yeah. 49 00:01:58,610 --> 00:01:58,920 I know. 50 00:01:58,920 --> 00:01:59,640 It's not obvious. 51 00:01:59,640 --> 00:02:02,940 So hopefully having that list of just the four steps 52 00:02:02,940 --> 00:02:07,089 that most people just call compiling all together helps. 53 00:02:07,089 --> 00:02:08,880 and this is the only time we show assembly. 54 00:02:08,880 --> 00:02:11,460 And we don't really go into detail as to the registers and the instructions 55 00:02:11,460 --> 00:02:12,460 as to what's going on here. 56 00:02:12,460 --> 00:02:15,168 But I think it's kind of neat to give students a glimpse of that. 57 00:02:15,168 --> 00:02:17,292 It's not zeros and ones but it's also not C. 58 00:02:17,292 --> 00:02:18,250 SPEAKER 2: That's true. 59 00:02:18,250 --> 00:02:20,190 And in CS50 AP, we actually do have a problem 60 00:02:20,190 --> 00:02:22,273 where we do have students take a look in assembly. 61 00:02:22,273 --> 00:02:25,860 When I took CS50, we had a problem set that was written in assembly. 62 00:02:25,860 --> 00:02:30,100 It certainly makes you long for the days of C. 63 00:02:30,100 --> 00:02:33,100 SPEAKER 3: Yes, you very quickly appreciate. 64 00:02:33,100 --> 00:02:35,280 But that's not the goal here. 65 00:02:35,280 --> 00:02:37,530 But you can start to pluck out familiar things, right? 66 00:02:37,530 --> 00:02:41,730 Like the low level print F instruction and get the notion of returning. 67 00:02:41,730 --> 00:02:43,780 Or pushing and popping watch to come back to. 68 00:02:43,780 --> 00:02:45,300 SPEAKER 2: Moving, adding, calling. 69 00:02:45,300 --> 00:02:46,650 You see some things in there. 70 00:02:46,650 --> 00:02:50,070 It's clearly one step lower than the C-like syntax we're used to, 71 00:02:50,070 --> 00:02:52,999 but we're not quite down to zeros and ones yet. 72 00:02:52,999 --> 00:02:56,040 SPEAKER 3: But what I like to is the notion of linking especially, right? 73 00:02:56,040 --> 00:02:59,077 Especially doing the hash include at the top of your file really 74 00:02:59,077 --> 00:03:01,410 it's just getting you access to the header file, but not 75 00:03:01,410 --> 00:03:04,805 the underlying zeros and ones into which the library itself has been compiled. 76 00:03:04,805 --> 00:03:07,680 So making this distinction between header file and the actual library 77 00:03:07,680 --> 00:03:11,330 code, the formerly dot C file that's a dot SO or dot O 78 00:03:11,330 --> 00:03:13,590 or whatever somewhere on the file system. 79 00:03:13,590 --> 00:03:16,380 Where those bits are coming from that compose print F 80 00:03:16,380 --> 00:03:18,130 I think is pretty helpful to mention. 81 00:03:18,130 --> 00:03:18,340 SPEAKER 2: Yeah. 82 00:03:18,340 --> 00:03:20,756 It's not the kind of thing that needs to remain a mystery. 83 00:03:20,756 --> 00:03:23,870 Because if people want to go on and do-- 84 00:03:23,870 --> 00:03:26,860 and use the CS50 library in an environment that's not the CS50 IDE. 85 00:03:26,860 --> 00:03:30,060 It's helpful to know exactly how to recreate that 86 00:03:30,060 --> 00:03:32,720 and where to store it in your file system. 87 00:03:32,720 --> 00:03:36,300 Again, these small little skills that are nice to know, 88 00:03:36,300 --> 00:03:38,562 but are not essential to taking CS50. 89 00:03:38,562 --> 00:03:40,020 SPEAKER 3: It's the complete story. 90 00:03:40,020 --> 00:03:42,330 And especially by way of things being on video, if the student really 91 00:03:42,330 --> 00:03:44,700 doesn't want to dive into this just yet or maybe it's a little too 92 00:03:44,700 --> 00:03:46,530 much too soon, skip over it, come back. 93 00:03:46,530 --> 00:03:49,321 But at least it's chronologically now, I think, in the right place. 94 00:03:49,321 --> 00:03:50,600 SPEAKER 2: I agree.