title
Safety in modern C++ and how to teach it

description
Patreon ► https://patreon.com/thecherno Twitter ► https://twitter.com/thecherno Instagram ► https://instagram.com/thecherno Discord ► https://thecherno.com/discord Series Playlist ► https://thecherno.com/cpp Thank you to the following Patreon supporters: - Dominic Pace - Kevin Gregory Agwaze - Sébastien Bervoets - Tobias Humig - Peter Siegmund - Kerem Demirer Gear I use: ----------------- BEST laptop for programming! ► http://geni.us/pakTES My FAVOURITE keyboard for programming! ► http://geni.us/zNhB FAVOURITE monitors for programming! ► http://geni.us/Ig6KBq MAIN Camera ► http://geni.us/t6xyDRO MAIN Lens ► http://geni.us/xGoDWT Second Camera ► http://geni.us/CYUQ Microphone ► http://geni.us/wqO6g7K

detail
{'title': 'Safety in modern C++ and how to teach it', 'heatmap': [{'end': 530.407, 'start': 513.518, 'weight': 0.755}, {'end': 557.584, 'start': 542.509, 'weight': 0.95}, {'end': 603.19, 'start': 573.957, 'weight': 0.89}], 'summary': 'Discusses the ongoing debate about modern c++ safety, focusing on raw pointers and smart pointers to provide clarity to new learners. it also covers safe programming in c++, emphasizing the shift towards smart pointers in c++11 to reduce memory-related issues and the significance of automating memory deallocation through smart pointers.', 'chapters': [{'end': 119.566, 'segs': [{'end': 60.003, 'src': 'embed', 'start': 22.889, 'weight': 0, 'content': [{'end': 25.373, 'text': 'with all the various projects and this series,', 'start': 22.889, 'duration': 2.484}, {'end': 34.165, 'text': 'I feel like more and more people are kind of a little bit confused about what the correct way to write C++ is and like Just.', 'start': 25.373, 'duration': 8.792}, {'end': 42.656, 'text': "there's been so much debate on my Discord on Reddit everywhere about just in general like how to write C++ in the modern day,", 'start': 34.165, 'duration': 8.491}, {'end': 47.062, 'text': "because there's all these people, of course, who are saying that modern C++ is all you should be using.", 'start': 42.656, 'duration': 4.406}, {'end': 50.286, 'text': "You shouldn't be touching things like pointers, like raw pointers at all, ever.", 'start': 47.102, 'duration': 3.184}, {'end': 51.628, 'text': "You don't even have to teach that.", 'start': 50.607, 'duration': 1.021}, {'end': 55.082, 'text': "because it's not even worth knowing because it's very bad.", 'start': 52.702, 'duration': 2.38}, {'end': 56.563, 'text': "But then there's the flip side of things.", 'start': 55.102, 'duration': 1.461}, {'end': 59.503, 'text': 'People are saying smart pointers are terrible.', 'start': 56.623, 'duration': 2.88}, {'end': 60.003, 'text': "Don't use them.", 'start': 59.543, 'duration': 0.46}], 'summary': 'Debate on modern c++ usage: conflicting views on raw pointers and smart pointers.', 'duration': 37.114, 'max_score': 22.889, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD422889.jpg'}, {'end': 127.752, 'src': 'embed', 'start': 99.874, 'weight': 2, 'content': [{'end': 104.776, 'text': 'I really want to know what this community that watches my videos actually thinks.', 'start': 99.874, 'duration': 4.902}, {'end': 109.739, 'text': 'Furthermore, I do have a discord, thechannel.com slash discord is the link to that discord.', 'start': 105.396, 'duration': 4.343}, {'end': 113.101, 'text': "So it'll be somewhere on the screen and in the description below as well.", 'start': 110.119, 'duration': 2.982}, {'end': 116.664, 'text': "So definitely check that out, because that's a whole.", 'start': 113.422, 'duration': 3.242}, {'end': 119.566, 'text': "I think there's like over three and a half thousand members on that discord,", 'start': 116.664, 'duration': 2.902}, {'end': 124.369, 'text': 'and we talk about C++ and graphics and game engines and everything all the time.', 'start': 119.566, 'duration': 4.803}, {'end': 127.752, 'text': "And lately I've been kind of more active on that as well.", 'start': 125.29, 'duration': 2.462}], 'summary': 'Creator seeks feedback from community, with 3.5k+ members on discord.', 'duration': 27.878, 'max_score': 99.874, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD499874.jpg'}], 'start': 0.169, 'title': 'Debate on modern c++ safety', 'summary': 'Discusses the ongoing debate about modern c++ and safety, focusing on raw pointers and smart pointers, to provide clarity to new c++ learners and the community.', 'chapters': [{'end': 119.566, 'start': 0.169, 'title': 'Debate on modern c++ safety', 'summary': 'Discusses the ongoing debate about modern c++ and safety, particularly the use of raw pointers and smart pointers, aiming to provide clarity to new c++ learners and the community.', 'duration': 119.397, 'highlights': ['The ongoing debate about modern C++ and safety, particularly the use of raw pointers and smart pointers There is a continuous debate regarding the use of raw pointers and smart pointers in modern C++, leading to confusion among learners and the community.', 'The discussion aims to provide clarity to new C++ learners and the community The discussion seeks to offer understanding and guidance to individuals new to C++ and the community regarding the best practices and choices in C++ programming.', 'The channel encourages participation from the community through comments and promotes the Discord community with over three and a half thousand members The channel actively seeks input from the community by encouraging comments and promoting participation in the Discord community, which boasts over three and a half thousand members.']}], 'duration': 119.397, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4169.jpg', 'highlights': ['The discussion aims to provide clarity to new C++ learners and the community', 'The ongoing debate about modern C++ and safety, particularly the use of raw pointers and smart pointers', 'The channel encourages participation from the community through comments and promotes the Discord community with over three and a half thousand members']}, {'end': 419.848, 'segs': [{'end': 173.736, 'src': 'embed', 'start': 146.209, 'weight': 0, 'content': [{'end': 149.891, 'text': 'I feel like the human race has kind of been improving on as time goes on.', 'start': 146.209, 'duration': 3.682}, {'end': 161.256, 'text': 'So, with kind of the introduction of C++11, we started to, I would say, move towards concepts such as smart pointers in favor of raw pointers,', 'start': 150.051, 'duration': 11.205}, {'end': 170.04, 'text': 'primarily because of the whole issue of having memory leaks, as well as not knowing what memory has actually been allocated or freed.', 'start': 161.256, 'duration': 8.784}, {'end': 173.736, 'text': 'because really all of this can be summarized into a simple problem.', 'start': 171.135, 'duration': 2.601}], 'summary': 'Advancement in c++11 led to adoption of smart pointers to address memory leak issues.', 'duration': 27.527, 'max_score': 146.209, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4146209.jpg'}, {'end': 265.957, 'src': 'embed', 'start': 240.069, 'weight': 2, 'content': [{'end': 250.412, 'text': 'Smart pointers and kind of automatic memory management systems exist to make make programmers lives easier, and not just easier but more robust.', 'start': 240.069, 'duration': 10.343}, {'end': 257.795, 'text': "meaning that you don't you know, it's not about the fact that you don't have to deal with certain things anymore because they're automated.", 'start': 250.412, 'duration': 7.383}, {'end': 265.957, 'text': "it's also, when you forget to deal with with certain things, you are fine because it's handled for you automatically.", 'start': 257.795, 'duration': 8.162}], 'summary': 'Smart pointers and automatic memory management enhance ease and robustness for programmers.', 'duration': 25.888, 'max_score': 240.069, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4240069.jpg'}], 'start': 119.566, 'title': 'Safe programming in c++', 'summary': 'Discusses safe programming in c++, highlighting the shift towards smart pointers in c++11 to reduce memory-related issues like crashes, memory leaks, and access violations, and its tie to automation to reduce human error. it also covers memory allocation, the problems of memory leaks and ownership in programming, and the need for smart pointers to handle memory management effectively and avoid complications.', 'chapters': [{'end': 239.789, 'start': 119.566, 'title': 'Safe programming in c++', 'summary': 'Discusses the concept of safe programming in c++, emphasizing the shift towards smart pointers in c++11 to reduce memory-related issues like crashes, memory leaks, and access violations, and its tie to automation to reduce human error.', 'duration': 120.223, 'highlights': ['The shift towards smart pointers in C++11 aims to reduce memory-related issues like crashes, memory leaks, and access violations, as well as to automate memory allocation to minimize human error.', 'The introduction of C++11 led to a movement towards concepts such as smart pointers in favor of raw pointers, primarily due to issues with memory leaks and uncertainty about allocated or freed memory.', 'The complexity of allocating memory on the heap has led to the development of constructs and systems to automate memory allocation and minimize human error, emphasizing the tie between safe programming and reducing human error.', 'The chapter addresses the concept of safe programming in C++, focusing specifically on pointers and memory management, with an emphasis on the shift towards smart pointers to automate memory allocation and reduce human error.']}, {'end': 419.848, 'start': 240.069, 'title': 'Smart pointers and memory management', 'summary': 'Discusses the concept of memory allocation, the problems of memory leaks and ownership in programming, and the need for smart pointers to handle memory management effectively and avoid complications.', 'duration': 179.779, 'highlights': ['Smart pointers and automatic memory management systems make programming more robust and handle memory allocation automatically. This highlights the purpose of smart pointers in making programming robust and automating memory management.', 'The problems of forgetting to deal with memory and the issue of ownership in memory allocation can lead to memory leaks and complex programming scenarios. This emphasizes the negative impact of forgetting to manage memory and the complexities arising from ownership in memory allocation.', 'The solution to memory deallocation problems involves being more attentive when programming, which can be challenging for some programmers. This highlights the potential solution of being more attentive while programming to avoid memory deallocation issues, acknowledging the challenge in implementing this solution.']}], 'duration': 300.282, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4119566.jpg', 'highlights': ['The shift towards smart pointers in C++11 aims to reduce memory-related issues like crashes, memory leaks, and access violations, as well as to automate memory allocation to minimize human error.', 'The introduction of C++11 led to a movement towards concepts such as smart pointers in favor of raw pointers, primarily due to issues with memory leaks and uncertainty about allocated or freed memory.', 'Smart pointers and automatic memory management systems make programming more robust and handle memory allocation automatically. This highlights the purpose of smart pointers in making programming robust and automating memory management.', 'The complexity of allocating memory on the heap has led to the development of constructs and systems to automate memory allocation and minimize human error, emphasizing the tie between safe programming and reducing human error.']}, {'end': 1054.082, 'segs': [{'end': 483.342, 'src': 'embed', 'start': 454.167, 'weight': 5, 'content': [{'end': 455.488, 'text': "they're going to probably screw things up.", 'start': 454.167, 'duration': 1.321}, {'end': 465.028, 'text': 'OK, so those are kind of the two big issues and the reason why we kind of want to automate the deletion of memory.', 'start': 456.542, 'duration': 8.486}, {'end': 471.073, 'text': 'But really, when we talk about safety in C++ and specifically all of this smart pointer stuff,', 'start': 465.329, 'duration': 5.744}, {'end': 476.917, 'text': 'we are specifically just automating one simple line of code and that is the deletion of memory, the freeing of memory.', 'start': 471.073, 'duration': 5.844}, {'end': 478.558, 'text': "That is the only thing we're dealing with.", 'start': 477.257, 'duration': 1.301}, {'end': 481.62, 'text': 'OK, primarily in two ways.', 'start': 478.959, 'duration': 2.661}, {'end': 483.342, 'text': 'And again, the smart pointers video covers all of this.', 'start': 481.661, 'duration': 1.681}], 'summary': 'Automating deletion of memory in c++ for safety, covered in smart pointers video.', 'duration': 29.175, 'max_score': 454.167, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4454167.jpg'}, {'end': 542.169, 'src': 'heatmap', 'start': 513.518, 'weight': 1, 'content': [{'end': 517.302, 'text': 'In any time right, in any kind of realm.', 'start': 513.518, 'duration': 3.784}, {'end': 521.605, 'text': 'it is good to automate a lot of things in programming right?', 'start': 517.302, 'duration': 4.303}, {'end': 524.806, 'text': 'Specifically the kind of freeing of memory,', 'start': 521.645, 'duration': 3.161}, {'end': 530.407, 'text': 'because it seemed to be such a fragile and pedantic kind of operation that people just screw up all the time right?', 'start': 524.806, 'duration': 5.601}, {'end': 532.847, 'text': 'So yes, smart pointers are really good.', 'start': 530.727, 'duration': 2.12}, {'end': 535.148, 'text': 'You should 100% use smart pointers.', 'start': 532.967, 'duration': 2.181}, {'end': 538.569, 'text': 'Never in my life would I say, you know, raw pointers only.', 'start': 535.588, 'duration': 2.981}, {'end': 542.169, 'text': "That's stupid, okay? I think everyone agrees that that's stupid.", 'start': 538.829, 'duration': 3.34}], 'summary': 'Automating memory management using smart pointers is essential for robust programming. raw pointers are considered impractical.', 'duration': 28.651, 'max_score': 513.518, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4513518.jpg'}, {'end': 568.171, 'src': 'heatmap', 'start': 542.509, 'weight': 0.95, 'content': [{'end': 548.098, 'text': "Not using the C++ standard kind of library smart pointers you know, that's fine.", 'start': 542.509, 'duration': 5.589}, {'end': 551.34, 'text': 'Some people may choose to write their own right?', 'start': 548.838, 'duration': 2.502}, {'end': 557.584, 'text': 'Whether that just be a scope-based pointer, which is the equivalent of like STD unique pointer, or whether that be like a reference counting system,', 'start': 551.38, 'duration': 6.204}, {'end': 560.106, 'text': 'which is basically the equivalent of an STD shared pointer.', 'start': 557.584, 'duration': 2.522}, {'end': 563.588, 'text': "That's fine, right? And then you can introduce concepts like weak references.", 'start': 560.426, 'duration': 3.162}, {'end': 565.589, 'text': "That's also fine, right? Or weak pointers.", 'start': 563.848, 'duration': 1.741}, {'end': 566.35, 'text': "That's fine.", 'start': 565.869, 'duration': 0.481}, {'end': 568.171, 'text': 'You can make your own constructs.', 'start': 566.97, 'duration': 1.201}], 'summary': 'Using custom smart pointers like scope-based or reference counting is acceptable in c++.', 'duration': 25.662, 'max_score': 542.509, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4542509.jpg'}, {'end': 603.19, 'src': 'heatmap', 'start': 573.957, 'weight': 0.89, 'content': [{'end': 583.546, 'text': 'or maybe try and squeeze out specific platform-specific performance constraints and concerns by writing their own system which they have 100% control of.', 'start': 573.957, 'duration': 9.589}, {'end': 585.108, 'text': 'Totally fine.', 'start': 584.007, 'duration': 1.101}, {'end': 594.341, 'text': "But if you choose to go with the 100% raw pointers strategy for your software that you're building, it's not that you're a bad programmer.", 'start': 585.548, 'duration': 8.793}, {'end': 595.943, 'text': "it's just like, why right?", 'start': 594.341, 'duration': 1.602}, {'end': 597.684, 'text': 'Like, why do that??', 'start': 596.363, 'duration': 1.321}, {'end': 598.765, 'text': "It doesn't make any sense.", 'start': 597.824, 'duration': 0.941}, {'end': 603.19, 'text': "And the thing is, I'm somewhat guilty of this as well.", 'start': 599.727, 'duration': 3.463}], 'summary': 'Encouraging avoiding 100% raw pointers strategy for software development.', 'duration': 29.233, 'max_score': 573.957, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4573957.jpg'}, {'end': 827.065, 'src': 'embed', 'start': 802.384, 'weight': 0, 'content': [{'end': 810.272, 'text': 'both maintainability and kind of reliability of code, as well as really just being able to write code freely, right?', 'start': 802.384, 'duration': 7.888}, {'end': 813.374, 'text': 'Without having to worry about when will my memory get freed?', 'start': 810.292, 'duration': 3.082}, {'end': 814.596, 'text': 'Oh no, I forgot to delete.', 'start': 813.495, 'duration': 1.101}, {'end': 818.819, 'text': "Oh no, what happens if I stop passing this pointer around? I'm going to lose ownership of it.", 'start': 814.936, 'duration': 3.883}, {'end': 823.303, 'text': 'All of that is solved with smart pointers, mostly right?', 'start': 819.921, 'duration': 3.382}, {'end': 827.065, 'text': 'Maybe threading issues and other kind of things might be solved, because, of course,', 'start': 823.363, 'duration': 3.702}], 'summary': 'Smart pointers solve memory management and ownership issues, ensuring maintainability and reliability of code.', 'duration': 24.681, 'max_score': 802.384, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4802384.jpg'}, {'end': 873.988, 'src': 'embed', 'start': 845.874, 'weight': 3, 'content': [{'end': 850.296, 'text': "We will definitely be using smart pointers as we get into more serious code, don't get me wrong.", 'start': 845.874, 'duration': 4.422}, {'end': 856.559, 'text': "It's just that at the stage of learning C++, I firmly believe that you need to know what a raw pointer is.", 'start': 850.716, 'duration': 5.843}, {'end': 858.3, 'text': 'You need to know how memory actually works.', 'start': 856.599, 'duration': 1.701}, {'end': 862.962, 'text': 'Why? Because smart pointers are just a wrapper on top of a raw pointer.', 'start': 858.66, 'duration': 4.302}, {'end': 864.183, 'text': "That's all they are.", 'start': 863.323, 'duration': 0.86}, {'end': 873.988, 'text': "They're additional auxiliary code around a raw pointer in order to automate things which essentially are just deletion, right, and freeing of memory.", 'start': 864.503, 'duration': 9.485}], 'summary': "Understanding raw pointers is crucial in learning c++ to grasp smart pointers' functionality.", 'duration': 28.114, 'max_score': 845.874, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4845874.jpg'}], 'start': 420.169, 'title': 'Smart pointers in c++', 'summary': 'Explains the significance of automating memory deallocation through smart pointers in c++, emphasizing the avoidance of ownership issues, ease of implementation, and advocating for their use over raw pointers. it also highlights the importance of understanding raw pointers before using smart pointers, emphasizing the benefits of smart pointers for memory management and the necessity of understanding the underlying memory management process in c++ programming.', 'chapters': [{'end': 786.638, 'start': 420.169, 'title': 'Smart pointers in c++', 'summary': 'Explains the importance of automating memory deallocation through smart pointers in c++, emphasizing the avoidance of ownership issues and the ease of implementation, and advocates for the use of smart pointers over raw pointers.', 'duration': 366.469, 'highlights': ['The chapter emphasizes the importance of automating memory deallocation through smart pointers in C++, due to the avoidance of ownership issues and the ease of implementation. The speaker highlights the challenges of managing ownership and the potential for errors when dealing with memory deallocation, advocating for the use of smart pointers for automatic memory management.', 'The chapter advocates for the use of smart pointers over raw pointers, citing the ease of implementation and the avoidance of potential errors. The speaker asserts the superiority of smart pointers over raw pointers, emphasizing the ease of implementation and the avoidance of potential errors, particularly for new programmers joining a project.', 'The speaker acknowledges the potential use of custom pointer constructs but strongly advocates for the use of C++ standard library smart pointers. The speaker acknowledges the potential use of custom pointer constructs for specific needs or performance concerns, but strongly advocates for the use of C++ standard library smart pointers for memory management.']}, {'end': 1054.082, 'start': 786.638, 'title': 'Importance of understanding raw pointers', 'summary': 'Emphasizes the importance of understanding raw pointers before using smart pointers in c++, highlighting the benefits of smart pointers for memory management and the necessity of knowing the underlying memory management process to become proficient in c++ programming.', 'duration': 267.444, 'highlights': ['Emphasizing the Importance of Understanding Raw Pointers The speaker asserts the need to comprehend raw pointers before transitioning to smart pointers in C++ programming, highlighting the importance of understanding memory management processes for writing efficient and reliable code.', 'Benefits of Smart Pointers for Memory Management and Code Reliability and Maintainability Smart pointers are advocated for their ability to enhance code reliability, maintainability, and memory management, reducing concerns about memory deallocation, ownership, and enabling freer code writing.', 'Necessity of Understanding Memory Management Processes for Proficient C++ Programming The speaker stresses the significance of grasping the underlying memory management processes to become proficient in writing real-time, performance-critical production code in C++.']}], 'duration': 633.913, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/CWglkNBUmD4/pics/CWglkNBUmD4420169.jpg', 'highlights': ['Smart pointers in C++ automate memory deallocation, avoiding ownership issues and easing implementation.', 'Advocates for smart pointers over raw pointers, emphasizing ease of implementation and error avoidance.', 'C++ standard library smart pointers are strongly advocated for memory management over custom constructs.', 'Understanding raw pointers is crucial before transitioning to smart pointers for efficient and reliable code.', 'Smart pointers enhance code reliability, maintainability, and memory management in C++ programming.', 'Grasping memory management processes is crucial for proficient writing of performance-critical production code in C++.']}], 'highlights': ['The shift towards smart pointers in C++11 aims to reduce memory-related issues like crashes, memory leaks, and access violations, as well as to automate memory allocation to minimize human error.', 'Smart pointers and automatic memory management systems make programming more robust and handle memory allocation automatically. This highlights the purpose of smart pointers in making programming robust and automating memory management.', 'Smart pointers in C++ automate memory deallocation, avoiding ownership issues and easing implementation.', 'Advocates for smart pointers over raw pointers, emphasizing ease of implementation and error avoidance.', 'Understanding raw pointers is crucial before transitioning to smart pointers for efficient and reliable code.']}