A local college is teaching C++ to first year college students (16 years old) with no prior programming experience.
As first programming language, is C++ suitable?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this communityA local college is teaching C++ to first year college students (16 years old) with no prior programming experience.
As first programming language, is C++ suitable?
Emphatically No.
For any goal you have in mind for students, another language or sequence of languages would be faster and better. Examples.
"Students need to understand low-level concepts."
"Low-level" coding does not consist of getting objects from new
, feeding them back to delete
, and occasionally having a pointer pointing somewhere it shouldn't. Functions, classes, and templates are not low-level. RAII, 12 ways to use const
, std::ostream::operator<<
, protected
and new
are not low-level concepts. Those things have low-level implications and you're skipping those for months or until a future class and teaching mountains of C++ semantics instead.
I suggest assembler with a good environment and teaching material like MIPS or MMIX. If you're in a hurry, teach C with detours to at least look at the assembler output. This will give you all the low-level understanding C++ does, and then some, faster.
"Students need to understand object-orientation."
The object-orientation built into C++ is way overcomplicated for teaching OO concepts, or almost any other high-level concept. See The C++ FAQ for a nice, long list of potential reasons why. You either have to hit all of that stuff, which will take a very, very long time with new programmers; or else you have to skip lots of it, leaving the new programmers in the dark--effectively, not really knowing C++!
I suggest learning a simpler, high-level language with objects first (Python, Ruby, Squeak, Common Lisp, Racket), if you must teach C++ at all. Beyond that, learn polymorphism as a concept that is separate from OO by visiting a functional language.
"Students need to understand templates and template metaprogramming."
No one really asks this, but I wish they would. C++ has nice templates and STL is cool, but they just shouldn't be a high enough priority to teach C++ first. Teaching the OCaml or Haskell type system and then retrofitting those concepts might be faster anyway.
"Students need to learn problem solving."
Yeah, you get this in any language, and you get more if it in almost any language other than C++ because there's way less baggage. Again, see The C++ FAQ for a list of all the things students will be learning instead of problem-solving skills.
"All of the above, and we need to use only one language." or "Employers want it." or "We need a C-style language." or...
Teach more than one language.
The idea that you save time or energy by teaching or learning just one language is flatly ridiculous. It's based on the idea that learning any given language takes exactly X man months (HINT! HINT!) where X is a single number or one number per language. This is nearly identical to the idea that you can save time and money by skipping all that 'requirements' and 'testing' garbage.
As for multiple syntaxes, you dangerously cripple students if you teach them to expect the C syntax in every language by making them wildly biased against other languages.
Almost any path is faster and better than starting with C++. Learning a simple high-level language and then C++ would be faster. Learning assembler and then C++ would be faster. Anything other than C++ will get students there faster and they will know way more to boot. Just don't teach C++ first.
No, C++ is a difficult language even for experienced C++ developers. Even for the simplest algorithms you have to explain many of the language subtleties. Consider a Hello World example:
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
What's that #include
command? What's std::cout
. Why the ::
? What is <<
? Ohhh, it is an overloaded operator! What's an overloaded operator? Sooo, for ints
, it does bit shifting, but for whatever std::cout
is, it outputs stuff to the console. Ohhh, std::cout
is a stream, and streams have their <<
and >>
operator overloaded.
Let's see the same sample in Python:
print("Hello World!")
That's it, let's go code some algorithms.
It's probably not a good first language: complex syntax, lots of rules, old language, error-prone memory management. Better to teach your students something more OO like Smalltalk, or something nicer to program with like Python, or something functional like Haskell.
They can learn C++ later in life (if they can't help it), after they've learned better languages.
Short answer: Yes!
I would say that any language is a suitable start but especially C++ (or equivivalent). These days C# and Java are major languages in use and programming with these you quickly learn to lean on the API and IDE's but with C++ you get a chance to learn programming from the ground up, including performance optimization, etc.
It's never a bad idea to learn the basics of programming, looping and sorting before you just blindly rely on a languages built in .Sort();
Actually I believe it probably is a good choice as a first language for a very practical reason: After learning C++ any other language you encounter will seem like a breeze to learn.
I taught myself C++ when I was 15-16.
It is better to leave the magic to others and to learn the inner workings of things yourself.
Bluntly put, if you can't figure out entry-level C++ syntax and semantics, you're not that good at computers. It's not that hard. There's no good reason to avoid "C with Classes".
If you expect students to start working on template metaprogramming, deducing polymorphic calls, and untangling multiple inheritance hierarchies - that's ridiculous for an entry level class for whatever sort of language you use.
There's a very bad tendency to want to hide the intricacies of programming for students. That does not end up well( c.f. Spolsky's Java Schools essay). Those people end up on the DailyWTF if they do not get their head straight. Abstractions leak, and when (not if) the abstraction leaks, that is worse than having to deal with it. I've worked as a TA for entry level C++ students. Either things have to be hidden all the way, or they have to brought into the light to be examined. Magic is the enemy of the learner.
If I had to recommend a starting language that compiled to machine code, a Pascal variant would probably be the best approach. It has a more regular and structured approach than the C family from what I recall.
I would say 'no'- I had an eagerness and desire to learn programming, and went right into my intro year at college with C++ right off the bat. Coupled with a teacher who was teaching C++ as if it were another language (concepts that made sense to them, not necessarily concepts of the language or real world application), and projects thrown at us right away every week, I crashed and burned along with half of the class. By the time I could even digest, experiment and apply what I was being taught, I struggled with the project homework which doubled as tests. I would argue that it was more a 200 level course than 100.
I really tried my best. I didn't ask for sympathy, I knew it would be a challenge, but the teacher wouldn't even help me. Just told me to go read the textbook, as I had been doing.
I would argue (and some would disagree) that Ruby or Python is a much better language to break someone into the world of programming. Clean, concise, readable, clearer syntax.
No.
As a teaching language, C++ is only marginally better than C, which is one of the worst teaching languages around. It introduces a lot of complexity up front, some parts of the language are deeply non-intuitive, and most of the time you're learning more about C++ than about programming in general.
That's not to say that C++ (or C) are bad languages, or aren't worth learning; just that there are better teaching languages available, such as Python.
string
data type that overloads operators like +
, =
, and ==
to do things that students more-or-less expect, compared to how string processing needs to be done in C. Hence "marginally". I wouldn't recommend either as a teaching language.
Apr 5, 2012 at 18:12
There are two essential types of post-secondary education: the university and the trade school. The difference is in what you want to be prepared to do after graduation. In the automotive field, it's whether you will be a mechanic or a mechanical engineer.
That being said, C++ is a great first language if you want to be an engineer, and a lousy one if you want to be the programming equivalent of a mechanic.
An intro class on C++ is going to spend a lot of time talking about data types, definitions, declarations, pointers, memory allocation, and so forth. These are a great foundation if you intend to spend several semesters building up to being able to do anything useful, but want to know that once you get there you have the foundation to handle any degree of complexity.
On the other hand, if you want to be able to do something useful more quickly, but don't mind if the domain and complexity are limited, then spending all that time on those lower level concepts up front is going to be a waste. There are plenty of programmers who can write a great html form validator, but don't have a clue how to approach designing a device driver.
Sure. My first language was C, but that was really just to ease our class into C++. It made Java much easier to handle once I got to University. C++ might have a slightly steeper learning curve, but if it's taught properly it should be fine.
No, C++ is not suitable as a first language. As shown here, many professional programmers share this opinion, but this is also an opinion that professional teachers have.
Here is what a report from the dean of Carnegie Mellon University has to say about using C++ for an introductory course to programming for freshmen:
Standard languages such as C or C++ are not suitable for this course because their complexity and deficiencies impede both informal and mechanized reasoning techniques.
CMU offers two introductory courses, an imperative one and a functional one. SML was chosen for the functional programming. I don't know what was chosen for the imperative course, but the report mentions using a subset of C.
Sure. There are other languages that might be easier for first year students to grasp. However, there are ways that a teacher could slowly introduce concepts in C++.
Definitely C++ can be the very first language. But it's about how well it is taught.
Everyone says, the first language should be very easy to grasp. But my point is, most of the people start programming in undergraduate level. So, you can teach something they are capable to grasp. And with C++, you can go from lower level to higher level of programming.
No. Absolutely not.
If I had my way, I would disallow it's use in an academic setting almost entirely. Not for reasons that are contrary to those already made, but because too many think C++ (or it variations) is the answer for nearly every problem because you can use it in nearly any situation. It is the screwdriver of programming.
Some people use it to tighten screws, a perfectly reasonable tool for the job. Others use it like a prybar, while often effective, not really ideal because a screwdriver, no matter what your father might tell you, is not a prybar, and may catastrophically fail due to misuse because the composition of the shank isn't intentionally built for the kind of forces a prybar would encounter. Still others might try and use it as a punch or a chisel, and they will almost always encounter problems because the handle of the screwdriver wasn't built for the kind of striking abuse that punch or a chisel is designed to withstand.
In my opinion, the job of a programmer is to generally translate real problems into automation that provides some degree of improved efficiency (decrease committment of resources to a task), velocity (decrease the time to perform a task), predictability (increase the repeatability of a task), or organization (increase the awareness of relationship between tasks).
While it is understandable that everyone who programs should have some common knowledge about low level operations of computers, and specifically device IO and memory allocation, it is definately uncommon to really have to utilize that knowledge to any significant degree, let alone leverage it for the vast majority of tasks. Attempting to do so without understanding the broader context of the problem inserts uncessary risk to an effort.
It is absurd that a first programming language should be C/C++ or close variants, as the class of problems that C and its derivatives solve are certainly not apppropriate for some arbitrarily large percentage of the current and future problems (except where one has to rescue a previously, screwdrivered program), and in fact is more of a miniscule set of coming problems. Most programmers will never come close to developing core OS features or direct device interfaces, despite increasing prevelance of small mobile, interconnected devices. Most will work and live like we did. Fixing and phasing out code that is more than two generations old, implementing on technology that is already showing age, or working in the fringe of technology on the killer(x+1) app.
For a first language, I would look at Lego NXT, a light duty but highly feature rich variant of LabView. While Lego NXT is not used widely in commercial ventures, it will present the fundamental nature of what it is to program in a "sensor rich" way. I might pair it with a somewhat platform neutral scripting language like Javascript or TCL/TK. Both would be relatively low impact in terms of what you have to discover to do very basic but effective tasks, with high return in terms of the feedback loop and flexability to introduce and solve varying degrees of problem complexity. Plus, it provides a good opportunity for students as they advance to explore the potential for exceeding what is provided in the canned environment: a chance to try working in the dark, damp, low-level places of device IO and custom drivers with a small amount of overhead.
After they learn to drive the four cylinder automatic, then step them up into the big v8 manual hotrod, if they are really interested and motivated. If Joel can't find the rock-star programmers under any stone beneath his feet, he just may have to keep looking somewhere else, or rethink why he may need more than a bunch of screwdrivers in his toolbox.
Some of points where beginners easily make mistakes in C++ are:
making assignments where you wanted to test = vs ==
Missing ;
Readability of curly brackets vs. for example pascal begin-end
And then there are all the include files, macros, memorymanagement etc. to confuse.
So I would say C++ is not the best language to start with - however there is no doubt that it can be very usefull when you have learned it.
I would - as others also suggested - use C#, Java or maybe even VB - and a good IDE with syntax highlight, debugger etc. to help make it easier to recover from errors.
When I was in college C++ was the foundation language that was taught throughout the first year of college. The theory was that it contained some complex programming concepts, so if you could master it, you could pick up other languages. It served me well as a good foundation.
Having said that, during my senior year, I served on a committee to determine whether or not to switch the core language to Java. After talking to several prominent employers and some alumni of the department, it was determined that a switch to Java was the best interest of the students. The employers we talked to wanted people to have experience in a language they were using in order to hire them. I believe now, 10 years later, they are still using Java as their core language.
On a similar note, we have been looking to hire a couple of recent college graduates with really good C++ skills. We haven't been able to find any.
I would say yes. But any language can really be a first language. I think C++ is good because while it's complex and sometimes difficult, it shows you what you can really do (less limitations). Also, it has some object oriented design that can help you get ready to take on other languages.
C++ was my first language and I'm glad it was. It got me thinking in the OOP mindset early on and I'm thankful for that. But in the end, it really comes down to what you want to do. The language doesn't matter as much because if you can get good with one language, chances are you're not going to have any problems picking up another. What do you want to do? Make games? Program for mobile phones? Each one will have tools and languages better suited for it.
C++ is an expert language, not a beginner one... would say C first, not Java or C# or Python... why? because C teaches you to take care about your memory and some tricky concepts such as pointers which are "hidden" by all languages yet being present everywhere. I've seen so many young developers who don't even understand why memory should be released sometimes and believe the garbage collector is not a little dwarf that cleans all coding craps: they instantiate, they instantiate and boom it explodes even if they have XXXXGb RAM... But they don't understand why the garbage collector is not simply magically cleaning everything! And I've seen this kind of developers coding in C++ (and even crazier, in Corba) and it was a slaughter!!!!!!!!!! So I would advice to learn coding in C and then go to Python/Java/C# for the object concepts and all sugar around. Then when you understand all of that, you go to C++ and you feel the power of C++ but you also discover all its dangers and why it shouldn't be used by anyone ;)
NO. There is so many stuff that C++ has, that makes difficult for a newbie to understand. Don't get into the "all programming languages are equal" fallacie.
Start with Basic or Pascal, (ignore the "they are deprecated" stuff), and later, with C/C++/Java/C#/Perl. Or if you have a chance, first with Logo & Karel, and then Basic or Pascal.
P.D. Some universities & collegues have a Programming Language usage & comparison class, and it happens that I had teach that class ;-)
You can choose any language to learn the foundations of programming. I learned stuffs in C/C++. but 7 years later, the tools/languages are changed in my school and they prefer java/C#. the languages are mere tools. What you need to get better is the fundamentals. e.g. in MIT people learns the algorithm fundamentals using python. e.g. Java may be good for web programming. but C/C++ are good for services and high performance applications. So it depends on your situations.
If "suitable" stands for "possible", yes. If for "good", definitely no.
It's possible to like, even love C++, but for that you better learn several languages and work some decade with teal-life rotten codebases, get experience on "crafting nontrivial software that works actually" -- then C++ will have charm.
Not at start when you are virgin, fiddle with small, simple (but supposedly interesting and fun) problems.
I'd start with python, followed by SICP (scheme), or something similar. Maybe reversed or interleaved. With those you can just go and deal with the problem. Instead of fighting the system, walking in deep mud and learn all kinds of illogical quirks and their historical reasons.
Later, when you already can program your way out of a paper bag, switch to bare metal: learn ways of assembly and several architectures, plus maybe Knuth's Mix. I don't mean memorizing opcodes or do much real stuff, just to understand memory, registers, the ALU, caches, interrupts, and get on read level.
Then with that foundation you can be exposed to other languages, including C++. Maybe a good idea to add some "history and evolution of languages" in between.
I started out with C++ in middle school. I picked up a copy of this book: C++ How to Program by Deitel and Deitel. This book is quite good.
Frankly there is no right or wrong answer here, I personally found that C++ was graspable. I learned it all the way to OOP ( I got tripped up on "this" which I now don't understand how I couldn't get that but whatever). Try it, don't get discouraged. If you get stuck, check out other languages and keep learning new ones. The idea is that as you see the same concept in 2-3 different forms you will understand them better. Like I said, the concept of the "this" pointer confused me but when I saw the same thing in Python (named self instead) it made sense to me right away because I'd understood it in C++. Do learn Java if you can as many colleges teach it. Do learn python or ruby as it's the language du jour and if you can explore more niche/new stuff like Clojure(and all the other lisps), Haskell, Scala...
No. I'd start with Java or C#. If you want to learn C++, its probably easier after you've learned the basics, such as what is a class, how to do loops and forks(if, then statements), etc. It's much more important to learn how to look at a problem or a mathematical equation and program it than it is to figure out if you've released all your memory or whatever.
It appears the assumption behind this question is "C++ appears so complex, will a 16 year old be able to pick it up as the first (computer programming) language?"
By the time we are 4 or 5, we pick up most of the constructs in the mother tongue, just with that much exposure to it through listening others speak it. Forming great sentences takes a life time, no question there.
C++ is sure a lot less complex/complicated than, say, most human languages. 16 year olds should sure be able to pick it up. Will they write great code with it? Got to wait and watch.
Beginners need to appreciate 'programming' first. In my experience in training a class of beginners, they appreciated first what they understand the most. Like Python vs. C# they appreciate Python because its very high level and does not use symbols like C# does, meaning very near to human language, its very English. So I would recommend to learn programming from high level to low level.