Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Debunking C++ Myths

You're reading from   Debunking C++ Myths Embark on an insightful journey to uncover the truths behind popular C++ myths and misconceptions

Arrow left icon
Product type Paperback
Published in Dec 2024
Publisher Packt
ISBN-13 9781835884782
Length 226 pages
Edition 1st Edition
Arrow right icon
Authors (2):
Arrow left icon
Ferenc Deak Ferenc Deak
Author Profile Icon Ferenc Deak
Ferenc Deak
Alexandru Bolboaca Alexandru Bolboaca
Author Profile Icon Alexandru Bolboaca
Alexandru Bolboaca
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Chapter 1: C++ Is Very Difficult to Learn 2. Chapter 2: Every C++ Program Is Standard-Compliant FREE CHAPTER 3. Chapter 3: There’s a Single C++, and It Is Object-Oriented 4. Chapter 4: The Main() Function is the Entry Point to Your Application 5. Chapter 5: In a C++ Class, Order Must There Be 6. Chapter 6: C++ Is Not Memory-Safe 7. Chapter 7: There’s No Simple Way to Do Parallelism and Concurrency in C++ 8. Chapter 8: The Fastest C++ Code is Inline Assembly 9. Chapter 9: C++ Is Beautiful 10. Chapter 10: There Are No Libraries For Modern Programming in C++ 11. Chapter 11: C++ Is Backward Compatible ...Even with C 12. Chapter 12: Rust Will Replace C++ 13. Index 14. Other Books You May Enjoy

The Kate Gregory method – don’t teach C

In a talk at CppCon 2015 (https://www.youtube.com/watch?v=YnWhqhNdYyk), Kate Gregory makes the point that C is not a prerequisite for learning C++ and that it’s actively harming the learning process to start by teaching printf, naked arrays, and char pointers on the first day of a beginner C++ course.

Instead, her proposal is to start with the objects available in STL. The string and vector classes are quite clear to beginners, and operator overloading is also a very natural way to use these objects. Beginners expect that "abcd" + "efg" will result in "abcdefg"; there’s no need to explain the intricacies of operator overloading so that they can write simple programs. Moreover, this approach completely avoids discussing destructors and memory cleanup.

She continues by arguing that teaching lambdas to beginners is also quite easy if you start with an example. Consider trying to find a value in a vector. A first approach would be using a for loop that you can skim over. The second method is using std::find. But what if we want to find an even value in a vector<int> instance? This introduces lambdas very naturally in the conversation, without a whole discussion on all the possible ways to write them.

With this method, she argues that beginners will be able to use existing libraries. They will have some gaps in their knowledge, and in the case of a course for programmers working on a specific code base, you might need to have a section that introduces them to reading specific idioms useful for their work. And if you want these programmers to become library creators, then you need a more advanced course that dives into the depths of memory management and optimizations possible with pointers.

My 15 years of experience training people in complex skills tell me that this teaching method is very good. A key thing in training is to understand your target audience and do your best to avoid the curse of knowledge – the fact that you don’t remember how it was not to know something you know very well today. This method caters to the beginner mind by providing fast wins and good progression and giving the learners the courage to write code. So, it’s definitely an improvement in the methods of learning C++.

However, this is not the only way to learn a language. It’s a structured way, yes, but exploration is an important part of learning. There’s a way to learn C++ through exploration that uses a method typically associated with Twitter clashes: Test Driven Development (TDD).

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image