Some students come to CS field but they have no idea about any programming language. Either they will have the background of engineering or medical. But still they want to make CS their field. What technique should be applied on them to take start, clear their initial concepts and make ready them how to code any program?
-
1$\begingroup$ Are you required to teach C++? Or can you choose a language that is more "friendly" to beginners? $\endgroup$– BuffyApr 22, 2019 at 10:27
-
$\begingroup$ I don't mean to sound like a know-it-all or come across as someone who's full of themselves but the basics of C++ aren't actually all that hard. $\endgroup$– MalekaiApr 22, 2019 at 11:05
-
1$\begingroup$ @LogicalBranch, ah, if only the basics were sufficient. $\endgroup$– BuffyApr 22, 2019 at 11:08
-
$\begingroup$ @Buffy Now, I never said anything about null pointers, segfaults or the hell hole that is memory management. $\endgroup$– MalekaiApr 22, 2019 at 11:11
-
$\begingroup$ @LogicalBranch, C and C++ programmers do it on the heap. $\endgroup$– BuffyApr 22, 2019 at 11:20
4 Answers
There are many ways to do this, they basically rely on the "culture" of students and the purpose that they should learn. C++ is a multiple model and not "pure" in any of them, so... Teaching language and realism is a process: start with some courses before the process: Make them know about the two, compilers, etc. do not go into detail, but tell the path to learn. Avoid the IDE: Use the command-line editor. You can insert the IDE later. But always give a wide look. Variables, and jobs must run ads together. Study Module C++ and indicators "problem combo", consider: string "base type", with Device: Table, Composite: Products and Model style: Map. Presenting the template as soon as possible, and teaching the context recursion. Also show recursion in specialization. Introducing the concept of "recollected" "Position indicator".
While I would suggest a different language for beginners, I'll take it as given here that the students need to learn C++ and not just programming for general use.
In that case, teach them Modern C++. That means C++ versions 14 and 17 and don't bother with anything earlier. To do this find a good book that focuses on those versions (or later if you are reading this in the future) and has been developed by someone who has good knowledge of pedagogy as well as the language. There are a couple of books available on Amazon that meet this criteria.
Note that you give up nothing by starting with the current version. The book will still cover the low level details that were inherited from C and that are still useful. You won't spend time trying to learn the things that have become obsolete for modern software development.
But, the important point is that a modern language comes with a set of idioms that enable its proper use. A language is not just a collection of features that you combine arbitrarily. It was designed with a vision.
So, once you get beyond trivial programs, you want to learn the current idiomatic usage of the language (whatever it is) along with the lower level details. In particular, you don't want to spend time on the idiomatic usage of an earlier version of the language once they have become obsolete.
I will also note that programming in a language requires the programmer to adopt some mental model. If a language is well designed, then it is possible to program completely within that model without worrying about how that model is implemented in some lower level model. That is to say, the model will be both consistent and complete. So, a book with good pedagogy will emphasize how you use that model to create useful artifacts.
The advantage of Modern C++ is that many of the pitfalls of earlier versions (and especially those of C) have been removed through the use of standard libraries. Lots of the kinds of errors that seem invariably to creep into commercial software don't occur at all (and so fewer viruses,...) if the programmer understands the libraries and the proper idiomatic use.
There is no need to take an historical approach to computing, starting with machine level programming and working UP to some higher level. That was my approach, actually, since I grew up with that history and have been programming for over 45 years. I didn't then use the languages that I use today since they didn't exist, not because it was better, in some way, for me to use primitive languages first.
Note that if a language does not provide a complete and consistent abstraction model for programming (if it isn't Turing Complete) then you would have to try to understand its features in terms of some lower level implementation mode. Otherwise you can learn the language directly and understand how the parts fit together idiomatically to write any program using a single mental model.
If you, as an individual want to learn everything bottom up, then go ahead. But if you are a teacher, I suggest that you don't impose that way of learning on your students. It is inefficient and unnecessary.
Once the students learn to program at a given (complete and consistent) level of abstraction they can then learn about how things are built or use them to build higher level abstractions.
If I had a choice of first teaching language today, it would probably be either Haskell (functional) or Scala (Object oriented). Both of these offer complete and consistent mental (abstraction) models as well as rich libraries. The teaching method would be to teach the idiomatic usage, not just the features. There are others that would serve equally well. The mental model needs to be taught along with the language. That is a pedagogical issue.
However for someone with less background in language principles and in programming pedagogy, I'd probably rather recommend Python or Java, just because of the wealth of teaching materials available, combined with a rational abstraction model. Creating good teaching materials in any language is hard work.
I'll also note here that many people have the experience that the second language they learn is the hardest, especially if it is either quite similar or quite different. That is due to the fact that your first language teaches you (you believe) how to program, so, the new language feels awkward and one tries to apply the idioms of the old language to the new one. It won't work. Even languages as close as Java and Ruby have different idioms.
-
$\begingroup$ Haskell as a first language is an insane approach. It’s probably older than C. So it’s not clear to me why would you suggest it after promoting modern C++. The same goes for scala which also quite old and impossible to debug. Both would be a nightmare to start with and certainly teach very bad habits. You can see this on folks who started with Java, a lot of them write wasteful and inefficient code $\endgroup$ Apr 23, 2019 at 12:22
-
$\begingroup$ Hmmm @Aksakal, so the age of the language is determinative? A lot of C programmer write extremely dangerous code. What is your point, exactly? $\endgroup$– BuffyApr 23, 2019 at 12:26
-
1$\begingroup$ Do I infer correctly that you believe the the only worthy goal is to become a skilled C programmer? Sorry if my disagreement with that stance offends you so deeply. I like Haskell for what it is and for the mental model it engenders. I might have said Scheme, actually, but personally prefer languages with more syntax as a guide to the student. I know I can't convince you. I'm not trying, actually. $\endgroup$– BuffyApr 23, 2019 at 13:18
-
1$\begingroup$ @Aksakal, it only takes 30 seconds on Wikipedia to find out when Haskell dates from, so why not invest that effort before spouting inaccurate guesses? Also, FWIW, Cambridge University's first teaching language is SML, which is not entirely dissimilar to Haskell. $\endgroup$ Apr 24, 2019 at 8:53
-
2$\begingroup$ Errr, @Aksakal, have you seen a bad programmer that started with C? Give it up and let your answer stand on its own. $\endgroup$– BuffyApr 24, 2019 at 11:45
I would make it hands on and C-based, with very little OOP in the beginning. You can code in C++ using it as a "better" C. You'd introduce classes by the way without making a big deal of OO stuff. I'd focus on I/O, data structures, particularly, containers such as lists and arrays, and algorithms such as search and sorting.
Maybe write simple utilities, e.g. renaming files in the directory using wild cards. Building pipes like in Unix tools, e.g. write on program that reads from input stream and replaces special characters with spaces, then output result into output stream. Then write another program that reads IOS and counts words, then outputs. Then you make a silly pipe out of these two etc. This type of exercise packs a lot of different concepts together and can make things interesting to non CS students. This stuff will easily fill the semester.
-
$\begingroup$ Unfortunately, this will instill lots of bad habits in programmers destined to be C++ programmers. You really want to avoid that. Don't teach things that need to be un-learned later. This goes beyond just heap management, actually. $\endgroup$– BuffyApr 22, 2019 at 16:34
-
1$\begingroup$ @Buffy, the reason I'm proposing to start with C is because it's simple enough to not distract from the objective of the first programming class: learn data structures and algorithms. for instance, you learn an array in its most basic form, closest to how it's implemented in hardware. you can focus on the essence of programming with C. also, starting close to hardware and OS helps in future development of a programmer in my opinion. $\endgroup$ Apr 22, 2019 at 20:20
-
1$\begingroup$ @ScottRowe, it's actually not my idea. I believe it was one of the C inventors who said that the success of C was due to it being close enough to hardware and OS architecture, to how things actually work in a computer. I learned C++ when it was a pre-processor for C compiler, not a real compiler, but don't code in it a lot these days. It's a great and powerful language, too rich to get into all its paradigms at once when first learning it. So sticking to its core C is a sound way to start its exploration $\endgroup$ Apr 23, 2019 at 1:54
-
1$\begingroup$ @Aksakal The Linux kernel is written in C, but definitely not by beginners. What chefs do in the kitchen of 4 stars hotels is not relevant when learning to cook spaghettis first time. Using C is a PITA for beginners when it comes to handling even basic things as character strings (try with utf-8...) $\endgroup$ Apr 24, 2019 at 12:22
-
1$\begingroup$ @MichelBillaud, I don't know what would be my choice for the very first programming language these days. OP is not asking about it. OP wants to teach C++ for some reason, and all I'm suggesting is to start with "better C" part of C++, the multi-paradigm language. Linus started with BASIC, not Visual Basic. BASIC used to come with all computers such as Commodor, and was something like C to Unix, i.e. it was very close to hardware architecture. You could read/write directly into memory, for instance. I started with stack languages in machine codes, but wouldn't recommend it today $\endgroup$ Apr 24, 2019 at 19:11
Arduino, it's full C++ 2011 underneath the "Arduino Language". What they call "libraries" are classes. The physical computing aspect is a good way to keep interest.
-
$\begingroup$ Hi! What you say is true, but it's unclear how this answers the question. If you include explanations relevant to teaching (for example: how one can use arduino to teach), it would greatly improve the answer. $\endgroup$– ItamarG3May 26, 2019 at 16:04