BrandGhost

Learning How To Program - Zero Experience Required!

I'm Nick Cosentino, and I'm an engineering manager at Microsoft. I believe that programming is one of the most important skills you can have access to, and I'm here to help you get started. Does this sound like you? - "I can't program, I'm no good at math" - "I'm not smart enough to write code" - "I don't know where to start" - "I don't even know what language to use" - "I don't see any value in it" - "It's too hard" If so, I'm here to help. If not, maybe I just missed your own personal excuse...
View Transcript
I am an engineering manager and I've been trying to do um sessions like this in different variations. Right? So I can see in the chat uh Francisco's joined. So um Francisco is actually someone I work with and I think today's topic of conversation is probably going to be a lot more introductory than maybe what Francisco and I would talk about at work. Um but thanks anyway for tuning in, Francisco. That's awesome to see you. Um, what I'd like to go over today though is basically spending time with folks to help you be introduced to programming and not necessarily have you leaving this, you know, hour-long session where you feel like, hey, I can go build, you know, the next billion dollar startup or something like that. Um, it's not it's not something that you just learn instantly. It does take practice, but um I think one of the big challenges is that people um seem to be nervous about getting started, right? It seems if you're not in a technical space, it kind of seems a little bit scary perhaps. So, you know, where do you get started? There's so much information on the internet. Uh I don't have time. Um you know, there's so many excuses you'll hear, right? And I think that's okay, but I think you have to get started. Um, so one thing I'll hopefully debunk today is that you don't need to be strong in math to to be um, you know, interested or try out programming. Um, for what it's worth, I would say very early on in my programming journey, I would consider myself strong in math. Like in high school, um, awesome. Yeah. So in in high school I think I was good at math but then like I would not say that I have any interest in math in my my 30s or even in my 20s. Um so uh I program regularly and if I can program regularly and feel like I'm not great at math you can do it too. Um so where are we going to start? So I guess I was mentioning why I wanted to do this right. It's to get people exposed to how you can just try to get into programming without hopefully having too many barriers where you feel like you just can't get started. Um, that's going to be the main thing. And again, it's not you're going to leave this knowing everything about programming. And for what it's worth, I would say after this, if you're checking out other resources, if you're seeing videos and links on social media where people are basically promising you like, oh, watch this quick video and you'll be an expert after. It's just not reality. So, I want you to have real expectations. It's just like learning any other skill. And I would say honestly, think about like learning a new language. Um, I only speak English and I had a little bit of French exposure uh, you know, early in my life, but I could not speak French now, right? And if you tried to learn a new language, you're going to have to spend time practicing it. It just doesn't happen instantly. So, please have uh, realistic expectations. Don't beat yourself up if you're finding it a little bit challenging. Just stick with it and practice. Okay. So the first thing I wanted to go into um and it's not just writing code. Uh the first thing I want to talk about is like what is a program, right? So I think a lot of the time especially because people think about if you're not familiar with programming like the go-to is that you know it's programs are for computers. It's going to be a lot of ones and zeros. Um I don't know how to speak ones and zeros. How could I ever be a programmer? Um, that would never work for me. And I wanted to start by saying that like when we're thinking about programs, the what I would say is the average programmer is also not thinking about programs in ones and zeros. Um, so I want to kind of clarify that in the first place, right? When we're talking about programs, we're not as programmers, we don't sit at our desks and go, hm, I wonder how I would think about this logic that I want to write and speak it in ones and zeros to a machine so that it knows how to do it. Um, and we can be very thankful that there have been many years of developments in software engineering um to do that work for us. So, what do I mean by that? Well, at the lowest level when we're talking about computers, yes, they are dealing with ones and zeros, right? It's a lot of switches on and off. Um, you've probably heard binary, right? Um, but we don't have to think about that as programmers today, which is great. There are some really low-level things you could do in programming where that becomes a lot more um kind of in your face because some of the things you're doing maybe you're talking um you're writing software that has to do um uh with different pieces of hardware, right? Like you might have a circuit board and some other stuff that you're trying to interface with. That might be something where you're genuinely looking at moving around ones and zeros, but it's pretty specific. And even then, there's going to be software that's been built on top of that where you don't have to think about how that works. So, how do we go from like the ones and zeros at the very low level that I'm telling you, you don't have to worry about? How do we go from, you know, computers talk that way to we're speaking like I'm speaking English to you. Um, how do we go from thoughts and logic that we can understand to what a computer is going to understand and execute for you? Well, there's a lot of different ways that this happens, but I mean the generalized way to look at it is that there's different tools that we can use as programmers. Um, and one word you'll hear come up is compiling. So, it can take code that you write, right? as programmers, we're going to be writing code and it will convert that into something that a processor so a computer can actually understand and execute for you. So the point is that there's tools and there's generally many layers of tools that will do different conversions that you don't have to think about fortunately um into something that the computer can understand. Now, as I'm telling you this, there's absolutely situations where um you know, depending on your field of programming, you might be spending actually a lot more time having to think about those things. But I would say the average programmer um like just generally doesn't have to worry too much about that. If all of the tools and uh pieces are built well for you, you can think about how you want to take your thoughts and your logic and turn that into code that then a machine will interpret later for you. Okay? So, I'm not going to if other people are watching this and they're more advanced, they might find like, you know, as I'm saying this, like, well, Nick, you know, there's compiled code, there's interpreted code, there's all these different languages and different processor architectures. Like, we're not getting into that. I don't think it's, you know, necessary for people when they're getting started. I think that's probably something that would scare people away. So, what I want to talk about is just, you know, the easier parts that are more simple to understand. So when we think about writing programs, a lot of it is essentially just taking something like an algorithm or a series of steps that we would like to execute and having a computer do that for us. And I think sometimes when people think about programming, if they're not used to doing it, they've never done it before, um you might have different understandings of what this means. So maybe some people are like, well, I can't be a programmer because I don't know how to make a phone app or I don't know how to build a website or I don't know how to build a service or whatever, right? Like these are all different forms of things you can create with programming, but I would say that not one of them necessarily defines a program on its own. Right? So what we can look at doing is taking a simple case which is like a series of steps. Let's say that maybe um I think the easiest way to think about this is think about something you might do uh throughout the day or at your job right something that you're doing on a computer that maybe you find you do a task or a series of steps that's repeated maybe multiple times within a day. Maybe it's something you do every Monday or something you do every day when you come into work. You do a series of steps. And really like what computers are awesome at that we don't enjoy doing as humans is computers like they can do steps for you that you set out for them. They're not going to complain about it, right? As humans, we don't enjoy doing that and we will complain about it. So we can leverage software, right? we can take our thoughts and our steps that we want to do and have executed for us, tell a machine to do it, and then we don't have to worry about it. So, the most simple case is probably if you've kind of been poking around in programming, you might have heard like scripting. That might be something that's come up. And I'm not going to get into like the the nuances of like what's a script versus a program, but I would say generally if what I [snorts] just explained about maybe automating some tasks and stuff, if that seems interesting to you, you may want to look at scripting. That might be a good kind of intro to like, hey, after I watch Nick's video and I want to go learn more stuff, maybe go check out some scripting. So when we talk about scripting and some of these examples that I'm going through, it's a scripting a lot of the time is more centered around um I have like a series of steps that I would like to automate, right? And then if you were to build more things on top of these scripts, that's where you might start having applications come together or services that you could build out. Again, the details of what that actually means, not super important, but what I'm trying to explain is that you don't have to be trying to jump into, I don't know, building the next huge thing that you're going to sell. Um, and I would actually advise that if you're, you know, interested in starting programming, what you don't want to do is necessarily jump right into like being bogged down by what's a the best business idea. Like if you want to learn to program, start with the basics, right? So when we talk about building programs or scripts, what we want to be doing is taking our thoughts and putting them into a programming language, right? So that will be the top level thing that we do. And as I mentioned earlier, there are tools that can take our code in these various programming languages and then convert that into something that the machine knows how to execute. So that's nice. But you've probably heard that there's a ton of different programming languages, right? Where do we get started? How do we pick a programming language? Like is there a right and a wrong language? Um, and maybe for some people, maybe you have been interested in learning to program, but maybe you got caught up on this step where you're like, okay, the idea of what a program is makes sense, but there's so many languages, like I don't want to go waste time learning the wrong one and then wasted all this effort. Um, what I would say is like there are certainly languages that may be better suited for certain tasks with without a doubt. Um, but I would say if you're learning to program, you can probably pick almost any language and if you're taking the concepts about programming, you can end up applying those to different languages later. So to give you an example, um, the language that I have chosen to kind of stick with as my my bread and butter, let's call it, um, I use a language called C. That's my favorite language to use. Um, I can't sit here and tell you, oh, C is the best language, because it's not. What's it the best at? Right? Like, you have to look at languages like things that they do a good job at. So, for this presentation, we don't have to get hung up on what language is the best. Um, what you may want to ask is like what language is more user friendly to get started with, right? Maybe there's some things that you just want to learn about. Um, often people will say that the Python language is the most userfriendly for people getting started. That's okay. Um, if you want you can learn Python. There are tons of resources about Python. Um, today when we go through this, I'm actually going to get to C code and we're going to walk through some examples there. And when we do that, what's um going to be important to keep in mind is that we're going to be talking about one language at a time. And what you'll want to do is take the the sort of the concepts that I'm showing you, right? It's a very introlevel thing. We're going to talk about the concepts, but what you'll see me type is in a particular language. So um to give you a parallel if you think about literally learning spoken languages um there are language constructs we talk about like nouns, verbs, um you might have punctuation and stuff like that, right? All these kinds of things may look different in different languages and that includes programming languages. Uh we call that syntax, right? Um in programming. So the syntax might look different, but the concepts that you're trying to accomplish are actually going to be very similar across many languages. How it looks when you code it might be different. How it performs might be different, but the concepts are generally the same. Um, and I'm I'm talking about generalizations here. So again, if people are more advanced and they're listening to this, they might, you know, want to pick that apart. But I think for for today I think we can take that as reality right there going to be things that are very common across programming languages but they may look different in how you write it. So what I want to be able to do is actually jump into some code and start talking about some intro things and some of these general concepts that apply to different programming languages. So, I'm going to end up switching my presentation mode here. Hopefully, that doesn't have too many hiccups. Um, and it will share my screen and have uh my face probably in the top right corner. Um, so we'll do that in just a sec. And before I do that, the thing that we're going to be looking at um that basically all programmers will be using is well like where do you write the code? [laughter] Um now for myself um and people that use a programming language called C there is a tool that we like to use for most of us and it's called Visual Studio. Um and this is something that is called an integrated developer environment or an IDE. Now the most basic like IDE you could think of is probably something like notepad on your computer, right? You just need a spot where you can type code. But the other pieces that we usually see in something like an IDE are things that let us run our code or save the output of our code in a format that can be run later, right? and some of the tools depending on how advanced the IDE is, the integrated developer environment, they might let us actually execute the code and step through each line of code one at a time. Um, and that's called debugging. So, we're able to step through line by line and go, "Oh, that's what's actually happening when I run this software." So, what I'm going to do is switch over to this other view. Hopefully, nothing blows up. So, let's give that a shot. Um, seems okay on my side. And what we're looking at on my screen right now is a website that's called.net fiddle. And the reason I wanted to use this today is so that if you want to try this literally as you're watching this live, and this is recorded as well. So, if you're watching a recorded version of this, um, you can follow along and try some of the things I'm doing. And I also wanted to take this opportunity to mention if you're in if you're watching it live and you're on the chat, please feel free to ask questions as I'm going. Again, just keep in mind there's a bit of a delay, so I apologize for that. And if you're watching the recorded version and something's not making sense, like, please ask in the comments. I will go through the comments later and I'll absolutely respond to you. Um because usually when I do sessions like this, this is something where uh you have the ability to unmute and you know ask stuff like if I'm doing this at work, then that's how we would do it, right? Like I encourage people interrupt me, ask your questions. Let's get them resolved as we go. Okay, so I mentioned this is net fiddle. Um this is a really basic um webbased IDE again integrated developer environment. We have our first ever program here. If you just visit this website netfiddle.net this will already come up for you. Like I didn't even write this. It's already here. Um I mentioned earlier too and I'm just going to jump over to this other tab here. Right. I mentioned earlier that if you're getting into programming, a lot of the time if you're reading about this online or watching videos, you'll hear people talk about Python. And Python is um supposed to be, you know, one of the more easier to understand languages. Um easier to understand does not necessarily mean that it is less powerful. Um it's just a different language. I'm less familiar with Python. So, I wanted to show you that you could go to a site like online-pon.com. You can do a web search for like online Python and you'll see a bunch of different things that you could do. But I encourage you to try something like this because when you go to actually start writing like full programs or maybe you want to write some scripts and things like that, you might have to install some tools on your computer locally. So I'm trying to save you some time so you can experiment. I think this is the easiest way to do it. But yeah, we have one for Python here. And jumping back, we have net fiddle. And this is what I would recommend just to jump in. Okay. So, when we're going to look at our very first program here, um I mentioned I didn't even write this. It kind of just showed up here when I went to the site. Um there's a couple of things that you're going to see on the screen today and I don't want to go into the details of them because they are part of the C language. So, I'm going to highlight them with my cursor and just explain for right now, we're not going to focus a lot on them. Okay? So, all of the parts that I have highlighted here and all of the parts down here. So, really right now, we only care about line seven. That might be a little bit confusing. Um, but we're just going to be talking basically about the stuff that we see from lines five, six, seven, and eight. Um, and we're going to change kind of the contents that we see in here. Another quick mention um, for why I wanted to start with something like this, well, I guess two things. One is that if you go write your very first program, um, in basically any language, the the I guess like the meme you would call it is like the first program you usually write is called Hello World. And hello you can I think you can check it on Wikipedia and get the actual details but hello world is basically like this is your first opportunity to write some software where a computer is able to execute something for you. So it's like the computer your software saying hello world like I'm alive. So that's where that comes from. And the second part for why I like starting this way is that as programmers, and you can ask other programmers this if you don't believe me. A lot of the time when we're trying to solve different problems, we're using other people's code. We might go to a site, do some research, and say like, I'm trying to sort a bunch of things, and I need to be able to do that, but I don't know the most efficient way to do it. I need to go download something from a website. How do I go do that in C? A lot of our time is spent basically identifying steps that we want to do and then going to look them up online. The more experienced you are, the more you're able to retain and kind of, you know, type out without having to to go search it up. But a lot of the time, you're going to be basically looking up other people's code and then modifying it. And that's okay. I'm not suggesting you go copy someone's entire program um and claim it as your own. Please don't do that. That's that's called stealing. But when you can borrow pieces and interpret them for your own use cases, especially if they're put up for open-source usage, this is a good example where we can make some changes here and start building some other things. So if you're following along and you've gone to netfiddle.net net in some tab you have um open in your browser. What we're going to do is this line of code that I have highlighted that says hello world. If we go run this, so I'm going to press this button right at the top. And what this is going to do for us, as I explained a little bit earlier, is this is going to take the the code that is closer to English than ones and zeros, right? You might not know what some of these things do and that's totally okay. But it's going to go from something that's readable for us and it will at some point put that into um instructions that a processor can understand and then it's going to run it for us. So if I press the run button, you can see it did a little spinner for a second and I think the output was already down here. Like I might have run it before starting this so I apologize. But you'll see right down at the bottom we see hello world. So cool. That's that's the first program that most people ever write. It's and what we can talk a little bit more about what this line does, but um we're going to do two things. We're going to explain what's happening here. And it might not be totally obvious yet. And I don't think you need to understand all the details quite yet, but I'm going to prove to you that with limited knowledge, we can change this to do other things pretty easily. So, I'll explain it briefly. Um, but when we look at this line, there's a couple things going on. First of all, I'm going to talk about the semicolon of the end of the line here. This is um unique to some languages and other languages don't have this. But a lot of the time you'll see a semicolon like this. You probably almost never use a semicolon normally. Um and a semicolon here is to indicate the end of a line of code that we want to execute. In C, not every line of code needs to have a semicolon. There are certain things that don't. But in C, this generally indicates the end of a of a line of code to execute. So I'm calling this out because when you see this and you're like, "That's confusing. Why the heck is there a semicolon here? Why are the curly braces and other stuff going on here? Like why are there parentheses?" This is all about the syntax of the language. So depending on what language you want to go learn, there's going to be little things that are part of the syntax that you need to learn about. So that's one of the things for C is that it has semicolons. I'm going to jump to the other tab briefly. So sorry if it's a little bit jarring, but if you look at this one, this is Python. It's a different language and uh it's not actually a hello world. Um, but here you'll notice there are no semicolons. You don't need semicolons in Python, right? And actually, I can My Python's a little bit rusty, but I bet you I can make this say hello world. I haven't coded in Python in years, but let's just try that super quick. Right. And where's the run button? Right. prints hello world right at the bottom. Okay, so I'm gonna jump back to the C one. I just was trying to test my Python quickly. But um when we look at this, we talked about the semicolon. That's cool. But we know based on when I press play, this text that we have here is the stuff that shows up down here. Like what what's actually going on here? And to understand that we have to look at this other part. And this I would I would agree that when people compare something like Python to C console right line maybe is a little bit more confusing. We got a couple more things going on. We have this thing that's called console. We have a dot and then we have the word right line or words right line. And then some parentheses, right? We have this open parenthesy. We have a close one and then we have some stuff between some double quotes. It's a lot going on if you have never programmed anything before and that's okay. So this is why I'm spending time trying to look at just this one single line to make sure that we have some clarity on it. Um but really what this part that I have highlighted console right line is something that is built into C. Um, it's something that you have access to as a programmer. This thing that's called console. and console depending on how familiar you are with um computers. I guess if you've ever opened up like a a DOSS prompt or a like a command shell, if if what I'm saying doesn't really make sense to you, think uh you've probably seen at some point maybe um like a window on a computer where you have like a black background, white text, and um different lines kind of uh being printed out one by one on there. It's generally referred to as a console. Um there's new things like PowerShell and other things like that, but the concept is a is a console. And what we're saying for this program hello world is that we would like to ask the console to write out a line that has this content. So what's going on here is that when you look at this part, this is the thing we're asking to do some work for us. It's called console. And this is one of those things like if you had nothing here to begin with. And and I said, you know, I would like you to write out the words hello world to the console and you've never programmed before. You might go, I have no idea how to do that. So, what would we go do? And I'm not exaggerating when I say this because I think some people look at programming like it's some, you know, magic art or something. But we would just open up a tab in our browser and say C write to console. That's what I asked you to do, right? So, boom. There's tons of examples that pop up. So anyway, it's pretty easy. You can see console right line shows up here. But this is how we program stuff most of the time when we're getting started. And even though we're not getting started, if it's a new topic for us, we generally do things like this. So I'm going to go back to here. Sorry for the black and white kind of jarring changes there. But I'm going to put this line of code back in. So you might not know console is even a thing you have access to, and that's okay. Um, like I said, different languages are going to have different things that are available to you. So, you might have to, if you're picking C as your first language, you would have to spend some time learning what's available to you. So, don't worry about that if you didn't know console was a thing that existed. Not not to worry. But the next part is really like this. Oops. This dot that separates console and right line. So number one is like the dot actually tells us that we want to access something about console. Now in this case we want to um get the thing from console that lets us write out text. And we call this a function or a method. It might be again like these are terms if you've never programmed before, you're like, I don't know what the heck that means. That's okay. Um I'm I'm going to repeat them again for you, but they're a function or a method. Um sometimes in languages you'll hear like procedure, just a handful of different words, but um they let you organize some steps of code to write and give it a name. So, we won't go into the details of what functions and methods and all that actually are today. Um, but one quick spoiler is that this stuff that I told you not to worry about that says public static void main, this is a function. So, we're writing code inside of a function. You don't have to worry about that for now, but that's what this is. So, we're asking the console, we would like to use your function or method that's called right line. And again, you might not know that even exists. So, you can search it online. Um, good integrated developer environments, idees, good ones will have um some type of autocomplete for you. So, you could literally um be typing console dot and as soon Oh, it does it here. Super cool. I didn't even try this out. Um, like here's a whole bunch of stuff that you could do. We could say clear. Boom. Oops. I have this gigantic microphone in front of my face so I can't see my hands and I'm going to make a lot of typos. But anyway, my point was that once you know you have console, depending on your IDE, you have, you know, you have all these tools in front of you to access different things. But we're not going to go into that. I just wanted to explain what this line does. The last part we're going to talk about are the parentheses and the stuff inside of it. And the parentheses, the opening one and then the closing one are sort of like markers that let us pass information into this function. So if I take it all out, [snorts] I'm now passing nothing into this function. If I am asking the console to write a line with nothing inside of it, what would we expect to have happen? Right? If we're looking down here, what words are going to come out here? If I press run, well, the answer is nothing. Right? We don't have any text inside of here anymore. I took it out. So when we write line, there's nothing that comes out. So if we know we can take it out and nothing's there and we know that if we have hello world in there, that means that if we put other stuff in here, we should be able to write it to the console. So again with limited knowledge like if you've never programmed before and I said okay now that you know that if you wanted to write a different message and say um like tell me what I want you to write out um a message that says like today's date is uh January 8th. Well that's pretty easy. Oops. Right. I I'm just typing out English between these two quotes. And if I press run now, if I said, I want you to do this 10 times, your answer to that might be, well, what happens if I do this? Okay, that that worked. That's two times. So you might go three, four, five, all the way down to 10. I only did it five times, right? And look, it it works. You you're you're already changing a program to do different things. And you might be watching this and going, "Well, Nick, that's nice, but it's pretty useless." Um, yeah, we got to start somewhere, though. So this um this would let you write things on multiple lines, right? All that I did was copied and pasted some of the code. And again, you don't have to have intimate knowledge about what this actually does, but we can see the output of what's happening. Um, so just trying to remind you that you should be trying to experiment with stuff like this and I think it's a great way to learn. Um, so just another super quick note. I want to try um showing you that you can write different things here. So let's take all of these words. Today's date is January 8th. And let's write each one on a new line, right? It's a it's technically a different program. It's a simple one, and that's okay. But if I were to do this, right, today's date is the next word and then is January 8th. Okay. Well, each one of these seem to put text on a new line. So, if I run this, it does what we expect. Today's date is January 8th. Again, these are examples of programs that you might go, that's not very useful. And that's okay. But I'm just trying to illustrate that you can start taking code that exists that's very simple and start manipulating it. You can start making little changes and seeing what happens. Now, the next part that I want to talk about is um is actually going to be a little bit more advanced, and we're going to be talking about um we're going to use what's called a variable. So, hopefully that doesn't seem too scary. We're going to talk about variables. We're going to talk about types and what that means. And to start, I want to say that I refer to this as text. This is text that is being passed into this method. In many programming languages, this text that we're talking about is actually something that we refer to as a string. You might not have ever heard that before and that's okay. That's why I wanted to call it text initially so you could maybe relate to it more easily. But in this particular case in C and many languages when we see text it is called a string. I'm going to jump over to the Python one super super quick because you'll see that in C we have double quotes. And in Python we have this F. I think that's for formatting. So we don't necessarily need that. Um, but it has a single quote, but this is a string in Python. Oops, sorry. Um, what I've just highlighted is a string in Python. So, again, just to show you the same concept of a string, right? It's what you would probably think of as text, but a string in Python. We have single quotes here. Um, different languages too have different ways that you can use single, double, triple quotes, all sorts of stuff to represent strings. Um, and in C, we use double quotes for a string. Okay, so that's nice. What what's a string? How do we use that? Is it do we always just put stuff in quotes? And can I just write I don't know like hello inside like oh no like that just doesn't work. So you might be wondering okay well now that we know what a string is like what what do I do with that like it seems kind of useless like unless I have something like right line to put it into. So this is where variables come in. So variables are a concept in programming that is called storage. So when we're talking about programs, there's often things that we would like to keep track of. Now, one way that we can keep track of strings is that we could say we want to what's called declare a variable that is of the string type. So, I'm going to get rid of the hello part. Um, I'm just going to push all that stuff a little bit lower and so you can focus on the line I'm writing up here. And if we wanted to declare a variable in C, we start with the type which is string and then we give it a name. So my my variable and then what we would do is assign some value to it. So I'm kind of throwing a whole bunch of stuff out at once. Um and this is going to complain for something. Oh yeah, it's telling us that nothing in the program is actually using this variable. So let's quickly just recap on what this actually says. I said we are declaring a variable, but we're doing two things. We're declaring a string variable and assigning the word hello to it. So this equal sign is an assignment. It says take whatever is on the right side and put it inside of this. So this gets kind of neat because now we can combine this stuff up here with this stuff down here. And now now our program is getting a little bit more interesting. So let me delete all that. And I'm gonna say I want to right line our variable. Okay. So if I go to run this, I'm going to pause for a second because I want you to think about what you expect to come out at the bottom. I think there's probably two things that people might have on their mind for what should spit out here in the bottom. We should either see the word my variable show up down here or we should see the word hello come out down here. So, I want you to think about that for a sec. And maybe there's a third option. Um, I don't know. But I think the two possibilities people are probably thinking to show up down here are that we see hello or we see the word my variable. Now that I've given you some time, the answer, drum roll, is hello. And the reason we see hello down here is because we've taken the string hello. We've assigned it. That's what this equal sign is. We've assigned it to this variable called my variable that is of the string type. And now when we go back to this first thing we ever saw when we were working together here, right, was console right line. And now we're saying I want you to print the value of my variable. And that's why it's printing out hello because it's taking the value that is stored inside of my variable which is hello and putting it out to the console. You Yeah, I can zoom in for sure. Is that easier to see? This is just something that's in this web IDE that I'm not totally familiar with. So hopefully that's helpful. So when we get a little bit more complicated here, we can do other things. So well, we talked about strings, right? Hello is a string. And then I'm going to talk about quickly the other thing that people always get scared about, and that's math, right? I'd mentioned already at the beginning of this and I can't recall if my audio is still messed up or not, but I'm not good at math and I program regularly, but how can you not be good at math and program, right? Because people are always afraid. Well, it's not that there's no math in programming. It's just that generally the math you're doing in programming is things like counting. I can count. Um, I've been able to count most of my life. Um, which is great. Um, but a lot of the time the math that you're looking at is really not very difficult. There's going to be industries you work in. If you were working in programming for finance, there's probably some pretty intense math, but that's specific to finance, right? Um, I worked for eight years in digital forensics and there was lots of math, but that math was like counting file size, for example. Um, you're not doing like calculus and really complex math. Oh, well, I'm glad. Thanks for the recommendation, Jamal. I didn't realize that it was too zoomed out for folks. So, I'll keep that in mind for next time. Um, so let's quickly talk about some of the other types we can use. Um, and we're going to talk about numbers because we're going to talk about everyone's favorite topic, math. So, numbers can be stored in different ways. And there's going to be I'm going to keep it uh simple here, but there's some computer science and sort of like low-level stuff to think about. But when us as humans talk about numbers, we have things like you know the numbers 0 1 2 3. These are things that we would call integers. They are whole numbers that can be easily represented that way. There are basically infinite numbers though. So how can we possibly represent an infinite number of numbers in software? And the answer is that we don't. we actually have some tricks. So we won't go into the details of that, but we're either talking about numbers that are integers. So I'm going to call it my int for my integer and I can say it equals 1 2 3. Now the other types of numbers I'm not going to I'll just mention them but um they are float and something that's called double and that's a slightly more advanced topic but those allow you to use things like decimal places in your numbers. So integers cannot have decimal places. And this is kind of interesting, right? Because now you might be going, okay, well, I wanted to maybe write a program that worked with um finances, right? I wanted to do something that could print out my budget for the week or something like that. And that might be tricky if you're only using integers. So you have to think about some of the tools that are available to you and then work with that. So if I said cool, we got my int now and I want you to write that to the console. How does that work? Well, if we look at this other example, all that I had to do here was put the word my variable here and we we could see that the word hello came out to the console. Okay. So, what if I just put my int here? I'm going to get rid of this one. Does it work? It does. Now, there's a trick that you're not able to see easily, and I'm going to see if this IDE ifn net fiddle shows us. But the point that I want to get across is that we're talking about two different types of variables. Oh, it doesn't show you here unfortunately. Um, just to show you quickly, remember we declared the string one with the word string and the uh the integer one with the prefix here int. These are two different types of variables. The right line works because there are different versions of it that you can't see easily here that allow you to pass in strings or integers. So, let's forget that for a second. And if I said, I want you to print out um this variable that's called my variable followed by my int the contents of that. How would you put it down here? Well, this is going to be something that we're going to call um like it's another assignment and we're going to be dealing with two different types. So, this might get a little bit confusing. So, um we'll try again. It's it's a pretty simple example, but if you've never seen it before, it's not obvious. So if I wanted to combine these two things, really if you think about it, if I asked you to combine hello and a number 1 2 3, well, one of them's a number. And if you added two numbers together, we all know that like we could if I said add 1 2 3 and the number two, you would say, well, it's one two five, right? You just do addition. But we have a string and we have a number. So how do we combine them? And that I mean it's interesting because there isn't like a right answer to it and you have to make a decision about what you want to do. So what I want to do in my case is I want to um I'm just going to write it up here. what I want it to look like. I'm going to use a comment is I want it to look like it says hello 1 2 3. That's what I want it to look like. So, how do we accomplish that? Well, someone who's watching this might go, well, why don't you just type it out, right? Like that's that's the the obvious thing. So, um I'm just going to call this new variable combined. And you might say, "Well, there's the answer, Nick." And you're right. So that is the answer, but um that's going to be cheating in this case. I want you to actually use these two variables to accomplish it. So if we wanted to combine an integer and a string to get a string in C, we can actually do that pretty easily. Um, some languages it's easy to do. In other languages you have to be very explicit about how you'd like this to work, but um, what we can do is actually type my v oops you have to spell things properly. That's the hardest part about programming. Um, so you would take something like my variable, right? We know that the value of that is the word hello. And then we can use an addition operator. And one thing that we don't have in our variable that you might not have uh recalled because I deleted the comment is that I want a space between the two. So I'm going to add a space and then I can actually add the number here. So this actually works in C. And like I said, different languages have different behavior here, but what this means in C sharp is not a mathematical ad. And that might sound weird to you um because we're talking about words here, but what I'm saying is it's not a mathematical ad because the word hello to us is not numbers. and a space is not numbers to us. So when you're talking about strings together in C, the addition sign is what's called concatenation. So it lets us take two strings and put them together. So that's really cool because now we can take my variable, we can concatenate a space. And then the last part here is kind of weird still because well my int is a number. So what does this operator it's called an operator right? So what does this operator mean when we're trying to take a string and add an integer to it? Well in C the result of a string and an int being added together is still a string. So what this actually does that you can't easily tell here is that this will actually convert our number into a string representation. And that again might not seem obvious to you um if you're not familiar with how types work and that's okay. But if we go to write this out now and I run this, we get hello space 123. So just I'm going to move on to a different topic because we're running out of time that I wanted to allocate for us today. But just to give you a super quick variation um on why the whole integer string thing is uh kind of interesting here. Um, I'm going to call this um I don't know, naming stuff is really hard. Other variable. Sorry, I'm not creative enough. And what we're going to do is I just wanted to to show this to you super quickly. Oops, that doesn't exist anymore. Sorry about that. Okay, so these two things, they look similar, but they are very different. One, two, three here is an integer and one two three here is a string. So, this is probably a better example for me to have used before, but um if I were to try and write this out to the console, right? Oh, I don't know why this didn't come up before, but this is where I was trying to show you that you can It's already gone. Sorry. You can pass in other things. Um, and I can't make it show up again, but you can pass in other things into here. So, if I said, I want you to add these together, right? One's an integer, one's a string. Well, what do we expect to come out? What would we expect to come out of here? Because one of them is a number and the other one is a string, right? And all that I'm doing is just like before, I'm adding two variables together. If I press run, we get 1 2 3 1 2 3. Some of you might have been trying to get a calculator out or did it in your head and said, "Well, 123 + 1 123 is actually 246." And you're right, it is. But in C, you are taking a string, which is this one here, sorry, a string and an integer. This will concatenate them and make this one also a string. So that's why you have one number followed by the other number. If you wanted to actually make this show up as uh 2 4 6 as the result and actually add the numbers together, that's where you would have to convert this to an integer. We're not going to do that today, but I just wanted to show you that there are differences in the types of variables that we use. Okay. Um, I'm a little behind time, so I'm going to omit one topic, which is called loops, which is really fun. Um, but we're going to talk about one last thing, which I would say is one of the primary building blocks in any program. So, we talked about variables, and that's how we store things. And that storage that we're talking about is in memory for the the program that's running. So, it it didn't go write that stuff out to a file somewhere on your computer. Um, that's just used in memory while the program is running. The next part we're going to look at is how we control logic. So, I talked about storing stuff, but what happens when you want to make decisions? Because making decisions in programs is really one of the core building blocks. And in different levels of programming and languages, it's called um either an if statement because you are asking if a condition is true, then you do something and then else you would do something else. That's called an if statement. Uh, another way to look at it, and I guess in really low-level stuff, you would hear branching because you're following one path of execution, right? Your code is running line by line. That's nice. And then it would get to a a decision where it needs to branch between one way or another. So, how does that look? Well, in C it's literally you start by writing if and we have stuff inside of parentheses. So again, this is some C specific syntax. So don't worry too much about it. But we would put our condition in here. So we have to write something inside of here. And then we're going we don't have to do this but um you'll see it written with um curly braces. Okay. So usually you will see this where we have some condition in here. So like if true. This is a really simple one. We're going to write hello world out. So this is our very first if statement. Um, for single line if statements, you don't need the curly braces. You can just write it like this. I just recommend that you don't start practicing this way. Um, and I say that because um, it's a a C and some other languages. specific where if you wanted to write this, this does not do probably what you think because if this condition is true, it will do what's I'm using a poor example here. It's not going to check this condition for both of the lines here. So this is probably like it looks almost like a typo really in Python. This probably does what you think. So let me change this a little bit. I'm going to write hello world like this. And I'm going to change this to false. So when we talk about if statements, it's checking inside of the parenthesis is the thing true or false that it results in. So if I write if false it will never be true. Just by definition false is never true. So what would happen if we run this? Well why is world printing? We said false false is never going to be true. So none of this should have run. But this is why I'm telling you that you need to have curly braces because um this syntax is what it's called, right? This syntax where you put one line underneath an if statement in C only works for the single line following the if statement. So basically, long story short, forget about doing it this way and always use curly braces. Always the curly braces say that anything inside the curly braces is now going to be controlled by the if statement. So again, if I run this now, it should print nothing because these are grouped together under the if statement. So pause for a second. Might be a little bit confusing because you're seeing other characters and stuff. You're not like people don't often type curly braces in English. if you're writing essays or emails, right? You're not usually using semicolons, but these are things that are part of the syntax we use in C and some other languages. So if inversely if I put true here, have to spell it right, this will always be true and it will write these things out. Okay, what are some other ways that we can make this a little bit more interesting? Well, let me do this. Let me bring back those other variables we were talking about. Um, my number, right? So, what does this mean? Well, I have declared an integer called my number and I have assigned 1 2 3 to this variable. So anytime we want to ask what my number is, it will tell us it's 1 2 3. Okay. Now I want to do my number two. And this is going to be four five six. Okay. So yes, there are numbers here. No, this isn't any scary math. Um but we can do a check now. We can say something like if my number And this is a C specific thing. So you see the equal sign here. This is an assignment. If you want to check if things are equal in C, you need two equal signs. Again, may not be obvious to you. That's okay. A lot of this stuff isn't until you practice it. But we will say my number two. Okay. So, what do we think is going to have or happen for an outcome? Here we have these two numbers. We're checking if they're equal. So, we're saying if the numbers are equal, write these two lines out. Well, before we run it, let's talk about it. My number is 1 2 3. My number two is 456. Does the number 1 2 3 ever equal 456? No. They're two very different numbers. So if I press run, I expect to see nothing show up here. And I expect to see nothing because this is false. This always comes out to false. So let me run it. There we go. You can see there's nothing down here. But we can do other comparisons. We can check other things here. So, we might be able to say, well, what happens if we want to see if my number is less than my number two, right? The arrow sign to the left is a less than. So, if I run this, it is true and it prints out the contents here, right? Because my number, this is this is functionally equivalent to me going 1 2 3 is less than 456. If it wasn't totally obvious before, that's what this ends up doing, right? So one, two, three is always going to be less than four or five, six. Now, one final part here because we're a little bit over um is you can also check the inverse condition. Okay. So, we'll put some other text into the console. Right. So, if my number equals my number two, we will write this out, right? So, we'll see hello and world. Else means otherwise, right? So, if this condition is not true, we go down to here and there's no other condition. It's checking. It's just saying we know that this one was false. So, let's jump down to here. So, if I run this, it will say goodbye, right? Because we know that again, I'm just going to I'm going to put the numbers into here. 1 2 3 4 5 6. We know 1 2 3 does not equal 456. So, all of this code never gets run. And we'll get this. We'll get the goodbye printed out. Okay, so that's mostly it for today. Um, so just a super quick recap. The things that we got to talk about are um that there's going to be differences in the programming languages that you might want to look at. Um, a really popular one to get started with is Python. Um, Python, you don't have a lot of these extra things like curly braces and semicolons, right? Um, none of that was here before. So it might be easier for some people to get started in Python. It's not my language of choice, so I generally don't go to that. Um, but you might have, you know, um, an enjoyable time getting started with that. But you're not going to make a wrong choice. If you start learning a language, the things and the concepts that you'll learn about that language can be applied to other languages. So um, Python has variables in it. Python has if statements. Python has loops in it. C, I was just talking about all those things. So, clearly it has it. So, don't worry about picking the wrong one. I just recommend you get started and you try sticking with it. Um, so we talked about variables, if statements. I did not get to loops today. So, if you're looking for a little bit of homework, maybe you said, "Yeah, Nick, this was nice, but it was maybe it was too simple." Cool. Um, I recommend trying to go look uh at loops in C or if you're looking in Python, you know, search for examples of loops in Python. Um, I think that would be great homework to try out. Um, and I think that's mostly it. So again, if you end up re-watching this video later, you're jumping through it. Um, there were some uh comments in the chat. So, thanks folks for being able to chime in on about stuff and I would say if you're re-watching it, feel free to leave comments and ask questions because I can respond to you there. So, there's no such thing as a dumb question. If you don't know how something works or you don't know where to find an answer, ask. There's nothing to be embarrassed about. Um, like people don't just know this stuff without practicing it. So, I'm happy to try and help. um and get you the answers you need. So, thank you so much for watching. Um I'm gonna try to do more of these in the future. Uh they'll all be pretty similar. Um trying to kind of do a bit more of like intro to programming. So, I do appreciate you tuning in to watch. Um if this helped at all, um please uh like the video. That would help a lot. Um and subscribe to the channel, too, because if you like content like this, I'll try to be putting out more. Um, and yeah, thanks so

Frequently Asked Questions

Do I need to be good at math to learn programming?

No, you don't need to be strong in math to get started with programming. I wasn't particularly interested in math in my 30s, yet I program regularly. The math involved in programming is often basic, like counting. So don't let math hold you back!

How do I choose the right programming language to start with?

When starting out, you can pick almost any programming language. While some languages like Python are considered more user-friendly for beginners, the concepts you learn can be applied across different languages later. Just focus on getting started!

What should I do after this introductory session?

After this session, I recommend checking out resources related to scripting or looking into loops in programming. Practice is key, so try experimenting with code and don't hesitate to ask questions if you're unsure about something!

These FAQs were generated by AI from the video transcript.
An error has occurred. This application may no longer respond until reloaded. Reload