C++ Tutorial for Beginners 1 - Introducing C++

This first video on C++ for complete beginners introduces the C++ programming language. I've designed this course with complete beginners in mind; you only need basic fluency with using computers as a non-programmer. C++ is a great language to learn if you want to write high-end games, powerful AI apps, or anything else that requires maximum power, speed and efficiency from your computer.



Transcription:

Hello,

This is John from caveofprogramming.com. Welcome to C++ for Complete Beginners. I'm going to teach you C++, the programming language, from scratch in this course, assuming no knowledge of programming. And in most of these course I'm going to program in front of your eyes and to get the most out of it you should also type in the code and play around with it a little bit after each video.

In this particular video I'm just going to talk about what C++ actually is. And then in the next video we'll get onto looking a bit more at installation, although you may have to do some googling to find the right stuff to install for your platform and then we'll get onto actually coding stuff.

So, C++ is a programming language. It's been around for a long time and it's going to be around a long time into the future, I'm sure. But, before you start learning C++, there are some reasons you might not want to learn it. So, let's take a look at those first, but I don't want to discourage you ....

Some people are going to be better off learning a language like Java, and I have a massive free course on Java, which you can find at caveofprogramming.com, or Python, for example.

C++ is considered challenging to learn. It's not the easiest programming language to learn. Although you absolutely can learn it as a beginner. It's easy to introduce horrible bugs into a C++ program. And actually both of these facts probably have to do with the fact that the C++ doesn't protect you from yourself at all. A C++ program just carries out your instructions. it doesn't second-guess them and try to figure out what you might have done wrong. It doesn't try to protect you from yourself; it just carries out what you tell it to do. So, when you program in C++, you have to be very careful; you have to think a lot. And it's very easy to create horrible bugs in there, if you are not careful. It's even possible to screw up your computer if you do something really, really, really stupid, although that's not normally something you have to be worrying about. But it's possible.

In C++ it’s often time-consuming to write the C++ program. And that's not necessarily the case, but you might experience .... if you want to get something done .... it's often quicker to use a what you might call a slightly higher-level language, like Java or Python; that kinda does protect you from yourself more, and gives you more sort of facilities that are immediately easy to use. So, if you want to make, let's say a desktop program, you can do it in C++ and it's going to be very fast usually if you do, but it's not so easy to write desktop programs in C++; there are other languages that make it easier.

C++ is not truly platform independent. And you often can, with a minimal amount of work, get a C++ program to work on different platforms, like for example on a Mac or on a Windows computer and so on .... but equally often it requires a substantial amount of work to get the same program to run on complete different kinds of computer. And that contrasts with Java, where, with Java, a whole simulated computer is basically running on your own computer, and your Java program will then run on that simulated computer. And that means that you can run a Java program quite easily on many different platforms as long as they’re .... you know they’re roughly similar .... like they have big screens and keyboards or whatever. And .... but this is not the case with C++ .... there's no simulated computer that it's going to be the same for every different kind of machine. With a C++ program, your C++ program is running directly on your actual computer .... and for that reason it's not necessarily so easy to transfer it to a different platform.

But of course there are reasons why you might want to learn C++. Let's take a look at those. So .... C++ is very, very fast and you can write programs that are pretty much as fast as they can possibly be, if you write good C++ code, because as I mentioned there's nothing between a C++ program and your computer; its directly issuing instructions to your computer .... and that makes it very fast .... at least if you can program well.

And by the same taken you can also access all the ... kind of ... low-level / hardware-type facilities of your computer ... and C++, if you want to, and if you understand them ... and you know how to do it, C++ will let you do basically do anything with your computer that can be done with it.

So, because C++ is fast and is efficient, also in terms of memory if you write it correctly, as well as in terms of speed and processing power .... that means that you can get a lot of processing done in a short time with a C++ program. As typically a C++ program it's going to be much faster than Java or Python or something like that ... And then, again with the caveat that you have to write it well in the first place. And that means that C++ is good for things like high-end games where you trying to squeze as much power as possible out of your computer ... although of course for that you have to be aware that these very glitzy high-end games ... 3D type games ... usually have a team of people working on them ... it's not so easy to write those things ... including artists and so on ....

C++ is good for artificial intelligence where you again are trying to do a lot of processing in a short amount of time on your computer. Or for any kinda real-time application where you having to do a lot of processing and get it done quickly and sharply .... it's good for that kind of stuff ... and for that matter, if you do write Windows kinda desktop programs in C++, usually you can expect them to run very crisply and to be responsive, because C++ is fast. And you can write device drivers in C++ because again you have the ability to access your hardware in C++.

C++ also pushes you to understand your computer more, a language like Java which is running on a simulated computer ... in effect a virtual machine that runs on your own computer ... insulates you somewhat from your actual computer. There's no such insulation ?… in C++. So, when you learn C++, you do usually learn more and more about your computer. And finally, learning C++ is a bit of a badge of honor among programmers .... I mean .... you get guys who say “Oh, C++ .... why you bothering with that? Java is so much nicer ....” and so on, but I think even those guys are mostly secretly impressed if you learn or if you know C++.

So, yeah .... it's challenging .... but when you've learned it, you can really feel that you've really learned something ...

And, so, to get started with C++ there are basically two things you need .... and a lot of the best stuff is free and I'm going to be using free stuff in this course. The first thing you need is .... well, a bunch of stuff, of programs, that are collectively called the compiler.

So, you need to .... you're going to write C++ programs as text files, as what we call source code files and then you use some software (the compiler) to turn those text files into a computer program .... and there's a choice of different compilers. The compiler that I'm going to be using for these tutorials is the GNU Compiler and the “G” is actually pronounced in “GNU” ...I believe ... and it's some sort of strange acronym. The Compiler is known as gcc or also g++. And gcc was originally designed for creating a language for compiling a computer language called “C” ... and later on, extensions were added to “C” to create “C++”, and then extensions were built into “gcc” to create “g++” ....so now they are the same program. You use G++ to Compile C++ programs as well as C.

And just as a side note here .... it seems like no-one is really sure why C++ is called C++ but in George Orwell’s 1984 if something’s really good that you say it's “plus plus”, like ... I don't know .... “ice cream plus plus” would be really good ice cream .... and because C++ was built on top of a language called C therefore you have C++ .... maybe that's the reason, I don't know ...

So, I'm going to be using the GNU G++ Compiler and that runs on UNIX-type system and I'm using a Mac, which is a UNIX-type system these days. If you're using Windows, you can use MinGW – it’s also free - and that stands for .... I think “Minimal GNU for Windows” and it's the same Compiler just ported to Windows .... and there's also Visual C++ and that's very popular .... and .... you probably can follow these tutorials using Visual C++; I believe there's a free express version that lacks some features, but you can use that for these tutorials.

But there are going to be some differences which I’ve tried to point out, where I'm aware of them, as we go along .... but if you're using Visual C++ is going to be look a little different ... it's going to be a little different. And occasionally to get the actual syntax of the language .... or not the syntax, but some of the things that you have to type in .... are going to be a little bit different with Visual C++. But I can highly recommend GNU, the GNU compiler, G++, it's because it's widely used in industry. Possibly even more so than Visual C++ .... it's an industry standard, it's completely free and you can absolutely rely on it.

So, that's the compiler, that's the software that turns your source code, the stuff you type, into a program. But you're also going to need an “IDE”- which stands for Integrated Development Environment - and that's kind of the equivalent of .... you know .... Microsoft Word, if you like, for computer programming. So, you'll type your source code into the IDE and then press a button and that will, behind the scenes, use the compiler to create the actual computer program. And the IDE that I'll be using in these tutorials is the Eclipse CDT which stands for C++ Development Tool Chain or something like that .... I'm not sure ....

So, and again, Eclipse CDT is free and you can also use Visual C++; that's an IDE which comes with its own Visual C++ compiler.
On Windows a very easy option is to use Codeblocks, but I've never known anyone who uses Codeblocks professionally .... but you definitely could. So, that's another, as far as I know, free IDE that you could use, and Codeblocks makes it pretty easy to install a compiler as well. So, if you end up having trouble getting started .... Codeblocks is maybe a good thing to look at.

On top of that you can use IDEs which are somewhat lower level, in a way, like Emacs and VIM. These are, kind of, editors that you can use for C++ programming but it's a lot more complicated. And some people swear by these things .... but personally, I'm not so keen on them, although I've used VIM for a couple of years .... but I prefer something that looks more like a nicely .... sort of colored thing with buttons and stuff. And, so I'll be using Eclipse CDT.

Now, in the next tutorial we'll going to talk more about installation and things to install. Unfortunately I can't give you specific instructions because it depends on your choice of compiler and IDE ... and it depends on your platform .... so I'm using a Mac but maybe you're using Windows ,or something else, or Linux. So, you have to do some googling probably, but I will give you recommendations about what to install and, kind of, point you in the right direction to hopefully getting you started.

So, that's it for this tutorial. And until next time, happy coding.