 Hey everybody, it's Brian. This tutorial, I'm going to answer a lot of questions that I get. This isn't going to be on any specific language, it's going to be on actually all the languages. If you go to my website and you just go to Contact, you'll see that I actually am fluent in a lot of languages. And I get a lot of questions about, you know, you're only 40 years old, how did you get fluent in this many languages? And, you know, some people are like, only 40, you know, you're ancient. And people are like, well, you're just a youngster, I'm 60, 70 years old and I'm writing code. I'm middle-aged, let's just put it that way. Point being though, learning languages is actually very, very easy and I'm going to show you a real trick on how to do it. If you go out to TIOBE index, you'll see it's just a ranking of languages and this is based on popularity, based on search. And you'll notice that most of the languages have certain things in common. For example, they're either C-style or they're Kobol or VB-style languages. Once in a while you get the oddball one like Python, but you could actually argue that Python is sort of a C-style language when you really look at it. You'll notice that C is quote-unquote the most popular, followed by a Java Objective C, C++, C-sharp, PHP. What are you looking at right here on the top? Let's look at the top six. They're all C-style languages. If you know C, you implicitly already know Java and Objective C and C++ and C-sharp. Now I know I'm going to get some hate mail saying Objective C is totally different, but really it's Objective C, I mean it's a C-based language. So my point is, if you know one, you pretty much know them all. So the objective of this tutorial is I'm going to show you some just handy shortcuts. And if you go out and you also look for the most popular coding languages of 2014, you'll see some trends. You'll see that Go is 1.5% share of the market. What goes is a relatively new language. Well, Python's an old language, but it's only recently been getting hyped up and now it's got 30% market share. And why is that? Well, it's easy to work with. Java is easy to work with. It's also 22%. You notice the harder languages like the C++, the C-sharp, and the Cs, they're a little less used. I shouldn't say less used, they're less popular in searches. So people like fast, easy languages. The thing about languages is no language is really faster or easier than the other. It's all about your knowledge in it. They just have smaller learning curves. You can learn Python in about two or three hours. You won't be an expert, you'll be fluent enough to write a pretty decent program. C++ will take you two or three months. There's a steeper learning curve. So without further ado, let's just crack open your word editor here. Some things you need to know for all languages. They have variables. Now what's a variable? Variable's a scientific term for something that means it will change. So for example, my age is a variable. As you're sitting here listening to me talk, I'm aging. That's utterly depressing now that I think about it. I'm aging. Anyways, my girlfriend's laughing in the background. Another thing they'll have in common is constants, if I can spell. What is a constant? Well, it's another scientific term. It means it stays the same. Like a radioactive state of decay is a constant. My gender is a constant, at least I hope it's a constant. I don't want to magically turn into a woman, although I know some species of frogs will actually change genders, so gender's probably not a good example. Let's just stick with radioactive decay. And then they have operators. These are like what you actually do with a variable or constant. For example, you can add it, you can minus it, you can say is it less than, is it greater than, you can and it, which is a memory function, you can or it, which is a memory function, et cetera, et cetera. So you're going to do something with the variables and constants. Well now you have flow control. And without sounding like a commercial for flow max, you're going to control the flow of the program. And this is like your if, thens, your elses, your loops, and select case, or what's this called, a switch. I'm partial to C-style languages. And now you also have what's called a scope, which means where do those variables live? And what do I mean by that? Where do they live? Well, when you make a variable, it has to live somewhere, it lives in memory on the computer. Well, a program sections off certain parts of memory into what's called scope. The scope can also be called statements, let's actually delete this. Statements, functions, I can't think and type at the same time. Statement functions, subroutines, methods, and properties. Now you should note some languages only have statements, some only have functions. Some have functions and subroutines, some have all of the above. And then you'll have last, but certainly not least, structures. Sorry, my computer's glitching up on me a little bit there. You'll have structures. And these would be data types, structs, which is short infrastructures, nums or enumerators, and you guessed it, objects. Now I know what you're thinking, whoa, hold the phone, there's some languages out there that don't have data types. For example, VBScript or Python, actually they do. They just shield you the programmer from having to learn them, which is why Python is a very easy language to learn, because you don't need to know the difference between a long, short, a decimal, a single, a double, double, wide, long. You just know that it's a variable, whereas C++ you actually explicitly have to state it. So that's the basic foundation of every programming language on the planet. They all follow these basic principles. Some have more bells and whistles than others, some don't. For example, C++ versus the .NET framework. At the very core of the .NET framework, it's actually written in C++. It takes the C++ runtime. Now, the difference between C++ and .NET is you have a massive library behind the .NET framework. That's why it's called a framework, where C++ is a language. So it's not fair to compare the two, and that's where a lot of people fall short. For example, people go, well, Java's a better language because it has X, Y, and Z. No, Java is almost identical to C++, just without pointers, but it has a gigantic framework. So it's a better comparison to compare Java to .NET because they're both frameworks. But as a language, C sharp versus Java, they're basically the same. Once you know one, you pretty much know the other. You just have to learn the language, which is working with structures, data types, objects, et cetera, et cetera. So what we're going to cover here is if you look at this, you'll notice that most of these languages are C-style languages, and then you have some oddballs like your co-balls or your visual basics, and they have a VB syntax. We're going to cover the foundations of these in this tutorial, if I can get my computer to... There we go. So we're going to do the C-style first because it's my favorite. Everybody has a favorite. And let me digress here a little bit. I actually... My first language is not a C language. People have watched my tutorials and they see there's a ton of C++. C++ was my first language attempt. Notice I said attempt. I actually did not learn C++ first. I bought a book, I read it cover to cover, didn't understand it, read it cover to cover again, did not understand it, tried reading it cover to cover and ended up throwing it literally through a wall. I hated that book. It just did not make sense. So then I switched to visual basic and it made sense. I clicked because it read like a story. If you're hungry, then go to the kitchen. Well, I learned a lot of bad habits in VB and then I went to Delphi, which is Pascal, which is kind of a mix between a C and a VB style syntax. Eventually I did land back on C++ and it was much easier because I learned the fundamentals that I'm about ready to teach you. All right. So a C-style language will have a comment. A comment typically starts with a double slash. Stigma is strictly for your benefit. Basically means hey, you can write notes to remind yourself what you did. When you declare a variable or even a constant, you'll have to give it a type and then a name. Now what's a type? A data type would be like an integer or a string or something like that. Now sometimes you have to do a little magic, like you have to put the word constant or actually constant in front of it to tell it that it's a constant variable, but in the end it's, I shouldn't say variable, it's a constant type, meaning it will never change. So you'll have to declare a type and a name. Next thing you need to do is get into, well, you guessed it, flow control and we'll just do the basic if statement. So it's if, parentheses, and I'll just do caps, that way you can really see it. If then, and then statement. And then notice the semicolon at the end. So that is a one line statement. You're just doing an evaluation, if, and then something, and we're just going to say x. If x. X could be true. X could be y plus 10. I don't care. If something, then do something else. This is an if then statement. You can also break that down into scope. Notice these brackets. That's indicative of a C style language. It's called C because C was really the first language, I believe, to use that kind of curly bracket syntax. A lot of people hate these brackets. I love them and let me tell you why. Because it defines scope. Going back to what we were talking about, scope. What is scope? Scope is a hotel. You have a variable and I'll call that variable Brian, me. And you have another variable and we'll call it you. You have a hotel room and I have a hotel room. You don't want me in your hotel room and I don't want you in my hotel room. So that's scope. Think about that in terms of a language here. You are a fair one. You live there. Fair two. You live there. Which means fair two cannot live outside of these brackets because you put it in scope. Now fair one has what's called a global scope. Meaning it can go anywhere. It can be outside this. It can be inside it. It can be underneath it, wherever. And when you look at a program, you should actually think that there is a giant set of parentheses. So it looks like that. It looks kind of weird, I know, but that's called the global scope. All right, now we've covered if statements. So right there, what we've covered in this brief tutorial thus far is probably about two weeks of computer science class. So you're welcome. And now we're going to do a while, which, you know, should look very similar. It's got a command if or while and then we give it a statement x and then you've got a scope. So while x, and we could say while my age is 40, while it's nighttime, while I'm happy, while I'm hungry, et cetera, et cetera, and then it'll execute that scope. Or you could do a do while. Now what's the difference between while and do while? Well, while will say evaluate it, then execute it. Where do will just execute it and then evaluate it. So you could say you're sad if you're sad, do something. So it'll say while I'm happy, meaning it won't execute because you're sad. Let's say you're sad and it says do, and then you get what I'm saying though. It's going to execute this without really evaluating the statement until the end here. Then you have a for loop, pretty much the same thing. And this is typically broken up with those semicolons. And we'll say x equals something, x is less than or greater than something. And then you're going to increment or decrement. Looks like ancient Egyptian algebra, I know. But it's actually very easy syntax. You're just going to say for and then some variable, because it's going to change, equals some value. And then you're going to evaluate it. This is basically an if statement up here. x is greater than, less than, equal to some other value. And at which point you're just going to increment and move on to the next one. So it's going to keep doing this over and over. It's going to keep executing this scope over and over and over until that condition is no longer true. And there's one last one I'm going to go over. And it's called a switch statement. Let me kind of move my notepad up here. All right. Think of switch as a gigantic if then else statement. Oh, that's one other thing I kind of forgot. Let's do the if. You can also add the else keyword. So if x, then do something otherwise, do something else. Notice how you've got two different scopes here. Scope one, scope two. All right. So the switch statement is very similar in function, but different in syntax. And let me explain here. You've got your evaluator. You're switching. Think of a switch as like a light switch. And then you've got a scope. Now in the scope, you've got a bunch of other switches. Can you see a pattern here? If I could type right. That pattern, of course, are your little light switches here. Case, case default. So you could say case one, case two, and then default. So if x is one, it's going to flip this switch. And you could think of this as a mini scope or a scope within a scope. If x is two, it's going to do this. If x is three, well, we don't have a case for three. So it's going to do the default, which is this scope down here. That right there, boys and girls, is about nine weeks of computer science class. Pat yourself on the back. You now know the fundamentals of every C-style language on the planet, which would be C, C++, C-sharp, Java, PHP. Python's very similar. The real difference with Python is they don't have these brackets, and they use indentations for scope. But like I said, you can pick Python up in about two or three hours. All right. So now we're going to move on to the COBOL style or VB style languages. Now a comment is usually just a single quote. And to declare a variable, you would do the opposite of a C-style. You give it a name and then a type. Sometimes you have to do a little magic in front of it, like say dim for dimension is what it stands for. And then we'll say name as, and we'll say string, something like that. So it depends on which language. Some languages are different. But just know that you got to do a name and then a type. If then statements are incredibly easy. If, let me do capital letters so you can really see it, if then, and then you'll do something. And there's just an invisible scope at the end of this. You can also do if, then, and if. Let me kind of break that up a little bit. And you would just do something in here. So you can see how you're building scope. And you would have, of course, oops, my keyboard does not want to cooperate with me. Else and if. So now you got dual scopes. So you have if, you know, some evaluator like X, if X then do something otherwise do something else. And you could build that out indefinitely. All right. Now you've got four loops. Syntex for these are a little different. But you notice the basic structure. You got four. Some variable equals some value to some value. Then do this. And in modern languages, they have a four each, which is called the iterator. Basically, you have a list of things and you could iterate through them, but we're not going to really go over it because it doesn't really, it doesn't really exist in all languages. And it's drastically different in most languages. All right. So we got the four next. And then we're going to do the do while. And then you would, you know, do something in here. I'm just going to take this do something and copy and paste it right in there. So you can see, whoops, you're doing something. And then you're going to do the do loop until X. And this is the same principle. You're going to evaluate first and then loop. Or you're going to just loop and then evaluate. So let's talk about a loop real quick. And it's the same thing with C style languages. A loop would be, you know, it's like playing hide and go seek. You got to count to 10. So, you know, while X is less than 10, keep counting basically. Now, VB style languages also have a switch, but instead they call it a select case. And then you'll just have your cases in here. You'll see case one, case two, case else. As you can see, it's very similar to the previous with the C style languages where you'll have one, two, and then you have your default. That was a mouthful. So you can see the comparison between the languages while they may look drastically different. They're very, very similar under the hood. A lot of people get kind of confused and daunted when they start a computer science class and they have to learn two or three languages in a semester. And I'm sitting here going, learning the language is extremely easy. It's just you got to bear in mind you have variables, constants, operators, flow control, scope, and structures. Notice how we have not talked about structures. There's a reason for that because structures are treated very differently in each language. Some languages don't have objects. You've heard the term object-oriented programming. That's a new fangled technology young kids are using since the 70s. Some languages only have structs and enums. Almost all languages have data types, although there are some real radical ones out there that don't have them. But when you do object-oriented programming, really what you're doing is you're making a structure in memory. Think of a structure as a blueprint like you're going to build a house. Well, houses come in different shapes, sizes, and colors. Same thing with cars. You want a blue car, a red car, or a black car. That's where you get into properties. The property is just you're going to control an internal variable in an object. Think of a property as like color. What color car do you want? Now you understand what a property is and you understand how an object works. Now an object, and let's actually just kind of go through here. If I could spell object, an object is just a scope. That's all it really is. We've talked about scope and we're just going to say this simplest form of object is called a class. We'll give it a name and then it's got some type of scope. Now I'm using the parentheses for the C style because it's easier to see where the scope is. You've got your start of scope and your end of scope. Now in here you could say void test. People always get nervous when they see the word void. They're like, oh no, what does that mean? It doesn't mean anything. That's what void is. It means nothing. This is a function and it's going to return nothing. So that's the premise of a C style language. Notice how you also have the scope here. Parentheses are also scope. In here you would give parameters. Parameters is just a fancy word for a variable. You could say A, B, C. Each one has a different data type. And in here you would have your flow control. If, you know, X less than 2, then do something in here. So really all an object is, all the structure is, is just scope. For example, you've got this class and we'll call it class, let's call it cat. Now you can take this class and make a new class and call it dog. Does the exact same thing, has the exact same function inside of it, but they're two totally separate scopes. Meaning they're two totally different parts of memory. They do two totally different things. That's called object oriented programming. And when you get into object oriented programming, it's very simple. It's very easy. Everybody says you need a high end math degree to program. I don't. You're really saying things like cat.meow or dog.bark. It's really all you're doing. And you'll see a lot of that in programming languages where you'll have, you know, object with a dot notation or dot and then something, which is that something relates to, you guessed it, a function. So when you look at these, it's actually very easy to see what's going on under the hood. I know it looks confusing at first, but once you really start trying it, you realize learning the language really isn't the challenge. It's learning the framework behind it. And that's why you buy these 2,000 page monolithic books. But what you realize is most of these books spend 1,500 pages teaching the language. And you've just learned it in this video. Well, that's pretty much all for this tutorial. If you like this, feel free to visit my website. I've got a bunch of tutorials out here and a bunch of different languages. And let's see, languages, yep. C-sharp, cute, C++, Java, HTML, VB, blah, blah, blah. You can also download source code, check out some projects, and donate so that I can help other people.