Alana on Harvard CS50, learning C

Alana is working through Harvard's CS50, learning C after Scratch and Python. She covers syntax like printf and format specifiers, shell commands, and how a compiler turns code into binary. She's also training jiu-jitsu with bigger partners.
Chapters
So I wanted to check in on CS50. How is CS50 going?
So since my change in schedule, I've been really, really busy, and I haven't had a chance to focus on that in a little while. But now on Monday, now that I've gotten my schedule in control, I'm going to— move some things around and progress more. I still have some of the video to watch, and then I'm gonna work really hard on all the— and on the rest of this stuff.
The video of Lesson 1?
I think it was Lesson 2 now, and I've been stalling. I've been stalling on it for a little while because, like I said, the schedule changed. But, um, this Monday, um, I'm gonna start, and then I have a little more time because we were training for competition this past weekend.
Got it.
So that was also taking up time.
In Lesson 1, my understanding is— I may have an old version of CS50— that you largely went from Scratch to C. You kind of learned a bit about the C language. Is that correct?
Yes.
And how was the transition from Scratch to C for you?
It wasn't that hard because I've done Scratch before, and then C is also like Python. But it was a little harder to remember because I'm used to Python. But I think it made sense.
Got it. I'm going to see if we can look at— these are some— this is something that I got from an old Harvard CS50. That's Scratch. Correct?
Mm-hmm.
And then this is— these are notes from an older version of Harvard CS50. And so what they do, and what was interesting to me, is on the left is Scratch, on the right is C, correct?
Yes.
And do you understand how to translate the Scratch into C?
Yes.
So can you explain? I actually learned C a long time ago. It's so long, it's like 80% forgotten. So can you explain how to translate the Scratch on the left to the C on the right? What are the various things going on in the C code doing?
OK, well, on the Scratch on the left, you start out with the beginner statement, when the green flag clicked, and that just kind of signifies the beginning of the program. And then you're going to print out or say hello world. For C, to be honest, I'm still kind of in the gray about what #include <stdio.h> means. But int main in parentheses signifies the beginning of the function. And then printf is printing and saying.
Got it. Do we know why we have main and then void in parentheses?
Because our main is— I don't know if it's a reserved word, but that this is the main function and then void. I think it means when you don't return anything.
Got it. Okay, that makes sense. And again, I don't, don't count on me because I've forgotten most of my C, but I think the hashtag include is that there are various library functions and that, you know, and so there's like a library of code. And when you say include such and such, I think it's calling a certain code library. Does that make sense? Does that kind of vaguely like what you think the hashtag include means?
Yes.
And you can ask Zulake to double check on that. So just want to check on another one. So because they've got a bunch of these. So here, this looks like a simpler version of the one above actually. So You wanna explain how the C is a translation of the Scratch on the left?
Well, Greenfly clicked signifying the big start of the program, and then int main void, I guess in this case, it equals the start.
And then the program does nothing, correct?
Yes.
Okay. It's a little bit weird, but, you know, that's a possibility. OK, and then, oh, you know what they're doing? They're breaking up the thing we saw together. So here it's confusing because it doesn't have hello world. Why does the C version not have the hello world?
My initial guess was that because you don't need to say hello world when you say print. Well, I see.
Okay. Let's see what they do in a subsequent one. Print. Do you know the difference between print and printf?
Not really.
Okay. I don't either. Okay. So now for some reason, now we've got the whole printf and hello world. This is a slide deck from an old version of CS50. And so the— professor would be explaining this as we go. So I thought we'd, you and I just try to figure it out as we went together. Does it, well, actually a question, does hello world here need quotation marks or does it not need quotation marks?
It does need quotation marks.
Okay. So let's see if they do that. Aha. Hello world. You were, you predicted that correctly. Yes. So I see what he's doing is he's kind of going step by step. Is this the full— is the C code on the right the full translation of the Scratch code on the left now?
Almost, but I might be being really specific. I think it needs the semicolon at the end.
Ah, okay, let's see. Ah, brilliant, absolute kudos. You said it needs the semicolon, and indeed it does. OK. Let's see. So now it's showing us— again, do you see how it's sort of doing it piece by piece by piece? And now it shows us the whole thing, the Scratch code on the left. So did your version of CS50 do this? Did they kind of translate Scratch into C to help you understand the C code?
I think they did.
Got it. And was it pretty easy? I mean, I can see the Python C confusion. 'cause Python and C are much more similar than Scratch. Scratch is a visual language, so it's very different. But other than the confusion with Python, would you say C was relatively easy to understand?
I think so.
Okay, let's, they do some harder one. Let's see if they explain why they include the StudioH. Maybe they just, I guess you just need that library to make it all work. So now this is the sandbox. There are a bunch of functions. Do you know, um, cd, ls, mkdir? Do you know all these?
I remember them, and I know cd and ls because I use them sometimes, but I think they're for getting into the console to get into your program if you're not doing it manually or something like that. But not sure about the rest of them.
So ls, I think from my old C days, ls I think is list, maybe make a list. Does that sound right?
I'm not sure, maybe.
cd is maybe change directory?
Yes.
mkdir is make directory?
That makes sense.
rm, remove?
Remove directory.
Yeah, an rmdir, that's my guesses. So this is the same code. I don't know why I've got the binary. Do you know about binary?
I do, and I've, I've looked through multiple lessons about binary. I just get confused at when it starts to spread into multiple numbers, but I guess I know the very basics, though it'd be really hard to understand. Are really hard to explain.
I'm kind of where you are. I get the basics of binary. I can count in binary, but you can imagine, you know, you know, at the code level, a machine level, binary, but how to go from, you know, the code we write like C or Python down to binary, that would be a lot of work. Input/output. So I'm just kind of checking here. I wanted to check to see where you were on your C, it looks like most of this is familiar. Did you talk about a compiler at all? What a compiler does?
Yeah, we did.
Okay. Yeah, source code, that's like this, my understanding, that's like the C or Python you write. And then the compiler translates that into something the machine can read in binary. And without a compiler, it would be, back in the days, people had to write code in binary, human beings did. It would be really, really hard. Let's see, I don't see anything too interesting here. I think they go into more elaborate examples. Ask what's your name and wait. Let's see. So they're going to do the same thing here. Aha, getString. Do you know what getString does?
It gets a string or answers a string.
What would be the— What would be the equivalent in the Scratch on the left?
Get the answer or the thing you get from GetString would be answer.
Okay. And here, what's your name? Why the slash n after what's your name in the—
Slash n, new line.
Oh, I see. Okay. I had totally forgotten that. I was lost. Without you on that one. Answer equals getString, what's your name, new line. OK. This makes sense to me. Does it make sense to you?
Yes.
I'm kind of processing it in real time. Is all of this, like, super familiar to you?
It's pretty familiar to me.
OK.
But I guess just the basic stuff like this.
Yeah, I think this is a 4-year-old version of CS50, so it might be a little bit different. String answer. Maybe I'll just cruise down to how they got it all compiled, or all the full chunk of code. Yeah, let's, let's look at this one. So string answer equals GetString, what's your name, slash n, and then printf, hello, what is the %s slash n, what's that doing?
Well, I'm still in the process of memorizing those, but I think you put them in when you put in a variable to your printf. I'm not sure, maybe you just put it overall. I think the letters mean— I think s means string because you're putting in a string, and then there's a specific letter for integer, but I'm not sure what the rest of the characters mean. I guess.
Um, and so, what's your name? Well, I'm— what's your name? And then you would put Alana or Michael or whatever, um, and then it would say hello. And that's what that's doing. Did you do Scratch programs similar to this?
I did.
Were they pretty easy and fun to do?
They, they were. There. Yeah.
And at this point, uh, would you say that C programs are easy and fun to do or not yet?
Well, it depends on the program. I own— I can't really only have got down some of the basics, I guess, things like this.
Got it.
So I think, yeah.
How about, how does C compare to Python? Similar, easier, more difficult, better for some things, worse for others?
I mean, for me right now it's a bit more difficult just because it's different in multiple ways. And then there's some things that I have to relearn in order to learn C.
Things relearn in that you kind of knew the concept in Python, but because it's different in C, you have to relearn, or just you kind of forgotten from the Python?
I think relearn was, that was a bad word, and I think what I meant was It's similar to Python, but then there are other things that make it C, which makes it a bit confusing.
Got it. Do you have a—
So I mix up the two sometimes, but—
It makes sense. Makes sense. Do you have a sense as to whether you like C better or Python better, or it's too early to know?
Well, I'd say it's too early to know, but of course, I'd feel more comfortable with the one I know better.
Of course. And how about Python versus Scratch?
Well, I mean, they're both obviously very different. I mean, it's the blocks in Scratch, and that's definitely way easier. But in some ways, it's a little harder because you have to find the exact blocks, and you can't just type it out.
So would you— go ahead.
I think Python might be used for more things, but Scratch is overall really fun.
Got it. So Scratch is fun and easy. Totally get that. But it sounds as if you're already getting the sense that Python might be a bit more flexible in terms of what you can do with it.
Yeah.
Okay, that makes a lot of sense. That's why Scratch is kind of a learning language and not really used for professional things, but both Python and C are used by professional software developers, because Scratch, Scratch is kind of a toy. I mean, it's not a real coding language, but Python and C are real coding languages. Oh, cool. Well, I wanted to catch— we hadn't talked about CS50 in a long time, so I had to kind of catch up and see how how that's going. Um, and, uh, congrats again on moving to the adult, uh, training for jiu-jitsu. Is it, is it strictly jiu-jitsu or is it broader than that?
It's jiu-jitsu. So now I'm doing the adults and then the kids.
Are you ever intimidated by the adults?
Um, I mean, there, there come times when that can happen. I only have a few partners that come with me or that are my size. So I'm a little limited in training, but not really, because sometimes I get to roll with the adults and the teens, which is amazing. But they, they can be intimidating.
You're a lot smaller.
They all know me, and they're really nice.
Okay, yeah, they're— you're a lot smaller, so— but you're okay occasionally training with somebody who's a lot bigger than you?
They don't go their hardest, of course, but they go hard enough to give me good training.
Good, good. Okay, well, congrats on that, and good to see you after a little break. And we'll keep checking in on progress in all the directions, okay?
Awesome, thank you.
All right, yep, take care. Bye-bye.
Bye.










