It's 2013. Why is C++ still being taught like C with classes?

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

37 Replies - 18991 Views - Last Post: 05 July 2013 - 01:41 PM

#1 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,009
  • Joined: 05-May 12

It's 2013. Why is C++ still being taught like C with classes?

Post icon  Posted 28 June 2013 - 06:01 AM

*
POPULAR

In another thread, jimblumberg linked to a delightfully wonderful book entitled Accelerated C++ that I've seen for the first time this morning.

The quote in the introduction:

Quote

Our approach is possible only because C++, and out understanding of it, has had time to mature. That maturity let us ignore many of the low-level ideas that were the mainstay of earlier C++ programs and programmers.

The ability to ignore details is a characteristic of maturing technologies. For example, early automobiles broke down so often that every driver had to be an amateur mechanic. It would have been foolhardy to go for a drive without knowing how to get back home even if something went wrong. Today's drivers don't need detailed engineering knowledge in order to use a car for transportation. ...

got me thinking and asking: "It's already 2013. Why is C++ is still being taught like it's C with classes."

My question maybe due to the filtered perception I have from the types of questions being asked in the C/C++ forum where beginning programming students are dealing with arrays, pointers, and linked lists. Perhaps there is hope that C++ is being taught in a much better format now rather than just translating the K&R C book into C++ and then tacking on how to use classes afterwards.

This post has been edited by macosxnerd101: 28 June 2013 - 07:59 AM
Reason for edit:: The book is for sale, so I swapped out the links


Is This A Good Question/Topic? 5
  • +

Replies To: It's 2013. Why is C++ still being taught like C with classes?

#2 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7648
  • View blog
  • Posts: 12,902
  • Joined: 19-March 11

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 07:37 AM

I still haven't added classes to my C, I have to admit, so I'm not really well placed to answer the question, but this pattern seems to be pretty common, across languages. Java is typically taught as "J with classes", where "J" is the imaginary "core language" of Java. (J looks a lot like C, as it turns out - what a coincidence!). You start by manipulating primitives, then you get to learn Strings and arrays, and later on you start manipulating and defining classes. The python books I've looked at usually start with simple scripts or one-liners in the shell, and then define simple functions, and get to classes much later in the game. Ruby is a bit of an exception, which is understandable since it's much more "pure OO", but for many languages it seems like this is an obvious pattern to follow.

How would you go about teaching C++? Can you sketch out a battle plan for CS 101: C++, taught by Professor Skydiver?
Was This Post Helpful? 0
  • +
  • -

#3 nullcoding  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 99
  • Joined: 08-July 12

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 08:00 AM

I never learned C or C++ formally, but rather on my own using nothing but internet resources and trial-and-error. The entire concept of "classes" was actually completely foreign to me until I'd been programming for several months, and up to that point, my code was generally poorly organized and all but impossible to navigate (Skydiver probably remembers...thank you for your patience!)

I paged through the K&R book (a very early edition, too) a few times for reference, and it was pretty helpful to get me started, but right from the start I knew that C++ was a lot different from C. Perhaps not at first, but what I like is that one can write an entire functional program without using traditional C-style constructs...or write an entire program that's almost pure C but with the additional "user-friendly" tweaks of C++.

Certain common frameworks based on C++ are class-based, though - Qt comes to mind, for instance. Glance at the official Qt documentation sometimes - class this class that. Then again, Qt is designed for people who already do cross-platform programming in C-based or C-like languages, like Java, so from what I gather it's designed to be interchangeable and familiar right from the start.

I've often thought about how I'd teach an introductory class, or really any class, but I have a tendency to make things too complicated. The whole idea of classes, and indeed OO programming in C++ to begin with, can seem a little strange, especially to people who know about C# and Java and therefore have a hard time figuring out the differences between, say, C# classes and C++ classes, both high- and low-level. I still haven't totally grasped it myself, but then again, I'm not using "pure" C++ most of the time.
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1147
  • View blog
  • Posts: 7,134
  • Joined: 07-September 06

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 08:03 AM

I think C/C++ is used mainly to try and teach students about data structures, and once they have the basics down many schools jump ship to a language like Java. I know that I had to look for professors at my college that taught classes in C++, the vast majority of classes were in either Python or Java.

Now, I'll agree that it isn't important for every person to know a lot of the functionality and low level aspects of a language, but I also don't believe they should jump to using the STL for everything. If all a student knows how to do is use pre-built libraries then they are going to have more difficulty when it comes to writing original code and algorithms aren't they? So to mitigate this (and to weed out those who aren't willing to put forth the required effort) it makes sense to teach students a broad basic functionality of the language and force them to deal with annoying things like memory management, data structures, and algorithms. Certainly they may never wind up having to write them in their careers, but it is also a skill that is fundamental in some fields and is good for CS students to have at least the basics of.

I also believe that students should be required to take a Unix administration/ intro to Unix class in their CS curriculum as it is something that will likely come in handy at some point during a CS career.
Was This Post Helpful? 0
  • +
  • -

#5 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 08:12 AM

I think there are a number of reasons. The big one is of course momentum and history. MANY programmers still think of C++ as C + classes. This is how they were introduced to the language, it worked for them, it is working for them, and that is what they teach (remember that academics don't do a lot of real-world programming -- not to say that is universal there are certainly some cutting-edge real-world code coming from academia but how many of those people are teaching intro-to-programming classes? Turbo-C is STILL taught in classes all over the world today, yes including the United States!)

Another reason is published materials. I thought with C++11 FINALLY crossed the finish line we would see a bunch of new C++ books published (it is long over due). For a while C++ books were not selling particularly well and publishers really were not interested. Well C++11 came out and all the old books got a new chapter. Not re-written with modern programming techniques just an addendum. -- so this helps the momentum argument as well.

It is really hard to find a book that takes STL seriously or that walks one though using smart-pointers or that will use std::string over char[] or std::vector<int> over int[].

So another is the Academic momentum - let's face it, if the schools are not interested in re-writing curricula then publishers are not ready to risk paying for the development of new course materials that may not sell. As I see it, schools have to change first. But as I have been informed (I have no idea) this can be very difficult.

There is a huge gap between what is taught in school and what modern C++ looks like. Not ALL schools though... C++11 has stirred the community a little. I think a lot of people who were sleeping since C++03 have become a little interested in what is changed and to be honest many of them are a little overwhelmed and you hear a lot about how lambdas and r-value references are too esoteric... now if we can just get them to take a second look at STL!
Was This Post Helpful? 1
  • +
  • -

#6 ruirodrigues1971  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 06-October 10

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 08:52 AM

C can be a good language to learn the basic concepts:
- Variables
- functions / simple algorithms
- Simple structures
- algorithms
- memory, address, ...
- some knowledge about memory optimization and time optimization.

This is sufficient to be a introductory course ... is a new way of thinking and needs some time to mature

I have many students that have java has primary course and because of the necessity to have classes they don't achieve
the basic goals of a programmer.

C++ is another course ... maybe a second course were you learn a object oriented methodology.

When you put the two objectives, learn the basic concepts of programming and object oriented methodology in the same course you have a big probability to fail in the two objectives.

If C/C++ is a second programmer course then you can speed from C to C++ ...
Was This Post Helpful? 0
  • +
  • -

#7 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 10:37 AM

This is an issue that I am trying to campaign at my school. Here are the issues I see

  • Momentum and history as Nick pointed out. This is the big one
  • Basically no classes use C++. OS and systems are taught with C here(and so after people learn C they treat C++ like C). Parallel programing is the only thing taught with C++. There is an introduction to programing in C++ but it is a 1 hour course and the first half just teaches C. It's a joke
  • The people in academia don't know modern C++. This is the big one. I tried showing modern C++ examples to try and get the curriculum boosted (and actually I got smart pointers and range based for loops in without breaking a sweat) but it just sounds like hipster talk to them and me saying "your way is bad. my way is better". It's hard to tell someone they are teaching wrong without offending them I think
  • Students don't do it even if teachers show them. Students assume all programing is the same and will learn to program *ok-ish* in 1 language and 1 language only. Everything else is just "how do I translate how I would do this in my language to this language" which yields really poor results. People hate C++ because they treat it like Java, that's about the quickest way to write bad code I can think of.
  • Students don't want to take classes with C++ or C. Even the game programing courses are taught with C# and XNA(or they were but not they are moving to something else, not sure what). This lowers enrollment and thus C++ is weeded out by natural selection


It's a huge issue. I want to teach a 13 year old book to people in an elective course because it is far more modern than anything that is being taught at my school.

This post has been edited by ishkabible: 28 June 2013 - 10:40 AM

Was This Post Helpful? 0
  • +
  • -

#8 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,127
  • Joined: 18-April 07

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 10:58 AM

Why is C++ still being taught like C with classes? Because it is C with classes. Sure you have STL, MFC, additional things added from C++11 but at the heart of all it is still just C with bolted on class functionality. Now if the question is why do schools teach it like C and then go into C++ it is because that is going to give you the most comprehensive knowledge of the language. This prepares students to work in fields where they have to do "close to the metal" C programming, drivers, back end utility programs etc all the way up through modern C++. If they taught just straight modern C++ then you would ignore C and it is much easier for most to go from C to C++ than C++ back to C.

I think more schools should start in C, teach the structures and layout of memory etc and then migrate them into C++. I can speak to this technique because I had the rare opportunity to be schooled in VB4/5/6 and then also schooled in VB.NET. Those after me only got the VB.NET and knowing VB6 has really helped with VB.NET and knowing its intricacies.

As for jon's remarks, I am a bit confused on the whole core J thing and "J with classes". First note, Java was created using C++ as a model and more importantly it was created with the intention that it would be purely class based OOP. J's core is all classes. Maybe I am not understanding that correctly. I just wanted to throw that out there that one of Java's five key principles at conception was that it would be a simple to use OOP based language. Not J with classes.

But anyways, just my opinion. :)

This post has been edited by Martyr2: 28 June 2013 - 10:58 AM

Was This Post Helpful? 0
  • +
  • -

#9 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7648
  • View blog
  • Posts: 12,902
  • Joined: 19-March 11

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 11:09 AM

View PostMartyr2, on 28 June 2013 - 12:58 PM, said:

one of Java's five key principles at conception was that it would be a simple to use OOP based language. Not J with classes.



I was referring to the way java is taught, which if the textbooks are any guide is usually from the ground up: first you get the primitive data types and the operators that work on them, then you get the control structures, and then you write a bunch of stuff using those. Objects are usually not discussed until all of the core language is understood. This seems to me like a good thing, so I'm not sure why it would be a problem to learn C++ the same way - first get an understanding of C, then add the classes.
Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon


Reputation: 4023
  • View blog
  • Posts: 12,419
  • Joined: 25-December 09

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 01:32 PM

Quote

I'm not sure why it would be a problem to learn C++ the same way - first get an understanding of C, then add the classes.

In my opinion if teaching C++ teach C++. Start by exposing the standard data types but move on quickly to the C++ types like std::string and std::vector. Leave dynamic memory and C-style arrays until later. Teaching proper use of encapsulation, inheritance and other OOP techniques should take precedence over teaching procedural methods whenever possible. C++ is so much more than C on steroids that the two languages should be taught differently.

I think one of the major problems with both C and C++ is the use of outdated tools and methods by the institutes of "Higher Learning". Although I have noticed a decline of Turbo-C++ usage there are still a couple of very outdated compilers on the market that still have huge followings.

But until industry and students/job seekers start to insist on higher standards I don't see much chance for any movement. Students need to be concerned about more than just getting top grades, they need to worry that they are being taught relevant material so they have a decent chance of post university employment.

Also the lack of activity in the availability of quality text books that cover the new aspects of these languages is yet another problem.


Jim
Was This Post Helpful? 1
  • +
  • -

#11 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5801
  • View blog
  • Posts: 12,639
  • Joined: 16-October 07

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 02:29 PM

It would be interesting if the curiculum started with C++, with C covered later. The C++ class would actively avoid Cisms, like c-strings and pretty much anything having a * in the notation. You'd probably need to avoid "new" at that point ( how much could you fake it with auto? ) but it wouldn't be a bad starting point.

Instead of C with classes, C++ sans C? Hmm...

To address the question: Perhaps because C and C++ programs three decades old are still viable? Meaning my old Turbo-C book could still be, theoretically, used? The current gcc defaults to, wait for it, ISO C90 for C and a progressive 1998 ISO C++. Changes are adopted slowly in both languages. Their very popularity imposes are certain inertia.

You see this on a smaller scale in newer languages. Java without generics, etc.
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3552
  • View blog
  • Posts: 11,009
  • Joined: 05-May 12

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 02:35 PM

View Postjon.kiparsky, on 28 June 2013 - 10:37 AM, said:

How would you go about teaching C++? Can you sketch out a battle plan for CS 101: C++, taught by Professor Skydiver?

I would have followed the same direction that the book took.
http:

I would move chapter 14 (Managing memory almost automatically) to right after chapter 10 (Managing memory and low-level data structures), and then replace chapter 14 with "Smart pointers" that come with the C++ library.

This post has been edited by jimblumberg: 28 June 2013 - 02:44 PM
Reason for edit:: Link removed, Book should be purchased.

Was This Post Helpful? 0
  • +
  • -

#13 ruirodrigues1971  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 06-October 10

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 03:55 PM

As a teacher and as a personal trainer of university students I see big problems when you go first to program in oriented object focus C++ (or another language) before you learn C (or any structure language).
Maybe if you have 2 courses you can start learning to program in another language than C then I think in the second course you can speed up the learning of C and go fast to C++, but never skip C ... that is my opinion and experience of years of teaching.
And is true in the academia they are loosing the evolution of C++ I think the same.
Was This Post Helpful? 0
  • +
  • -

#14 jimblumberg  Icon User is offline

  • member icon


Reputation: 4023
  • View blog
  • Posts: 12,419
  • Joined: 25-December 09

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 05:03 PM

Quote

I see big problems when you go first to program in oriented object focus C++ (or another language) before you learn C (or any structure language).

What type of problems are you talking about?

Quote

but never skip C

Why not? C and C++ are different languages, even though they share common ancestry. C++ can be taught without any knowledge of C. In fact in my opinion if you insist on teaching C before C++ you will be teaching many methods that are in stark contrast to how they should be properly handled in C++, on any other OOP language for that matter.

There may be a case that C++ shouldn't be the first language taught, but in my opinion C should probably shouldn't be considered a first language either.

Jim
Was This Post Helpful? 0
  • +
  • -

#15 ruirodrigues1971  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 06-October 10

Re: It's 2013. Why is C++ still being taught like C with classes?

Posted 28 June 2013 - 05:32 PM

View Postjimblumberg, on 28 June 2013 - 05:03 PM, said:

Quote

I see big problems when you go first to program in oriented object focus C++ (or another language) before you learn C (or any structure language).

What type of problems are you talking about?

Quote

but never skip C

Why not? C and C++ are different languages, even though they share common ancestry. C++ can be taught without any knowledge of C. In fact in my opinion if you insist on teaching C before C++ you will be teaching many methods that are in stark contrast to how they should be properly handled in C++, on any other OOP language for that matter.

There may be a case that C++ shouldn't be the first language taught, but in my opinion C should probably shouldn't be considered a first language either.

Jim


1 - Structure language --> 2 - Object oriented

Independent of what is the language :)
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3