Modern C++ Course, Lecture 0: Course Introduction, Organization, Hello World (2021)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome everyone and let me give you a warm introduction to the morning plus plus course for the 2021 edition as you can see this year we have a brand new setup to make the video seem more fun to you to help you in the learning process let's get started with the first lecture so in this lecture we are going to see rather a small introduction to c plus plus and i'm trying to motivate why we should learn c c plus plus on first place for the organization part of this lecture so we typically have a per week one lecture and one hands-on tutorial on the computers lab so we will be doing in personal lectures but you will have us back at these videos and also every thursday on the lecture hall we will be doing the exercise so you get to practice everything so this course is rather practical so it's really important you pay attention to put hands-on work on your homeworks otherwise you're not really going to learn everything we want to teach you so this course is basically speed in two parts the first part is going to be the lectures plus the homeworks where we will give you 10 lectures approximately where we will be teaching you some concepts and the basics of c plus plus programming and we have nine homeworks for you to work on to help you to learn the concepts concepts we teach on the lectures after you finish the first part you move to the second part that is going to be working on a real project and we are going to build a place recognition pipeline based on bag of visual awards and then this you can do in group of two people so basically first you will learn how to pronounce it and then you will put all this knowledge to work on the second part of the course that is the final project the bug official awards typically this course is intended for one semester undergrad course or grad course depending on where you are and we typically calculate rather 180 hours per semester meaning that you at least need to put eight hours a week working on the lectures and on the homeworks assignments in order to make it through so this is rather a suggestion but it depends on how much skill you are in programming how much previous knowledge of c plus plus do you have so what we are going to learn this course so the first thing we are going to learn is how to work with with linux system because linux nowadays the base of any kind of mobile robots or any computer vision applications so this is rather important for us for you to learn also you're going to learn how to write software that is written in one c plus plus and as i will discuss later i will call modern c plus plus whatever c plus plus code is written after 2011. also you will learn how to work with some core software development techniques such as such as using ci cd like formatting tools linters and stuff you will probably use on your professional career after if in your studies so it's also really important to get to know the tools so you can have a smooth transition when you start working on real life projects and lastly but not least you are going to learn how to work with images using opencv the c plus plus api of opencv that you will be using apply to build your bag of visual work projects that is basically the final project of this course the part two this is more or less the big schedule so the so basically the lectures are divided in four parts so the first part is going to be learning the basics that this interaction lecture is going to be on this two weeks module and then we're going to jump next week into work with build systems to let you learn once for all how to really build c plus plus projects then we will move to the second part where rodrigo marcus is going to be helping me to teach that is the course plus language that is basically the syntax of the language and what you really need to know in order to prime c plus plus and lastly the third part of the lectures is going to be the moon ciphers plus part where we will be teaching you cool techniques object directing programming some design patterns and generics programming using the most er of this modern c plus plus tools lastly is the final project that is the second part of the course in this case is part four where you will learn how how to build a bulk of visual worlds pipeline by yourself this is more or less the course content if you go and check out the webpage you will find all these topics so this is rather a summary of what we are going to teach you on the three parts so tools the core c plus plus and the minus plus plus so if you're more interested on what you're going to learn you can go ahead and check the the website of the course the main philosophy of our course is basically that talk is cheap draw me the goal so basically i will be doing hands-on exercises and some hands-on examples here on my computer so you can also get to know uh the concepts through coding so this lecture in particular is going to be more talking in not that much coding but in following lectures you will see me a lot coding and a lot involved with the my computer also part of the philosophy of the course is that you should get your hands dirty and this basically means you must do the homework so there's no way you can really learn how to bike by just watching youtube videos so at some point you will need to get your bicycle and start riding and you will probably fall and then you will get hurt and whatsoever so in this course you also need to do the same you basically need to do the nine homeworks assignment try to make everything work and get as much points as you can from the homework but to help you learn because as much as i want you to explain all the stuff i know about c plus plus is never going to be enough for you if you don't do a homework so please change your mindset and realize that you're going to get your hands dirty then the next question you will probably ask is like why c plus plus so why simple spots in general so there are many reasons uh one of the main reasons for us here in stockton's lab is that c plus runs on real robots and we want our applications our research our ideas to be deployed on the real life not just on an abstract whiteboard and then for this you will need a tool like c plus plus so basically if you go and check the the mars robot that is now uh on from the nasa road there is now mars you would you can go to the hit github page and then you realize that most of the code is c plus plus code so nowadays c plus plus is everywhere on mobile robots the many reasons that we will also explore in the following slides so efficiency is usually one of the most important reasons of why you want to use c plus plus or actually any compiled language but c plus plus is basically the most popular compile language out there for mobile robots application and for embedded applications in general c might also be an option but nowadays we want to teach you more in c plus plus so you can have a better development experience and without paying any cost at runtime or any cost and memory consumption even if you have available some bigger processors for your application if it we are still talking about mobile robots in general you are going to suffer about power consumption so you will have batteries on your robot there is no way around of this and then for this you want to make your the best efficient usage of your processors and then for this typically you need to target a machine code that you actually get to get to this machine code through a compiled language like c c plus plus rust and so on in this course we're going to teach you how to use c plus plus to get this efficiency from your processor no matter which architecture you're using then other important um reason why you want to learn ziplex plus in our community in particular is that the robot operating system is entirely written in zippers plus of course there is some python bindings and some raw spy utilities but not everything is there and particularly if you want to run your application if you are building a perception pipeline for example or something like this you will want to write c plus plus code using ros and then therefore ros is also a really important tool to get to know we will not teach you ros in this course because it's a no it's not a ros course but you need to learn to know c plus plus if you want to use ros it doesn't matter if it's ros 1 or if it's ros 2 you need to know c plus and now and also safety is one of the most important reasons nowadays so autonomous driving is basically the most hot application on the mobile robots market and everyone is trying to build autonomous robots and for this we will need c plus plus why because there's no way an autonomous robot should be running some scripting language like python because in python every time you execute one line you don't know what's coming next until you go there and execute it with compile languages like c plus plus for example you get to to first compile the binary compile application into a binary and then do some static checks before you even get to run the application so safety or safety critical applications is one of the big domains for c plus plus programming then also you will be wondering why linux why you should be using this strange operating system so maybe now in 2021 it's not strange anymore but when i started working professionally it was still strange now it's ubiquitous and it's basically everywhere in the world and actually even companies like microsoft are including the windows subsystem for linux where you can use linux with linear windows distribution so why linux because most of the robots run linux and of course it's much more natural to just use the same development platform as the target platform that this would be linux because if you want to try something first we can try it on the desktop machine do some testing there and then we can target the real application that will probably have another processor that is not an intel processor or amd most likely some embedded like processor like aram i sorry irm and stuff like that and therefore you will be running linux there some sort of embedded linux probably using yokto some raspberry buy some arduino variant and then you need to know linux it's important for you as a professional c plus plus developer targeting mobile robots and computer visual applications to get to know how to use the shell and then lastly but not least c plus plus is always so it's now a popular language and it has been always a popular language so it's a 45 years old language but and even so it's always on the top 10 on the list so here we see one of the indexes out there for programming languages and it's if you start googling around and looking for c plus plus you will always find some sort of top 10 in the list of of c plus so that's basically the motivation of why we want to learn z plus plus and why we want to teach uc so it's a popular language use it on the real world from a wireless application and therefore you will need to learn so let's continue with a bit of history of c c plus plus and computers in general so it all started with computers and some language that it's called assembly that had some benefits to brand computers and processors in general but some also some drawbacks so the benefits is that there were some unbelievable simple instructions and this means that depending on the processor you have and you are targeting you have a really small set of instructions you will use to program your application also it was extremely fast when it was properly written because you were basically written machine code through the assembly language and then you had complete control order program so people from an electrical or electronic background you will realize that this is certainly true because when you prime an assembly that believe it or not assembly even when it's a language it strictly depends on the target processor you're using you will have control of your full application so you know what's going on at each point in the moment but then the question is like okay if assembly is that cool and that fast why we don't use assembly and let me reply to that question with an example of a hello world so if you really want to print a hello world message to a console in intel based processors this is how the assembly looks uh code looks like and as you can tell it's rather complicated and really hard to understand to debug to develop further and actually it's a long example so it's a lot of lines of code to do such a simple task like saying sell hello world so therefore there are some drawbacks so you need a lot of code to do simple tasks also it's really hard to understand and it's extremely important the application you just saw for the hello world example only works on intel processors if you want to try this on a raspberry pi it will not work you will need to rewrite your entire application from scratch using the instruction set for that processor so basically we need a better language and that's how c came to life so the problem is that the computers only understand assembly language and this is not entirely true because actually computers only understand binary language but between assembly and binary there is one-to-one translation so it's we can basically assume that it's the same and then the idea is like okay if the computers understand assembly language then we can probably make the the development experience a bit more complicated but add some translation in between some translators some other tool and this idea of the compiler so the source code will be written in a much higher level language something we can read more and understand more but then you will need some some second program that is going to be the compiler and this additional tool will basically translate from your high level language to the assembly one of course you might say but now this is making everything more complicated because instead of like writing the source code and then i just run it on the processor first we need to write the source code then compile it to translate from our high level language to the assembly code and then run applications this is certainly true but as you can see if you compare any high-level application language with assembly you realize that it's much easier even when you need to compile so for you to know i will be trying to repeat this idea on all my lectures but c plus class is a compiled language meaning that you always need to compile the source code you're writing c was invaded at the for kenyan and richie uh like many years ago and when they invented theme that was basically also they created the unix operating system then they were trying to make computers more accessible for humans and for not that uh not always for just engineers they created c and c was like easy to write and lady was it was a fast language so all the applications were running fast it should be simple rather simple to to run and also should be close cross platform meaning that my application written c should run on different platforms and the compiler is going to be who is in charge of changing the assembly code depending on which application you need to do and then after c and there was some drawbacks so because there was also some weakness on c so there were no objects or classes meaning that you you cannot provide new types for the application and then this was basically tend to be difficult to write code that generate work generically and of course if you have some experience with c even when i see lobster as my one of my primary languages it was really to use to write large programs if you want to write a perception pipeline for example a full perception pipeline c is going to be rather complicated tasks it's not impossible it's suitable a lot of applications are running in c even nowadays but it's much easier when you write it in c plus plus and without paying any costs at runtime so that's why bjorn's this is the creator of the c plus plus language inspired by this drawbacks inspired by the runtime performance and memory performance on c he created c plus plus it all started as a c with classes language but then quickly evolved to something that we call a multi-paradigm language providing support for any kind of programming paradigm so c was a language that was fast the same as c it was also simple to use a c it was also cross platform the same as c but now we have some high level features like creating new types for the application using some static check compilation compile time checks sorry and stuff like that so you can actually do a have a very developer experience getting the same type of applications with the same runtime so the fact that c plus plus is lower than c it's a myth and if this is true it's only showing that you're not using the right compilers or the right tools but nowadays there's no real drawback of using c plus over c this is more or less the evolution of uh c plus plus so in c plus plus 98 so these are the standards so this is something uh that the it's an iso standard so it's a real like like a pdf kind of file where you define like what the language should be supporting depending on the standard and then on c plus 98 that was the first kind of big myosin of the c plus plus community where we already have templates the stl library and some simple operations but this was still rather more like a seaweed classes kind of language after c plus plus 11 and this was basically in 2011 so exactly 10 years ago from this lecture move semantics were introduced smart pointers were introduced lambda functions were introduced cons expressions were introduced and a lot of new stuff that really turned c plus plus into a super modern language that we all use nowadays so the c plus plus 20 um standard is probably the next big milestone on the c plus language process but we are not going to teach that in this lecture in this course in general because we are going to rather focus on the main concepts of the modern citrus plus language so on my lectures i will be trying to give you the intuitions and the real concepts for you to learn so in five years this knowledge you will get from this course it's still valuable so we are not going to really teach you the latest and greatest feature of the language but rather something that can be sticking to your mind uh stuck into your month for years and then you can if you need to keep growing on the c plus plus development experience you will have the strong foundations to do so then the design philosophy of c plus plus is that is multiplied with him as i said before if you want to use it for dynamic programming if you want to use it for object oriented programming if you want to use the procedural language everything should be possible with c plus plus and it actually is the yes that you should express the ideas and the intent of the of the code directly on the code so this is super important as a c plus philosophy is that when we read c plus plus we should be able to understand what the problem is doing and this you could also do it with c actually but it's rather complicated because the lack of creating new types with c that also we call classes and you will see this on the second part of the of the lectures makes everything much more complicated to express how you want to operate your application and how you write it on the real source code safety is also super important so we want our program to be safe across all execution because we don't want the problem to crash because we forgot to assign an integer to a variable and this for that we also have the compiler that will be our best friend and our worst enemy at the same time because it's going to be warning us and not allowing us to compile the application because some simple errors but this will give us safety and we will give us the the the freedom to know that when we run the application a lot of checks has been already made and also efficiency so c plus plus should be super efficient because that's why we want to get our hands on and learn this uh super interesting language and tool to write super efficient applications so and we can with this we can really make usage of all processors or target applications whatsoever and then abstraction is the last and most important step of c plus plus because probably the rest could also somehow except for the multi-part edition you can also get it from c but you don't have the beauty of abstraction and there is something we see plus plus parameter called zero cost abstraction that basically means you can write something on a more abstract manner meaning that you can write this on a more high level language without paying anything at runtime or memory consumption meaning that you will get the same application with the same performance the same memory consumption but the difference is going to be you the programmer is will be able to read maintain and have a better developer experience by using c plus plus so that brings us to c plus plus so before we dive into the first example of c plus plus i want to let you know that we won't teach you everything about c plus plus one of the main reason is that i don't know anything about c plus plus and c plus plus is an evolving language has been around for more than 45 years already and then it's always changing so we will rather show you a really small piece of c plus plus and also apply for computer visions and mission sorry and mobile robots so don't expect to learn everything from c plus plus don't expect to become a professional as a blog post developer within this one semester course this is rather the starting point to get to your professional level with as a c plus plus developer if you want to do this on the future where we are going to write c plus plus code that depends only on loo on you so there are some ideas that i would not recommend i invite you to go to the the course website there's a frequently asked questions there that you will get to know why i think ideas are not the best for you to learn unless you really know what's going on and then also you can use more in text editor visual studio code looks to be the most popular options nowadays so i will tell you i would recommend you to use visual studio call i don't use it on my professional uh [Music] program so i basically use bim as a mattex editor but the learning curve is super steep so if you're not into vm or emacs i would recommend you to stick with visual studio code so you can really focus on the concepts of programming on c plus plus and not on how to use the text editor so text editor sometimes lack of some tools like the build button or the run button but the problem with these buttons is that behind there there's a lot of magic going on and in this lecture you need to learn and understand what's going on behind that button if after this lecture sorry this course in general you really understand everything that is going on behind that button then i will tell you you're free to choose whatever ide you prefer but make sure to know that it's very unlikely that you will be able to use any of those ideas with really really big projects that this tends to be true on most of real life projects so most of ideas will basically block your computer use all your memory just to search a few words so it's a really common choice in the industry and also in academia to use just text editors that somehow provide some coding experience like code highlighting providing you with the terminal and stuff like this and then let's check to the hello world example so this is it will be our first program and i will code it right now for you so you also get to know how to start off with this so let's open uh um my screen so now you're seeing my screen basically i'm using um an ubuntu based distribution ubuntu 24. we will give you more details on which tools you will be using on the first hands-on tutorial and how to use linux so stay tuned for this tutorial that is coming and it's basically the partner of this lecture so the first thing i will do is to just open a terminal and then i will go to a temporary directory on my computer and then here i will create some directory if you don't really know how to use the terminal if you know how to use the shell don't worry you will learn how to do it on this course but not on this lecture the first thing the first hands-on we will be discussing a bit more about how to use a linux terminal but for now just stick with me i will rather be rare running some simple commands so to create a new directory we will use the make directory command and then let's do hello world as the the directory for creating our main application and then let's dig into so change directory into this um and sorry directory and then now we are going to open an instance of visual studio code there's many ways of doing this so for now i will just open uh code like this and then this will bring me pictures to your code instance let me change the color theme so it's more nice and it's close to the slides so let's pick the light plus and then now let's go and check the the hello world example so the first thing you will do is to create a new file that is basically untitled and then the first thing you want to do with this file is to save it as a cpp file so actually the extension.cpp is not really important so that no one is going to check this extension but most of the tools and the text editors will basically be using this dot cbp to realize if it's this is c specification or not so the first thing we will do sorry is to include the iostream header file iostream and there's more to come about this on the build system lecture next week so again uh stay sync and stay tuned and then what is inside here iostream is basically just a file a header file with some function declarations and whatsoever the include statement is basically a copy paste statement for the zipper processor again we are going to discuss more about this on the build and tools uh lecture next week so for now you just let's pretend that this will bring you the power of interacting with the c out that is basically the standard output of your system in this case it's going to be the terminal and then everything will start with main so main is going to be a function and this function name cannot be changed so you cannot pick another name you like main is always the main function and sorry for the redundancy that when you run the c plus plus application you will go and look for this point and then you will enter here so everything that is uh with the double slash is going to be a comment so this is a comment meaning that this doesn't change the behavior of your application this is just basically ignore and in order to bring a message to the standard output we'll be using the c out that is under under the namespace standard so this std namespace is basically like a wrapper that inside here you will have a lot of elements you can use use for your program such as the c out so if you see here later is also giving me some suggestion and we see how we can access the terminal output and then here we'll put basically welcome to the modern c plus class 2021 course and then some c plus plus parameters or experience programs will help me for this but for now when we print this message we also need to print a new line character and there's many ways of doing this but just to keep the example simple let's use the end line that is also part of the namespace standard this will basically be the the program that we're going to compile how we compile this you can open a terminal so you can open a separate terminal or use the bs code or whatever text editor you're using and in this terminal we're going to compile this application so the simplest option is to use the c plus plus compiler that in my system if you check this is pointing to the gnu c and c plus plus compiler version 9.3 so basically if i do c plus plus and then i pass the main.cpp file to the compiler we will basically get a binary so if we list the files here on this project directory that is the hello world you see that we have the main.cpp file that is a program so this is the source code and this is the binary file that is what we can execute as we discussed previously on the lecture now we need to write the high level language that is this c plus plus source code and then we need to invoke the compiler that is the translator between this high-level language and the assembly language and compile an application after this process has been finished and then you will get to understand the whole building pipeline next week uh we'll have a binary that it's typically called a dot out and this is the standard but we can change this name really easily and if we run this uh binary application you will get this welcome to the more c plus plus course so basically this is the first success case in our lectures so we will we we say that we just compiled the first hello world so welcome to c plus plus programming let's go back to the slides so then this is basically the most simple c plus class example the the only detail i was missing was basically the return code that even when you don't provide it so here return call if you return zero this will basically tell the shell or the terminal that everything was right and then if i recompile this parent because c plus plus is a compile language so every time you change the source code you need to recompile if we call c plus plus that is a compiler we invoke it again when we run with our application it's the same behavior this basically means there was no error during the execution of the program so the comments as we say are completely ignore also white spaces the compiler doesn't care at all about this so the only thing that the company will care is the the source code of your program so whatever is a comment that could be with the double slash or with the slash and the i mean with with this syntax over there it's going to be completely ignore the code style is important so you should not be you should not get lost with this there's those like clan format that will allow you to format your code with some standards like google standards mozilla standards there's many out there and you can build your own standard but the important thing is you have some sort of format in your code and getting some some sort of style here on this course we use the google style so there is a cpp guy from google on week which kind of style you should be following for c plus plus programming we are not really really strict on the style but it's important that at some point you go to this link over here that is on this part of the slide and check the the style of from google because this is most likely what we are going to ask you when we check your homeworks also there are some tools like cb billing to check this style but it's important you start building some knowledge of the tools to help you programming in c plus plus everything start with main this i said an example so every simple specs program will start on the main so no matter what you do before and after the problem will go there this function is always returning a code that is an integer value that's why the return value of the main function is main so this is we can highlight this here so that's why main it's always an integer and it's not void or string or something like that basically because we need to return some error code that if zero then means that everything is it's okay and if it's different than zero there's a lot of meanings between number one and 255 but basically it means that the prime fish with some error and then the application which is calling sorry the the process which is calling the application should handle this error properly if you need to do so the include directory is the tool we use to include the iostream header file and then there's basically two flavors of this one is with the angular brackets and they're always with the quotes there is no real difference between these two it's more like a style and then the site we usually follow is that we'll use the angular brackets for system files like the iostream header library that is a sorry header file that is basically part of your system and then we'll be using quotes for local uh file projects again much more about this on the bill and tools lecture and then this is an example so i'm not going to show you this example on on on this lecture but i highly recommend you to get to your text editor to your id or wherever you use and try to run this example and see how it's working the most important thing is that we are also using the standard output the standard input and also the standard error output from the linux system so more to come on the linux tutorial and then here i just picked you put you the example on how to run this the only difference of how we just did it is that if you check the the line here first this is the c plus plus standard so here we are specifying the compiler okay please use c plus plus um standard 2011 then this basically means please don't build this a dot out binary but rather make a hello world binary and then the only other difference is that this instead of calling it main which is called this helloworld.cpp but if you compile this program it's it's going to be the same there is also a small error on the slides so on previous year we were using clang now we're reaching gcc but it's rather not so relevant for the learning process of this course so please make sure you compile around the hello world so you get to the the first hands-on experience on c plus plus then there's always uh or i will try to always give you some video there is this fun video or rather fun video like why you should learn how to program so i would recommend you to go there and check it out and also we don't really follow any book on this course but if there's a book or any book to follow we'll be using the beyond c plus plus book that is basically the book written by c plus plus how author himself so this is basically the most relevant book biography of course there's many really good books out there but this will be probably the basic uh or the basis uh if you want to really buy a book or go for it it's not something you should buy uh with a kindle or with a ebook reader it's very a big book and with a lot of examples and information you it's more like a manual than uh like a text like a novel you read during the weekend so make sure you understand this fact about this book and then probably if you're not into much two books the best reference is cpp reference so this is nowadays the most widely used on the community online reference where you always have some sort of examples for each concept you're looking for so my recommendation would be never google stuff about c plus plus first go and check here if you have some questions or something or some query for search you can go into cpp reference and try to search even manually what you're looking for because the explanations there are usually great it will give you the concept right away they are super short and self-contained so it's much easier for you to understand than going through to a random stack overflow question with probably a wrong answer and then that's these are the reference for for this lecture and uh thank you very much for your attention keep in mind that next week we're going to be using the watching the villain tools uh lecture and homeworks assignment will be released after this week so i hope you enjoyed the lesson and thank you for staying with me and until the end and i hope you also enjoy the new video infrastructure we just built for you to make the learning process even more fun thank you very much
Info
Channel: Cyrill Stachniss
Views: 3,719
Rating: undefined out of 5
Keywords: robotics, photogrammetry
Id: NEBRJth_NXE
Channel Id: undefined
Length: 39min 47sec (2387 seconds)
Published: Mon Oct 18 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.