Week 1: Friday - CS50 2011 - Harvard University

CS50 · Intermediate ·🔧 Backend Engineering ·11y ago

Key Takeaways

The video covers the basics of C programming, including source code, compilers, object code, GCC, functions, comments, standard output, arithmetic operators, precedence, local variables, types, casting, standard input, libraries, boolean expressions, conditions, and loops, using the CS50 2011 course from Harvard University as a reference.

Full Transcript

All right, welcome back. This is CS50 and this is the end of week one. We are so pleased that so many of you have returned to us. Indeed, there are a total of 646 of you who have returned to us this year. Roughly 246 of which are still sleeping or at home it seems now, but that's okay. Everything will remain available online. Indeed, the lectures go up quite quickly as will scribe notes, the transcripts thereof, and yet other resources on the courses website. Um, but a couple of mentions now because this is of course the beginning of the semester and you certainly have the discretion of the next several weeks to either remain with or leave us. Let me make a personal request that if you do decide that life's getting in the way or you are thinking yourself you are the least comfortable person in the room, do reach out whether during office hours off to the side or just reach out to me so that we can at least have a conversation. We have a team of over 80 TFs and CAs, all of whom are very eager to make sure that every single one of the 646 in this room make it through to term's end and you can and you will, but do engage us in a conversation if you're feeling more than just a little bit stressed at any point. With that said, uh, we'd like to and do take advantage too of the option to do pass/fail, um, which we can do up until the fifth Monday, but more on that in the syllabus. So, with that said, we cordially invite all 646 of you to lunch, uh, most any Friday during the term. it's a large course, we like to make sure there's more intimate opportunities to chat with me, with the TFs, with the CAs, often with industry guests and recruiter friends of ours so that you have a chance to make the course feel much more intimate. So, typically what we'll do every Friday or so is in, uh, open up an RSVP, uh, starting next week whereby we'll take 20 or 30 folks in the class out to lunch somewhere in the square or in a house and really just have a casual conversation. Because we will no longer after today have lectures on Fridays, we'll try to generally use Fridays for that lunch slot, but for those for whom it's impossible, we'll try to make other other opportunities available. So, more on that next Monday when we set up the RSVPs. So, with regard to our team of some 40 TFs and 40 CAs, all of whom, just to paint this picture, are here to help you throughout the semester. All very nice indeed. So, that's our staff. You can take a look at it online. But, know that office hours have commenced. Indeed, our high-tech fancy iPad-based approach to office hours did begin in Foho and Leverett and Lowell. And we thought we would share a few statistics. So, over the past few nights alone, although this is just term start, we had over 25 questions asked on Monday, almost 100 questions asked on Tuesday and Wednesday, and two questions asked last night, which is great cuz it means no one's taking late days yet really. So, that's terrific in fact. But, in terms of the wait times, which has been the target of this whole initiative, on Monday the average wait time between raising your hand and getting help from a TF or a CA was under 25 seconds. Even on Tuesday, though this bar looks big, that's seconds on the left-hand side. So, the wait time was over just over 2 minutes, and that then decreased again on Wednesday when we threw yet more manpower at it. And our response time last night was really good. It was 0 seconds. So, um Thursdays are clearly the sweet spot. But, no, in fact, quite the opposite. So, do realize that one of the best things you can do in tackling the problem sets is to start early. Not because they're going to take all week necessarily, but honestly, so that you have that option if you're getting stressed out, you hit some barrier, you're facing some stupid bug, and you just don't see it, you can call it a night, you can take a break. And honestly, to this day, anytime I work on coding projects, the moment I start to feel myself getting stressed, you just get stupid, or I do, at that point, and it's just not worth trying to force through it. Better to take a break and come back a little more refreshed and a little more excited. So, what's on the horizon? So, sectioning has commenced. You'll use the FAS sectioning tool, which is linked on the course's home page, between now and Monday, um so that we don't have to rush into putting you into sections that might conflict with your other classes. Sections themselves won't officially start for another week out. So, what we'll have this coming Sunday, Monday, and Tuesday is one super section per day, to which anyone can come. They're not based on track. It's simply an opportunity to get together um with just a couple of TFs and generally more students this first week for an opportunity to discuss the problem set or lecture material or the like. The uh the schedule for those will be posted on the course's website's uh home page. So, what lies ahead? So, believe it or not, starting this weekend or this coming week, the first C-based problem set you'll tackle will be, we hope, quite a bit of fun. Not only will you get this thing called the CS50 Appliance installed on your computer, you'll also implement a few programs. One, the simplest of them, is going to be what what's generally called Hello World. And we've seen that uh as recently as Wednesday, where you just make a program do something silly, like say, "Hi." Or the like. But then we'll ramp up to things more interesting, reminiscent perhaps of the types of problems you might want to have solved in Scratch, whereby you can uh you'll be challenged to uh implement a simulation of sorts of that interaction I had up here in the first day, where I offered either $10 million up front or just one penny a day, and you'll get an opportunity to just get comfortable with the syntax of C and implement that sort of comparison. Uh you'll also be challenged to uh solve what's generally called a greedy problem, but more on that in the spec. And we also drew inspiration this year and last from one of CS50's own students, Teyjas Totra, who graduated in 2010. And her final project, if familiar was this site called I saw you harvard.com. If you click on this page here statistics, you'll see that she's using a free library or API from Google that allows you to create visualizations quite easily by plugging in data she has in her database and generating charts as to who's spotting whom or where sightings occurred. We'll implement this albeit a little less sexy in the context of the appliance using C implement charts like these. And then fast forward till terms end these fairly primitive charts will very quickly involve evolve into something more sophisticated. Now those of you tackling the hacker edition of this piece set will tackle some similar problems but there'll be a twist to each of them whereby the bar will be raised. You'll have to think a bit harder and again the hacker editions assume that you've have some prior programming experience or you simply want to push yourself as hard as you might but again we do expect and we do encourage a super majority of the class to tackle the standard editions by default. The walk through now for problems at one will be this Sunday at 7:00 p.m. We're going to exit Maxwell Dworkin because it's hard to get in on weekends without swiping and so we'll relocate to another building but the location will be posted on the courses home page. And now the last perhaps most compelling announcement is that there's an event in Sanders here around 2:00 p.m. today so we'll adjourn early. So that's our parting Friday gift here for you. Thank you. Thank you. That that's touching. So So let's dive right in. So we looked Wednesday for the very first time at how to write a real program using a real programming language and by real I just mean more traditional a little less user-friendly than Scratch but ultimately much more powerful because with a language like C and later PHP and JavaScript can you command a computer to really do some sophisticated things without some of of limitations or challenges you might have run into in Scratch where you might have just found it hard to express yourself sometimes because a puzzle piece just didn't exist or you didn't know where to find it. So, we introduced C and we introduced the CS50 appliance. And just to kind of get things flowing, what's in sort of easy to understand terms is the CS50 appliance, someone? Yeah. It's an operating system inside of Good. So, it's an operating system inside of a window on your computer. And so, it allows us to create the illusion that all of you are running the same operating system. It happens to be called Fedora, which is a version of Linux. But what that means is that you'll all have a uniform desktop open in a window on your computer, no matter whether you have a Mac or Windows or any type of other machine. So, once you get this thing installed and the PDFs for our problems at one, which will be posted later today on the course's website, will walk you through the process of installing that. Once you have this environment on your computer, we opened up a very simple text editor last time, akin to Notepad or TextEdit or even Microsoft Word, but much much much simpler than that. And so, if I go to menu in the CS50 appliance and I go to programming and I go to Gedit here. Or notice at the bottom, just like in Mac OS and Windows, I can click an icon that's just right there always at the bottom. I get this text editor like this. And in the top here, I have a blinking prompt and a big white space where I can start writing code. And at the bottom, I had what we called a terminal window. And this is just another program that happens to be embedded inside of Gedit. And it just facilitates the process of doing what? Running your program and before that, compiling your program. Because in Linux and also in Mac OS and even in Windows, if you have the right tools, this uh the first programs we'll write will assume a a command line environment, whereby you don't so much double click icons and choose things from menus. Rather, when you want to run a program, you type its name at a prompt. And that program might be GCC, which was the name of the compiler we used. That program might be called hello, which you yourself wrote, but ultimately you can run it in this window. Now, as you acclimate in the problem set, we'll mention this as well, this gets very limiting. You've got 90% of the screen for your code and like 10% for this terminal window. Well, realize also under the CS50 menu, you can go to menu, programming, and then terminal, and then you can actually get a full screen version of this very same tool. And it's black and white instead of white and black, but the program is exactly the same. And then just like a Mac or a Windows computer, you can just alternate with these icons at the bottom between whatever program you want to use. So, just realize you have options, especially if you find this interface limited. Now, later in the term, we'll transition to more sophisticated tools, but for now the intention very deliberately is to keep things simple so we can focus on the ideas and the code and not so much on the intricacies of stupid new programs. We'll get to more sophisticated things before long. So, how do you actually go about writing a program? Well, you open up gedit, you type in some code, and we'll come back to that in a bit, and then you save it. And you save it with what, easy question, file extension from last time? So, dot c. So, dot c is just a convention where if you're writing a C program, call it dot c. In the world of Scratch, your files happen to be called dot sb, but your operating system may have even hid that file extension from you. So, that's it. It's just a convention. And then once you have a file called hello.c, recall that we could compile it in a couple of ways, but the simplest that we focused on ultimately is just to type make hello. Now, make is not a compiler. It's just like one of these automating tools that just makes it easy to figure out what compiler commands to type so you don't have to think about it or type out something very long and tedious. So, make hello will look in your current folder for a file called hello.c, and if it's there, it will translate it into those zeros and ones. Then how did you proceed to run a program called hello? Yeah, so go ahead. Good, dot slash hello. And one tweak, so generally dot slash in dot this way would be forward slash and the other way would be backslash. Windows is backslash and usually other OS's are forward slash or just slash. But exactly, dot slash and then the name of the program, hello. And the dot slash is just a nuisance that specifies it's in this folder because I put it there. It's not some program I installed in some special default location as you would typically do on your own computer. So, that's how we might make it. That's how we might run it. Let's actually now do some more interesting things. So, to start writing programs in Scratch, you had when green flag clicked or maybe when I receive if you were using events. And that block indicated this is the guts of the sprite's program. It's a script. Well, in C as in a lot of programming languages, main is the equivalent of that. This is the name of the function, the sort of miniature program you need to write with a simple text editor that automatically gets executed, gets run, whenever you type dot slash hello or whatever your program is called. And so, main is really the guts of our program, but main itself, though a function, can call other functions. And recall that on Wednesday we used several times a function called printf. And the F stood for And so, just formatted. And that was because with printf, you don't just need to print out verbatim letters and numbers, you can format them in interesting ways. And indeed, problem set one will have you leverage printf to print things out like money and the like so that you don't have to figure out how to insert a decimal point into the output, you can just tell printf make this look like a decimal point, make it look like a piece of currency. So, printf takes, we call them arguments or parameters or more generally inputs. And those were things in between the parentheses. And it could take zero arguments or one argument or two. You just separated them by commas. But by far the most common thing we saw was just to have a very simple function that in main that used printf and looked a little something like this. So, I'm going to go ahead and preemptively go to file, save. I'm going to just put this on my desktop for now. I'm going to call this hello.c and hit enter. And again, the problems that will walk you through this, but even though it looks a little different from Windows and Mac OS, it's the same ideas poking around on your own hard drive. So, I'm going to click save. And now notice the top of the window has changed indicating that this is indeed hello.c. And silly though this is to dwell on file save, the advantage now of this in gedit is because the file ends in dot c, gedit's going to do something fancy for us, which is called syntax highlighting. It's going to colorize everything I type in a way that hopefully makes interesting things pop out rather than leave my code just black and white. So, it's not saving the colors in the file, it's just showing them to me as I go, but recall that I began this program with include standard io.h. Then I had int main void. And now notice what gedit's doing, too, which is both helpful and annoying depending on your view. It's started adding parentheses for me. So, as I typed main and then did open parenthesis, it preemptively, because it knows I'm writing c, figured, "If you opened a paren, you probably want to close it. I'll do that for you." So, realize that tools like this try to save you keystrokes, but it can get annoying if you're not expecting it. So, just know you can disable this by going to like edit preferences and poking around. So, after this, I had some curly braces. Those two were automatically inserted partly for me. And then I just said something like uh oh hi world exclamation point. That But that was That wasn't the fun We have a guest today who finds that funny from college. Uh my college. So, let's go ahead and now compile this code. And we have now the following end results. So, let me go into my desktop. So, notice what I'm doing down here. At the jharvard@appliance prompt, we have by default my so-called home directory. This is where all of my files get stored. And now notice that the thing in parentheses that just says tilde, this is just shorthand notation for exactly that. You are in your home directory. But I said a moment ago, I saved this file on my desktop. And so recall from Wednesday that the command to change directory is quite succinctly CD. So by typing CD space desktop and hitting enter, notice my prompt changes, reminding me parenthetically where I am where I am. And if I now type LS for list, I'll see everything that's on my desktop. And indeed, if I minimize this window temporarily, go back to my desktop, there's hello.c. It wasn't there before, but I created it with gedit. So let me maximize this window again. I'll zoom in so that it's more legible. And if I now want to compile my very first program for the second time, what do I type? Make hello. Quite simple as that. So make hello enter. The fact that no error messages appeared, just this one line of output, means make indeed automated the comp compilation of my program. Notice that if we weren't using make, we would probably have to type a fairly long, fairly annoying, and cryptic command like this: gcc -ggdb - standard = c99, and so forth. And we'll explain what all of those mean, but for now, make just simplifies this process. So to now run this program as we proposed before, I can do hello. Oh, but not quite. ./hello because it's in indeed in my current directory. So now just to make this more clear, this gets frankly even in lecture a little annoying using such a small window. We could do exactly the same thing with this terminal window. I click terminal, I do CD desktop, I type LS, and I see the same file plus another one. And what's nice about the black and white version of terminal is that it also colorizes files just based on whether they're executable or directories or files. So it's a little more user-friendly. So know that it exists. And similarly, can I now run hello? And if I sort of accidentally try to recompile it, make realizes you haven't changed your code. I'm not going to waste time regenerating the same zeros and ones. Bam, we are now done with hello. So, let's tease this apart and start adding new features. So, at the very top here, we have sharp include standard io.h and just in easy-to-understand terms, what was that doing for us on Wednesday? Yeah. A little Sorry, a little louder? Exactly. It's that directive include standard io.h and specifically angle braces is saying is telling the compiler, GCC specifically and in turn make, that for any functions I might call, see if they exist in a file somewhere on the hard drive called standard io.h because if I myself didn't write them, odds are someone else did, but I have to tell the compiler in what file they are, we'll call them declared. So, we've not used ourselves a dot h file. We'll start using those before long. But for now, a dot h file now just contains the names of functions that other people have written that you yourself can use. Now, fast forward down here, there's this mention of ints and I mentioned briefly on Wednesday the notion of error codes and the like. And so, for now, just trust that every program returns a number and the best number to return is zero and anything else is usually a problem. So, for now, we're just going to take on faith int main and then in parentheses void. And this is a new word, but take a guess what it means if you say void in between parentheses. Just nothing. It takes no arguments. It takes no input. And that's kind of sensible here because all this program does quite foolishly is just say, "Oh, hi world. Oh, hi world." There's no notion of input, so I can explicitly tell GCC, "Don't even expect any input into this program. Just do the same thing again and again." So, now the curly braces are just a convention. Printf is the name of a function that happens to exist in that file. How do you know? Well, you kind of learn these things in lecture, you read them in a documentation, you just know what files to include. And now between quotes, I have what we called an argument or a parameter, and you just have to worry about the minutia of things like the close parenthesis, the semicolon, and more interestingly this thing, and what did backslash n represent? So, oh, okay, good. We're moving We'll move more quickly now. All right, so new line, and that's the way of telling the computer explicitly put a line break after these words, because otherwise it's not going to appear. All right, so we can do things that are a little more interesting now, like not just say oh hi world, let's say oh hi David, or some arbitrary name that I type in. We need the ability now to get user input, so we can actually do this with the following syntax. A word, recall from Wednesday, is generally called a string in programming, a word or a sentence, any sequence of characters is a string. I'm going to call it S only because I only have one string, I know it's S, I don't need to give it something more descriptive, and then there turns out there's a function I can use called get_string. It too takes no arguments, but just to distinguish the two, when you call a function that takes no arguments, you don't have to say void. You only say void in something like main if you're saying preemptively don't pass me anything. So, we'll tease these apart before long, but for now get_string open paren close paren is string is going to do exactly that. It's going to get a string from the keyboard, and it's going to hand it to me in a variable called S. But unfortunately, I'm about to run into a problem. Let me go down here, and I'm going to change this to percent S, and then I'm going to put a comma S, because to recall from Wednesday briefly, this is how I dynamically inserted the value of a variable into a string that I don't necessarily know in advance. I know I want it to say oh hi, comma something, but to dynamically insert that something, you use a format code. A format code is just something that starts with percent. Percent S means string, put a string here, so comma S means take that value, whether it's d a v i d or whatever the user may type, and put it inside of the string itself. So, unfortunately, this isn't quite perfect. Let me go down to my terminal window. This is still called hello, and I'm going to go ahead and make hello, and wow, lots of issues here. So, when in doubt, and honestly, if a whole lot of errors scroll, it doesn't mean you made an infinite number of errors. It might mean you made one, confused the heck out of the compiler, so never start fixing errors from the bottom up, always scroll back up and try to fix the first one first. And there is the first one, error, unknown name unknown type name string. Well, turns out we're kind of lying to you here. It turns out in C there is no data type called string. There is int, there is float, there is char, and a few others we mentioned before, but string is kind of a CS50 simplification just for the first week or two. So, if you actually want to use this data type, you actually need to uh use another library. So, I'm just going to do some quick copy-paste, because it turns out in the appliance is a file called cs50.h, and in that so-called header file is not printf this time, but functions like get_string and get_int and some other user-friendly uh functions that just make it easier in these first weeks to do simple reasonable things. So, now I'm going to save this file, I'm going to go back to my terminal window, and I'm going to go ahead and rerun make hello, enter, and now all is better. I still see the script to command, but I don't see the word error, so now all is better. So, now let me go ahead and run {dot} {slash} hello. Nothing seems to be happening, but that's because it's waiting for some input. So, let me try typing my name, enter, and indeed it now says, "Oh, hi David." Well, we can make this marginally more user-friendly. Let me scroll to the top, and rather than just kind of blindly get a string from the user, let me first say, "You know what? Printf uh say your name, colon, space, semicolon." Just to kind of format it in an interesting way. Now, let me go back to the bottom here. Let me rerun hello and hit enter. And hmm, bug. Yeah, not really a bug. It was just a stupid mistake on my part, right? Cuz I didn't recompile the program. Oh, and as an aside, if you kind of get stuck in this awkward moment where your program's running and you didn't want it to run, almost always control C is your friend and that will quit out of whatever program you're running at the command line. Control C and it just looks like carrot C when it actually appears. So, let me rerun make hello. That looks good. Let me now rerun hello, enter, and now it just looks a little prettier. Still underwhelming the end result, but at least now it's becoming a little more user-friendly. Yeah. Uh like if you do not program in C within the CS50 application, so what do we include at the top instead of CS50.h? If you do not uh so, to be clear for all P sets, you should start using the CS50 In general, you could download something like the CS50 uh you could download the CS50 library on your own computer if you were programming outside of the appliance or more generally, there's other functions altogether called scanf or sscanf, which are generally used instead. But again, more on those in the future. For now, the CS50 library simplifies these details. Any other questions? Yeah. Oh, yeah, over here. Uh I wanted to ask what you meant by uh like that main Mhm. An excellent question an excellent point. So, I seem to have contradicted myself, whereby I said main does not take any input and yet here we are clearly taking input from the user. So, long story short for today, there's two types of input. When you run a program at the so-called terminal window, recall that we're typing things like make hello. Well, the program in this case is called make and I'm passing it input, the name of the program I want it to make. So, this is what we'll call in a future week a command line argument. It's input you provide when the program is run and you can't really do this in a GUI, a graphical user interface, cuz you either double click an icon to run something or you don't. At a command line, you can type words after the name of the program to provide it with input, but notice what I've been doing. I've just been saying hello. So, in this sense, does hello not take any command line input? It does take input later, but it takes it via a different channel, a different mechanism, and that mechanism in this case is called get string. So, we'll come back to command line arguments before long, but for now our programs will remain relatively simple so that we only get input inside of the program itself with functions like get string and the like. Any other questions? Yeah. Okay. Uh a good question. A word on spacing. So, what I have done now is what we'll call a matter of good style. The fact that I've hit the space bar after this comma before the S is not strictly necessary, but it makes ultimately the code more readable. Not necessarily if your program's only five lines long, but when your program's, as they will be before long, 100 lines long or even more, it just makes it easier for the human you to read it or even colleagues of yours with with whom you're working. Similarly here, is this a convention? I am indenting, just as we did with Rob on the stage when we did PB&J, he indented the pseudo code as we typed. Similarly here, am I hitting tab or really four spaces to actually indent my code to just make it more readable and more clear what the control flow, so to speak, is. So, you'll see in problem set one that we ask you to read a short style guide written by CS50 that essentially gives you some quick do's and don'ts as you figure out exactly what kind of style you yourself like um with which to write code. Yeah. You mentioned earlier that main function can return an integer or something. Sometimes programs it doesn't even say at the bottom return zero and so you just be commenting on A good A good point. So, you may see if you read ahead, if you look at other examples online that a lot of times people, myself included, will write at the bottom of main a statement like return zero, thereby being ever so explicit what the exit code is for this program. Well, I'm actually leaving that off now just as a matter of pedagogical simplicity. It's actually not strictly required. If you leave it out, zero is automatically returned for you. So, for now it's it's correct but just a distraction so I tend to leave it out until our programs get longer. All right, so what else is there? Let's come back in just a moment. What else is there besides just get_string? Well, in the CS50 library there's a whole bunch of useful functions. Capitalization does matter with C. So, the fact that we've capitalized get_char, get_double, get_float, get_int, get_long_long, and get_string is deliberate so that because they're all capitalized in this way, it just makes it more clear to you in these first weeks that this is a CS50 function and not something built into C. Because eventually we'll take these training wheels off when you can get user input in other ways including from the web but for now these are all CS50 functions. So, what's the difference between these? So, get_char gets a char. A char What is a char? A character. It's just a single letter or a single number that was typed at the prompt and how is that represented? Well, with eight bits or one byte and recall when we had our human volunteers the other day, they represented a byte worth of bits and they were representing ASCII characters. So, long story short, if you want to ask the user just for the letter B and then the letter O and then the letter W, you can ask him or her for three chars one after the other, and each of those chars will be put by the computer into a different byte, eight bits, in order to store that value. But, we'll see examples of that before long. Now, there's get float. What's a float? It's a floating-point number or real number. It's something that's got a decimal point in it, and it's 32 bits typically, though this is somewhat dependent on the machine that you're using. And sometimes just 32 bits is too small, so we instead want to double it, and so there's a double. So, the get double function, meanwhile, gets you a double, but it uses 64 bits, which just gives you more precision. And one of the goals of showing the video on Wednesday of the various uh missile mistakes was to demonstrate that actually taking into account or failing to take into account how many bits, how many zeros and ones you're using to store your values can absolutely have significant effects. And we saw this again 10 years ago in Y2K. Wasn't quite an issue of bits per se, it was a matter of digits then, but the idea was the same. If you only use two digits, you're going to run into a problem when the century rolls over, and you now need a third digit uh potentially to represent that, as was the case between '99 and 2000. So, what else is there in the way of types? So, there is char. There's double, there's float, there's int, and there's the goofily named long long. And we'll revisit these before long in the problem set will introduce you in more detail to some of these. But again, a char is one byte or eight bits. A double is 64 bits or eight bytes, if you just divide by eight. A float is half that, 32 bits. An int is also 32 bits. And a long long, just to round this out, is generally 64 bits. And so, part of the problem set will actually have you playing with money, the notion of $10 million and potentially more, for which, you know, you probably don't want to run out of bits if the downside is you don't get as much money as you're due. So, you'll see in this case uh of Pset1 that these data types become applicable. Um, so one other detail here. So, in the CS50 library, there's not only the notion of a string, which we'll tease apart before long. That just represents a sequence of characters, multiple chars. There's also what's called a bool. And we actually had bools or the notion thereof in Scratch. Turns out in C, there isn't a boolean data type, true or false. So, we've created one in the library so that you yourselves can represent the idea of true or false. And we'll see some examples thereof. And then there's simple stuff, to be honest. Computers, at the end of the day, are indeed calculators. And so, there are mathematical operators built into C. You can do plus and minus and divide and subtract and so forth. And just know, as an aside, that just like in grade school, where there was a well-defined definition of the order of operations, multiplication comes before plus and so forth, most of those same grade school rules still apply. And this chart is not meant to overwhelm, but just to be a reference down the road. If you're ever wondering, "Hmm, does this symbol get executed by the computer before this other one?" Know that charts like this exist and you can refer back to the lecture slide when the the problem arises. But, the simplest rules of thumb still apply. Multiplication binds more high with higher priority than plus. So, realize you might sometimes in code need some parentheses. Now, let's finish up printf. So, printf, we've used %s thus far, but there's other format codes. If you want to spit out a character, you don't say %s, you say %c if it's just a single character. If you want to print out a decimal digit, you say %d, you know, just a human-friendly number. If you want to print out a floating-point value, you print out %f, whether it's a float or a double. And this just means that printf will take care of putting the decimal point aesthetically wherever it belongs. And as we saw the other day, it will also decide for you, if you don't specify, how many decimal how many numbers to show after the decimal point. And then lastly, and just as an aside, there's also this crazy one, LLD, long long decimal. So, this is actually important because if over the next few weeks you use, for instance, a long long cuz you really want lots of bits to store big number, but you try to print that number using percent D, it's going to look completely wrong. It's going to be negative, it's going to be smaller, and that's because printf's going to be misinterpreting the bits and essentially only looking at 32. So, if you want to tell something like printf, "I'm using 64 bits," just realize and refer back to things like these other uh format codes. So, those are just some building blocks. Let's actually do something with them. So, just as in Scratch we had conditions, so do we have them in C. And we saw a glimpse of this on Wednesday, and so the next several examples are really meant to just translate what was more user-friendly and puzzle-piece-like to something more deliberate, something more cryptic, but it will be increasingly familiar. If you want to express the notion of a condition, "If this is true, do this," well, the syntax in C is to say if, space, open parenthesis, and then something, we'll fill in the something in a moment, open curly brace, and then do this. Now, in C, this slash slash actually represents something special. For those already familiar, it's a comment. It's a comment. So, a comment just means this is not actually code, it's just English or whatever language I personally speak, that's a notation to myself as to what's going on. You might not have noticed these in Scratch, but if you right clicked on the stage on the scripts area, you could actually paste in a little yellow sticky, like a post-it note, and that was the equivalent in Scratch of just notes, comments to yourself. C also has this. C also has another syntax that you might see in books in my own examples, whereby you can do slash star star slash. The advantage here is that this syntax can actually span lines, and you you say something like, "And this," and that's all the comments. Whereas the slash slash only applies to one line. So, just realize they're two different styles and doesn't so much matter which one you use so long as you're ultimately consistent. Now, this only lets you do something or not at all. Can we do more? What about pound or sharp? Pound or sharp do not work in C. So, the only two options in C are slash slash and slash star. So, what if we want two options, two forks in the road? We can go if this is true, do this, else do that. And just like in Scratch, if we start embedding these things, we can have three forks in the road. We can say if this, do this, else if this condition, do that, else do this other thing. So, again, same ideas in Scratch, we just need to express them now with a keyboard, but the ideas are the same. Yeah. Is there a way to do automatic formatting in C? Is there a way to do automatic formatting? Yeah, start like for example typing like slash star and then like indent and then like basically align the code. Good question. So, those of you with prior backgrounds might have used tools that actually kind of fix any messiness, any sloppy code that you write for you. Gedit does not do that. A program called Eclipse that we'll eventually use does that. And for those more comfortable, you're welcome to use other tools if they'd like. But for now, the goal is to actually get you yourself into the habit of writing good clean code until the tools will actually start making this easier for us. So, in short, in Gedit, no. You need to be hitting the tab key or space bar. So, Boolean expressions, just as in Scratch, you can say if this is true and this is true, do something. Or you can say if this is true or this is true, do something. And as I recall, those blocks are generally green in shape and they've got little diamonds. If you used any of these in your program, to express that same idea in C, you can say if this condition is true or some other condition is true, then do this with whatever is inside the curly braces. Now, the vertical bar vertical bar is just again C syntax for saying or. A single vertical bar in a few weeks we'll see means something else. So, this is just the equivalent of or. The equivalent of and meanwhile is this, and and. And so, now with this syntax, we can express doing something if only if two things are true. So, let's actually try to use a program that leverages these. Let me go ahead and close hello.c. I'm going to go into one of the prefabbed examples for today, which is available as a PDF and also as downloadable code on the courses website under lectures. And I'm going to open a file called conditions1.c. And it looks a little something like this. Now, at the top of the file, there's actually a whole lot of text, but this is just a comment. And the fact that I've hit the asterisk this many time, this is just a human convention to kind of make super clear. This is not a comment not only a comment, this is a pretty huge comment. You better read this, but this is just a matter of style. You don't necessarily need to adopt the same convention. What's important though is that the first character at top left is slash star, and the very last one involved is slash is star slash. All the other stars are just an aesthetic uh curiosity. But, uh here I just have some comments. So, let's scroll down to the more interesting part. Notice that I'm using apparently the CS50 whoops library. I'm using standard IO, so I can preemptively guess that I'm probably calling something like get string or get int. I'm using something from the library, and I'm probably also using what other function? You can kind of infer the answers right there. Right, printf, right? So, I you included standard io.h because I'm calling printf. But, otherwise, this is familiar except for a few new features. So, let me scroll down here, and here's now a more compelling role of comments. Thus far, just saying do this is kind of useless. It's meant just to be a placeholder. But now, another matter of good style, quote unquote, and we'll reinforce this in section over the next several weeks, is to not just write your code and leave it to the reader, whether it's CF, a colleague, or you 1 month hence, to figure out what the heck you meant by your code, the best habit to get into from the start is to actually make a note to yourself in one line or two or three or more what's going on so that you yourself honestly the next morning can skim your code and realize, "Oh, that's what I was doing and why." Moreover, someone else in the real world can also understand what you're doing. So, what am I doing here? I'm asking the user for an integer. How do I do that? Well, as before, I just have this aesthetic of I'd like an integer, please, colon, space, but I could have said anything there. The interesting part is this. So, what's going on here? Well, before I used get_string, and get_string returns, so to speak, a value. It figures out how to get all the user's keystrokes, it then bundles them up together, and then hands me a value. But, if I want to keep that around, I need to put it in a variable. Well, in Scratch, to create a variable, you click that button, like create variable, and you give it a name. Same thing in C, but you have to be more explicit. You have to give the variable a type, and you have to say, "Is it a string? Is it an int? It is a Is it a float?" And so, the key difference here in C is that you literally have to say that. I want a variable called n, its data type, per this keyword to left, is an int, and what do I want to put into that variable? I want to assign it, so the equal sign means assignment, whatever it is that get_int has gotten from the user. Now, just as an aside, because you'll see other syntax still, these two things, getting in the int and saving the int, do not all need to be done in the same line. It is not uncommon to see this instead. I'm going to put a semicolon there, and then on the next line or somewhere else in my program, I can do this. So, the takeaway here is that you always have to declare, so to speak, a variable, and to declare a variable just means tell me its type, tell me its name, semicolon, that's it. But, to assign a variable a value, you have to eventually use the assignment operator, the equal sign, but notice that you don't re-declare what? You don't say int again. You already told the compiler what it is. It would be redundant to say what it is again, and so you don't need to say it again. Now, why use version two versus version one? You know, frankly, again, as a matter of style, and this is something you just kind of pick up on your own. Just kind of looks a little ugly, right? So, I'm a little anal, and I just kind of like the elegance of this one line of code. And so, when we say code is elegant or clean, it's these little details where your code starts to get more compact and just more readable. And this too is a style that we won't enforce on you, but rather encourage exactly what conventions you adopt. Now, what about here? This is the meat of the program. Analyze the user's input somewhat in your inaccurately. Now, here's the syntax for this. If n, which is again is the int that the user just typed, is greater than zero, print out you picked a positive number. Backslash n. Else, print out you print picked a negative number. Now, I disclaimed in parentheses somewhat inaccurately. Why? What's the bug in this program? Okay, good. So, zero is obviously not considered. So, if I type zero, what's it going to say? You picked a negative number, and that's not true. Zero is neither negative nor positive, so we can fix this. So, I can actually do something like else if, let's say n is less than zero, say this, and then otherwise, let me go ahead and just copy and paste, and then get rid of the redundant condition there. You picked, let's say you picked zero. And now I have three branches, the last of which is the catch all, but the only case left to catch is zero, so this would now seem to work. But also, I seem to be violating the previous slide. What piece of syntax have I omitted here? Yeah, those curly braces. Remember, in every prior example in black and white, I had if and then a condition in parens, open curly brace, then some comment like do this, close curly brace. Well, it turns out this is okay if and only if all that you're doing inside of the fork in the road is one thing. If you only have one line of code, frankly, it just feels kind of lame to add three lines in total just to say one thing. So, this is correct and frankly, when your code gets more fancy, this is actually more readable cuz it makes it even more clear what's inside this fork in the road, but it as it is, it like triples the size of this block of code and it's just not necessary. So, this too is a matter of style, but notice this would be wrong. Printf Oh, by the way, hi or something like that. This is now wrong and the program will not even compile in this case because even though I've indented it, you know, that's great. You can indent things all you want if you've used more than one line of code and no curly braces, the compiler is actually going to complain. So, let's go back to the correct version. Let me get rid of this and I'll leave in the third fork in the road. Let me go down now to this file. Now, this happens to be a file I created in advance and I put it in a directory called lectures in a subdirectory called one for week one and then in a subdirectory called source src and now if I type ls, here's a whole bunch of code that we'll be playing with this week and next. Let me go ahead now and say, make What was the name of this program? Conditions one, enter. That looks good. Let me go ahead and run conditions one. I'd like an integer, please. Let's say 123, enter. You picked a positive number. How about -3? You picked a negative number and how about zero? So, it seems to have caught that. So, we now have conditions. Yeah. Uh sorry, a little louder? Ah, a good question. So, what if I try to feed the program a float, which is clearly not an int, a float being something with a decimal point and again, recall that I'm using get int. Well, let's see. And again, this too should be a recurring theme. Like when in doubt, and obviously, it's fine now if you don't have your own computer out, but when in doubt, just try it. The worst thing that can happen is it will break something and that will in itself reveal the particular answer. So, let's I'd like an integer, please. How about 1.99? Enter. So, it says retry. So, one of the things the CS50 library does too for you is that if you you're calling get_int, it's only going to let you get an int. If the user is difficult and types in something stupid like monkey, it's also just going to reject it and automatically say retry. So, it does these kind of checks for you. If I wanted to actually get a float, I'd have to actually use get_float. Now, just a quick tip, how do I get rid of this program? I'm kind of done executing it. Control C will abort. Uh yeah. Uh if you were to take input in several lines of code, how would get_int like react to that? Uh good question. If you were to use multiple lines of input as in the case of Let me go back to hello, where I say something like hello, my name is David. Enter. So, get_string can only get one line of string. So, to get multiple lines of input, we'll actually need more sophisticated techniques. We cannot use get_string, but that's fine cuz at that point these training wheels will be off. All right. So, we now have conditions. We now have Boolean expressions. And again, a Boolean expression, to be clear, is just something in parentheses that evaluates or is true or false, one or zero. But, there's a few other pieces of There's a few other features here. Among them called switches. So, it turns out if you have a bunch of conditions, you don't have to say if, else if, else if, else if, else if, else. Just know that there's this other construct, this other piece of syntax altogether called switch, where all you need to do is actually enumerate cases one at a time. And we won't dive into detail on this one, but the takeaway here is that just as in Scratch, there's rarely if ever going to be one or right or even one correct way of doing something. Rather, there can be any number of ways, and so also as a matter of style, when you start to have if else if else if else if else if else if, that's just a lot of redundant words. So, switch is just another way, as we'll eventually see, that you can simplify syntax by just listing them case by case by case. But, the most powerful thing that we'll need ultimately are loops, because otherwise our programs can only do one thing and once, and that's it. So, with loops, recall from Wednesday, we translated some sample Scratch blocks into the corresponding looping constructs. Now, this is one of the scariest ones to look at first, but it's actually quite easy to use. In a for loop, you declare a variable, you generally call it I by habit, then you say how many times do you want to increment I plus plus plus plus plus plus, at which point you want to stop, and inside of this loop you'll do something. So, we can actually do something a little silly. Let me go over to Gedit here. I'm going to go ahead and just create a new file. I'm going to call this on my desktop, let's say loop.c. And again, I'm just going to bang out some familiar lines, so include standard io.h. I'm not even going to use the CS50 library. Uh int main void. Now, I'm going to do printf how about this. So, let's do how about int n gets gets int. Okay, I just lied, so I need the CS50 library. So, no problem. So, CS50.h bug solved. So, I'm getting an int from the user. And now, what do I want to actually do? Well, I want to loop like this. For int i gets zero. So, give me an int, call it i, initialize it to zero, go ahead and keep doing this so long as i is less than n, and then keep incrementing i on every iteration of this loop. So, Scratch kind of automated some of this for us. Um if you use the block like um change variable by one, it's a little uh simpler. But, now let me do this. Let me indent here and just as with if, if you're just executing one thing, I don't need curly braces around the for loop. Let me go ahead and print out the decimal number followed by a new line that's currently inside I. So, very simple program, ask the user for an int, print it out, then increment it, increment it, increment it, increment it. So, let's see what happens. This is called loop.c. Let me go ahead and type make uh it's on my desktop. Let me do make make loop. Okay, that's good. No errors. And let me go ahead now and run loop. Okay, I need to type in a number, 99. Okay, that's pretty fast program, right? I can now scroll way back here. Now, of course, you can do some perhaps uh silly things. Uh what might be a bug now in this program? Yeah, what if what if I'm kind of a difficult user and I say, "How about negative one? See what happens." Hm, what happened? It's already less than n, it's already less than negative one. So, what if I kind of goof and do something like this, right? This is a reasonable bug. Let me recompile and do make loop. And now let me go ahead and run loop. And now if I type something like one, okay, that works. Negative one uh-oh. So, now we sort of get to empirically test what the capacity is of an int. And just to think back to Wednesday, what is the largest int that we can actually represent? Yeah, so it's like 2 billion give or take. It's 4 billion total if you have 32 bits, but if you want to use some negative, some positive, you actually have to sacrifice half. So, it's roughly negative 2 billion to positive 2 billion. Frankly, this is going to take all day if we keep counting up this way. So, let's actually do something a little fancier. In my program, rather than uh increment one, let me go ahead and say multiply by two. So, this is just fancy syntax that we'll come back to over time, but this is just shorthand notation for saying Actually, let me do it more simply. I, on each iteration, is going to get the value of I * 2. So, keep doubling it, doubling it, doubling it. That should get us out of here quicker. So, let's try this. Make loop. Let me go ahead now and run loop -1. Hmm, what happened? Let's scroll back up here. What's going on? Yes, I'm kind of an idiot, right? I shouldn't start counting at zero and then multiply by two an infinite number of times. That was not intended. So, let's go ahead and do make loop, rerun loop with -1. Interesting, it stopped. It didn't keep going. It should have kept going, right? It should have kept going again and again because so long as I is greater than N, just go on up to infinity. So, what might have happened? Yeah? Uh it went past the highest number it could display. Yeah, it went past the highest number it can display and more specifically It became a negative number. It became negative. So, here's the curious thing. Just as with our example with humans, we had eight bits. Just because I want to count beyond that eighth bit, it doesn't mean you get a free bit all of a sudden and now you have nine bits and 10 bits, right? You are limited in capacity. So, if we made all of these humans raise their hand and then we said, "Okay, add one more number to your total value." You know, what would they do reasonably? Maybe one of them puts their hand down. Maybe all of them puts their hands down. In other words, if you keep changing zeros to ones again and again and you run out of permutations, you're going to have to start over. But, unfortunately, once you start over and {quote} overflow, well, what comes after roughly 2 billion when you overflow? You know, what's the What How do you start over? It becomes negative 2 billion. So, even though we didn't see it on the screen here, what happened is the zeros and ones changed into some pattern whereby it actually was representing a negative number cuz again, we only have finitely many zeros and ones in 32 bits or even 64 bits. And so, now we had the illusion of some negative number, and this badness happened. It just stopped. But the loop a for loop is not the only option. We can actually use something called a while loop, and this shouldn't be too scary, too, because even in Scratch, you had repeat blocks, you had forever blocks. Same idea, and we'll see different syntax. And then there's this also this one, too, a do while loop, whereby it does something one time and then again and again and again. And so you'll see in problems set one in particular what something like this can do. Now let me just go back to the terminal window here and demonstrate just two things to pique curiosity as to what lies ahead. If I go into the prefabbed code here, you'll see a couple of things. Uh one of which is called Thad Gavin, named after the guy. So this is when you really want to be anal and pretty print your code. You can actually make it look pretty um by formatting in this way. This is not what we mean when we say good style. This is uh a submission for a special contest where you try to outdo all of the other geeks. But what you can do here, which is pretty cool, is if we run Thad's program, you can do some crazy things just using these loops. So this is a C program. It was only a few dozen lines of code. You saw the whole thing, but with loops and with C we can do things like this, and this is just the beginning. So with that said, let's call it a day. PS set one will be posted tonight, and we'll see you on Monday.

Original Description

C. Source code. Compilers. Object code. GCC. Functions. Comments. Standard output. Arithmetic operators. Precedence. Local variables. Types. Casting. Standard input. Libraries. Boolean expressions, continued. Conditions, continued. Loops, continued.
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from CS50 · CS50 · 47 of 60

1 Hello, World: Hadi Partovi
Hello, World: Hadi Partovi
CS50
2 Content Distribution and Archival in a Digital Age
Content Distribution and Archival in a Digital Age
CS50
3 CS50 2014 - Week 1
CS50 2014 - Week 1
CS50
4 CS50 2014 - Week 3
CS50 2014 - Week 3
CS50
5 CS50 2014 - Week 0, continued
CS50 2014 - Week 0, continued
CS50
6 CS50 2014 - Week 4
CS50 2014 - Week 4
CS50
7 Week 3, continued
Week 3, continued
CS50
8 Quiz 0 Review
Quiz 0 Review
CS50
9 CS50 2014 - Week 3, continued
CS50 2014 - Week 3, continued
CS50
10 CS50 2014 - Week 7
CS50 2014 - Week 7
CS50
11 CS50 2014 - Week 7, continued
CS50 2014 - Week 7, continued
CS50
12 Breaking Through The (Google) Glass Ceiling by Christopher Bartholomew
Breaking Through The (Google) Glass Ceiling by Christopher Bartholomew
CS50
13 Introduction to Amazon Web Services by Leo Zhadanovsky
Introduction to Amazon Web Services by Leo Zhadanovsky
CS50
14 CS50 2014 - Week 9
CS50 2014 - Week 9
CS50
15 How to Build Innovative Technologies by Abby Fichtner
How to Build Innovative Technologies by Abby Fichtner
CS50
16 Light Your World (with Hue Bulbs) by Dan Bradley
Light Your World (with Hue Bulbs) by Dan Bradley
CS50
17 Building Dynamic Web Apps with Laravel by Eric Ouyang
Building Dynamic Web Apps with Laravel by Eric Ouyang
CS50
18 CS50 2014 - CS50 Lecture by Steve Ballmer
CS50 2014 - CS50 Lecture by Steve Ballmer
CS50
19 CS50 2014 - Week 10
CS50 2014 - Week 10
CS50
20 This is CS50 with Steve Ballmer?
This is CS50 with Steve Ballmer?
CS50
21 Meteor: a better way to build apps by Roger Zurawicki
Meteor: a better way to build apps by Roger Zurawicki
CS50
22 Data Analysis in R by Dustin Tran
Data Analysis in R by Dustin Tran
CS50
23 Data Visualization and D3 by David Chouinard
Data Visualization and D3 by David Chouinard
CS50
24 CS50 2014 - Week 6
CS50 2014 - Week 6
CS50
25 Build Tomorrow's Library by Jeffrey Licht
Build Tomorrow's Library by Jeffrey Licht
CS50
26 CS50 2014 - Week 9, continued
CS50 2014 - Week 9, continued
CS50
27 Essential Scale-Out Computing by James Cuff
Essential Scale-Out Computing by James Cuff
CS50
28 iOS App Development with Swift by Dan Armendariz
iOS App Development with Swift by Dan Armendariz
CS50
29 Sam Clark Leads Yale Students on Tour to CS50 at Harvard
Sam Clark Leads Yale Students on Tour to CS50 at Harvard
CS50
30 3D Modeling and Manufacture by Ansel Duff
3D Modeling and Manufacture by Ansel Duff
CS50
31 CS50 2014 - Week 5, continued
CS50 2014 - Week 5, continued
CS50
32 hello, world
hello, world
CS50
33 CS50 2014 - Deep Thoughts - Hash Table
CS50 2014 - Deep Thoughts - Hash Table
CS50
34 CS50 2014 - Deep Thoughts - Binary Tree
CS50 2014 - Deep Thoughts - Binary Tree
CS50
35 CS50 2014 - Deep Thoughts - Scratch
CS50 2014 - Deep Thoughts - Scratch
CS50
36 CS50 2014 - Deep Thoughts - MySQL
CS50 2014 - Deep Thoughts - MySQL
CS50
37 LaunchCode Visits CS50
LaunchCode Visits CS50
CS50
38 CS50 Live, Episode 100
CS50 Live, Episode 100
CS50
39 CS50 Field Trip to Google
CS50 Field Trip to Google
CS50
40 This is CS50 AP
This is CS50 AP
CS50
41 Week 4: Monday - CS50 2011 - Harvard University
Week 4: Monday - CS50 2011 - Harvard University
CS50
42 Week 2: Wednesday - CS50 2011 - Harvard University
Week 2: Wednesday - CS50 2011 - Harvard University
CS50
43 Week 1: Wednesday - CS50 2011 - Harvard University
Week 1: Wednesday - CS50 2011 - Harvard University
CS50
44 Week 11: Monday - CS50 2011 - Harvard University
Week 11: Monday - CS50 2011 - Harvard University
CS50
45 Week 3: Wednesday - CS50 2011 - Harvard University
Week 3: Wednesday - CS50 2011 - Harvard University
CS50
46 Week 12: Monday - CS50 2011 - Harvard University
Week 12: Monday - CS50 2011 - Harvard University
CS50
Week 1: Friday - CS50 2011 - Harvard University
Week 1: Friday - CS50 2011 - Harvard University
CS50
48 Week 3: Monday - CS50 2011 - Harvard University
Week 3: Monday - CS50 2011 - Harvard University
CS50
49 Week 10: Wednesday - CS50 2011 - Harvard University
Week 10: Wednesday - CS50 2011 - Harvard University
CS50
50 Week 2: Monday - CS50 2011 - Harvard University
Week 2: Monday - CS50 2011 - Harvard University
CS50
51 Week 9: Monday - CS50 2011 - Harvard University
Week 9: Monday - CS50 2011 - Harvard University
CS50
52 Week 7: Monday - CS50 2011 - Harvard University
Week 7: Monday - CS50 2011 - Harvard University
CS50
53 Week 5: Monday - CS50 2011 - Harvard University
Week 5: Monday - CS50 2011 - Harvard University
CS50
54 Week 5: Wednesday - CS50 2011 - Harvard University
Week 5: Wednesday - CS50 2011 - Harvard University
CS50
55 Week 7: Wednesday - CS50 2011 - Harvard University
Week 7: Wednesday - CS50 2011 - Harvard University
CS50
56 Week 8: Monday - CS50 2011 - Harvard University
Week 8: Monday - CS50 2011 - Harvard University
CS50
57 Week 9: Wednesday - CS50 2011 - Harvard University
Week 9: Wednesday - CS50 2011 - Harvard University
CS50
58 Week 8: Wednesday - CS50 2011 - Harvard University
Week 8: Wednesday - CS50 2011 - Harvard University
CS50
59 Week 10: Monday - CS50 2011 - Harvard University
Week 10: Monday - CS50 2011 - Harvard University
CS50
60 Week 2: Wednesday - CS50 2010 - Harvard University
Week 2: Wednesday - CS50 2010 - Harvard University
CS50

This video teaches the basics of C programming, covering topics such as source code, compilers, and object code, and provides a foundation for further learning in computer science and software development. It is part of the CS50 2011 course from Harvard University.

Key Takeaways
  1. Write a C program using a text editor
  2. Compile the program using GCC
  3. Run the program and observe the output
  4. Use functions to organize code and reduce repetition
  5. Implement conditional statements and loops to control program flow
  6. Use libraries to access predefined functions and functionality
  7. Debug and troubleshoot programs using standard input and output
💡 Understanding the basics of C programming is essential for building a strong foundation in computer science and software development.

Related Reads

📰
Setting Up a Playwright JavaScript BDD Automation Framework with Cucumber
Learn to set up a scalable Playwright JavaScript BDD automation framework with Cucumber for efficient testing
Dev.to · She11 QA
📰
Mastering Background Jobs: A Developer's Guide to BullMQ
Learn to manage background jobs with BullMQ, a Node.js library for handling queueing and job processing, to improve your web development skills
Dev.to · Time Pass
📰
Java Strings Explained: Immutability, String Pool, StringBuilder, StringBuffer, and What Really…
Learn how Java strings work, including immutability, string pool, and the differences between StringBuilder and StringBuffer
Medium · Programming
📰
localStorage, sessionStorage and cookies: The Auth Token Decision Most Tutorials Get Wrong
Learn how to properly store auth tokens using localStorage, sessionStorage, and cookies, and avoid common mistakes made in most tutorials
Medium · JavaScript
Up next
Past, Present, and Future: Logical Decoding and Replication in PostgreSQL | POSETTE 2026
Microsoft Developer
Watch →