How to Spot a Bad C++ Course/Book/Tutorial?
Learning programming in the C++ language is as easy as in any other language. But learning from a bad tutorial or book is extremely hard. C++ programming apprentices run a real risk of stumbling upon an inappropriate course or learning materials. These inadequate courses and learning materials cannot be identified by beginners unless they are given some clear guidelines.
The fact that various programming books, courses and online instructions are of different quality should not really surprise anyone. The quality does vary substantially, and the differences are even more pronounced for a language like C++, which is extremely extensive in scope and size.
Of course, every person would like to learn only from the highest quality sources. But how can a beginner discern whether a programming tutorial or course is of high or low quality? In many cases and in many different fields of study, a beginner cannot make this distinction, but when we are talking about a beginner’s course of the C++ language, the situation might be slightly different.
Again, this has something to do with size and scope of the C++ language. Many beginners get the impression that C++ is a hard to learn language, but that is not really true. Learning the entire C++ language would be extremely hard, because it is such a big language. However, it is much easier to learn programming basics in C++ than in C. Why? Well, all the features added in the C++ language are there to make programming easier, not to make it harder. Adding a feature to a programming language to make it harder would obviously be insane, and no serious language designer has ever done such a thing.
The size of C++ exposes a way to spot bad instructors and bad books. In many cases, bad instructors get lost in all the features offered by C++, and they use those features in an inappropriate way or they teach them in the wrong order. This quality is almost unique to C++, as other languages are either much smaller in scope or they lack features with overlapping functionality by design.
So, what are those telltale signs of bad instructions that even a beginner can spot? Let’s analyze them one by one.
Explaining C-style Arrays Before std::vector
Every beginner can easily spot this error even before he/she starts to attend a course and before he/she starts to read a book. It is sufficient to take a look at the table of contents and find the first mention of arrays or vectors. Be aware that some instructors will explain std::vector under the name ‘arrays’, so it is necessary to ascertain what the actual content is. Go to the first chapter that mentions arrays or vectors and quickly skim through it. If this chapter is not about std::vector, than it is about C-style arrays, and that would be a very, very bad thing.
In 99.9% of cases, this is an instructor’s error in ordering of topics. In most cases, it is also an error of good programming style.
Firstly, you need to understand why this error happens. The C programming language doesn’t have std::vector, only plain arrays. Historically, C++ started in the 1980s, but it got std::vector only in 1998. Some instructors have become used to C-style arrays. Some have old materials and they don’t want to update them. Whatever the reason, such materials and courses are severely outdated.
This is not to say that C-style arrays are useless. C-style arrays have many legitimate uses and they are used widely. However, that is not the issue. The issue is, should you explain C-style arrays first or std::vector first when you’re teaching programming to beginners. There is no question that std::vector should be explained first because it solves many problems that beginners will encounter with C-style arrays, like array size, copying, bounds-checking and so on. It makes programming safer and easier.
Some instructors will attempt to defend their choice of using C-style arrays with various excuses and rationalizations which can confuse a beginner, but can’t stand up to serious scrutiny.
What is more concerning is the issue of quality of a book or course that includes this grave error, as it is an indication of a serious problem. It would be wise to switch to another book or course in such a case.
Explaining Pointers too Early
The hardest part of learning programming is to learn the specific way of thinking which can be called algorithmic thinking. Like that wasn’t hard enough, some instructors like to mix it in with various low-level issues which tend to be highly confusing and completely unnecessary at this stage. Pointers are one such issue.
In the C language, the pointers were ubiquitous. In the C++ language, they are necessary in many cases. For beginners, the pointers are usually not necessary and are best avoided.
All the beginner’s topics can be explained without pointers. Name it: flow control, arrays, functions, algorithms, graphics, structures, classes, generic programming, files, recursion and polymorphism. Even linked lists, trees and graphs can be explained without pointers, albeit with some slight additional complications (which are no deal-breakers).
When does a beginner first need to learn pointers? He will need pointers when he needs to use a library which uses pointers. A beginner should also learn pointers when he needs to learn more about the internal workings of a computer, which is not a beginner’s topic, neither are libraries with pointers.
It would be justified to introduce pointers earlier in a book which is intended for programmers that already know another programming language, and they just want to learn an additional language. It is not justified in a book intended for almost complete beginners.
Beginner’s programming courses should be using the highest abstraction level possible. The level of abstraction is approximately opposite of the level of detail. At the lowest level, the discussion is about hardware, memory, pointers, CPU, registers. On a higher level, it is language syntax, language semantics, language standard, execution model, execution speed, and lots of rules. On the highest level, there are algorithms, practical issues, problem solving, program organization. Low level issues are just confusing for beginners and are a complete waste of time. If low-level issues were not a problem, then people would be learning programming in assembly language.
In comparison: if you were learning to drive a car, thinking about 4-cylinder engines and the Otto cycle would not make things any easier (even if you were going to be a mechanic)
In conclusion, the later the pointers are explained, the higher the probability that you are learning C++ the right way. How late should it be? Here are some rules of thumb: explaining pointers before vectors (arrays) is extremely bad, explaining pointers before functions is bad. The pointers should not be explained in detail before structures.
Not Explaining or Not Using a Debugger
The ability to pause programs during their execution and to examine the state of a program in complete detail is very helpful in teaching programming. Even more so, the C++ language ecosystem is awash with amazing tools including the best visual debuggers available. Why would someone not use such a tool?
One teacher once said to me: I don’t explain debuggers because I don’t use one, and the great programmer XY didn’t use a debugger either. Well, I know of some great runners who don’t use shoes (they are from Africa). But I wouldn’t recommend anyone to go running without shoes.
When looking at various C++ beginner question and answer sites, it is easy to figure out beginners who don’t use a debugger, because most questions posted would be easily solved if a debugger was used. The best debuggers have visual interfaces which are extremely simple to use, so it is impossible to complain that a debugger is hard to use or to understand.
If a book doesn’t mention a debugger, there is something wrong with it. If you are attending a course, ask your instructor which debugger you will be using, just to see his response.
Learn Computer Programming in 1 Hour a Day
…and give up after 30 days. When you have a programming problem that requires some thinking, you might stumble upon a solution in five minutes, or you might need a few hours. Or you might ask for help on an Internet forum. Perhaps you need to think about it for a few hours straight, or you might need to rest for a day or two.
Introductory programming courses take about 100 hours of instruction with guided exercises, and to that number you should add about 200 hours of practicing. At one hour a day you will complete such a course in approximately 10 months, if you don’t give up way before. Learning for 1 hour a day is just too slow (you will forget too many things). This entire 'one hour a day' is just a marketing gimmick designed to give you an illusion that there is a quick road to success.
Perhaps you should try to learn programming in one month? Well, that turns out into 10 hours a day, each day, for a month. It’s on the boundary of possible, if you have one completely free month and lots of energy to keep up such a crazy pace, but I wouldn’t recommend it.
The truth is, you either like programming or you don’t. If you like it, you will be curious about the problems to solve. Perhaps, in the very beginning, the problems are too simplistic to arouse curiosity, but once you get to vectors (arrays), things should change. When you are curious about a problem, it will keep bugging you until you have solved it, and you won’t limit yourself to 1 hour a day.
The fun will never end! Programming is such a vast field that there is an endless number of problems waiting for you to study, if you are interested. It’s something like a puzzle, but much better.
Programming books that advertise any kind of fast road to success are just not being honest, and you should really stay away from dishonest people. Learn programming slowly, at a pace that suits you best. Think of it more like a hobby. You should do it when you have time and when you feel like it, not for 1 hour a day.
Modern C++ is an elegant language, extremely suitable for an introductory programming course. But a modern language does not equal a modern course. Some data suggests that over half of C++ courses and materials are badly outdated or use outdated teaching methods.
C++ programming apprentices run a real risk of stumbling upon an inappropriate course or inappropriate learning materials. The inadequate courses and learning materials cannot be identified by beginners unless they are given some clear guidelines about this issue.
C++ is a huge language which is constantly evolving. Many instructors are unable to handle this complexity and they get lost in the vast number of features offered by C++. Some instructors get stuck on older features of the language and are unable to apply the new features appropriately because they have learned how to do things the old way. The result is a course which might be unnecessarily taxing for beginners.
The features of the C++ language make it possible to teach programming on a very high level of abstraction, which is extremely desirable. The programming lessons for beginners should always keep to the highest abstraction level possible, and then slowly descend towards lower-level features. The possible level of abstraction is limited by the features of the programming language, but it can also be artificially limited by a lecturer, if he wishes to do so.
The vast number of features offered by modern C++ is unmatched by most of today’s languages. Those features provide for easier programming and easier learning. For example, operator overloading can make the syntax easier for beginners, true pass-by-value provides a uniform execution model devoid of side-effects, static type checking helps beginners to find many of their errors easily, and the ability to create new types with custom conversion rules and common operators can hide many complexities inherent in programming. Of course, it is unnecessary to teach all those advanced features to beginners, but those features can easily be employed to provide for enhanced learning, with beginners not even being aware of them.
C++ is an excellent programming language for beginners if it is used in the right manner. Due to its long history and ever-changing nature, its abilities are often misused by instructors, more often than it would be desirable.