

C++ For C Programmers  - hydrology
https://www.coursera.org/course/cplusplus4c

======
nly
Imho, C++ should be thought of as a new language with a degree of backward
compatibility with old C code, not as a 'bigger C'.

How I'd start:

    
    
        Lesson 1: Pointers don't exist in C++, we 
           have references.
        Lesson 2: malloc() doesn't exist in C++
        Lesson 3: Templates are awesome.
        Lesson 4: Smart pointers are awesome.
        Lesson 5: 'Structs' can have constructors, and 
           they're awesome!
        Lesson 5.5: Exceptions are awesome!
        Lesson 6: 'Structs' can have copy constructors and 
           assignment operators, but the default ones do 
           exactly what you'd expect so you shouldn't have 
           to write them often.
        Lesson 7: OK, OK... pointers still exist in C++ but
           smart pointers and references make them almost
           deprecated, right?
        Lesson 8: ...oh, and if you use raw C pointers you
          need to do all this extra donkey work when it 
          comes to handling exceptions, and write a lot 
          more of those pesky copy and move constructors 
          and assignment operators I told you you didn't 
          need to write.
          Example: writing a smart pointer (with C pointers!)
        Lesson 9: Implementing a safe, dynamic, exception-safe
          array in C++ using templates and C pointers.
        Lesson 10: back to sanity, the ease of using <vector>
          (or the output of lesson 9) in every day code. 
           Introduction to the STL, <string>, etc.
           
    

...and so on. The idea is to first teach the common C++ way, and then teach
the penalty of ignoring it and going the C way, and then the places where you
need to pay that penalty.

Imho teaching inheritance or virtual functions early is also a bad sign. I'd
go with public/private access control first (leaving protected), then member
functions, then _pure_ virtual member functions and basic inheritance, all the
while presenting no hint of Circles and Ellipses, just interfaces.

~~~
checker659
What's wrong with handling errors with status codes as opposed to exceptions?
Just because it exists doesn't mean one has to use it, no?

~~~
nly
Exceptions allow you to leverage value semantics and safe reference semantic
abstractions like smart pointers. If you fail to handle them properly you will
also discover bugs a _lot_ sooner.

------
skrebbel
Nice! However, I'd appreciate the converse more.

I'm pretty well versed in C++, and every time I try to write something in C, I
fall back to C++. I find memory management a pain without RAII, error handling
a hassle without exceptions, and, well, anything really a pain without some
sort of standard container library.

I have the idea that there's good alternatives for these in C-land, but I'm
unfamiliar with them and would love for an expert to teach me.

In general, I wonder whether there's really that many people who know C but
not C++. This might just be me projecting myself onto the world, though.
Anyone?

~~~
CraigJPerry
You're the first person i've heard of who falls back to C++, if that data
point is of any value.

AIUI exceptions and RAII are mutually exclusive in C++. I don't know enough
about C++ so i wouldn't be surprised to find out this is wrong.

~~~
jacobparker
> AIUI exceptions and RAII are mutually exclusive in C++

That is... very wrong. Exceptions are perilous unless you use RAII religiously
(which you should; it's good.)

For more information, read up on RAII and search for "exception safety."

The definition of C++ RAII from Wikipedia: "In this language, if an exception
is thrown, and proper exception handling is in place, the only code that will
be executed for the current scope are the destructors of objects declared in
that scope". Without this it is very hard to reap any benefits of exceptions
(people have disagreements on what those are, if any, but that's another
topic).

~~~
CraigJPerry
Up-voted a few of the others below too.

I also found this which I thought was a high quality summary:
[http://www.parashift.com/c++-faq-lite/ctors-can-
throw.html](http://www.parashift.com/c++-faq-lite/ctors-can-throw.html)

------
dysoco
I heard awful things about this course. Just check the reviews for it's
textbook: [http://tinyurl.com/cppcprog](http://tinyurl.com/cppcprog)

In general, anything that says "X for Y programmers" is not worth it.

If you really want to learn C++, and you already know C, I suggest either
"Accelerated C++" or "The C++ Programming language"

~~~
16s
___" Accelerated C++"_ __is a fantastic book if you wish to pick-up idiomatic
C++ quickly.

------
PLejeck
I'm slightly afraid to learn C++ after being told so many horror stories. But
for the low low price of free? Count me in.

~~~
stinos
Forget about the stories. I have quite some experience with both C and C++,
started with C. There's horror in both of them, if you do it wrong enough. Oh
yes there's more horror in C++, there are more ways to do it wrong. But in the
end it comes down to the same: learning curve. If you know it well enough
there's no horror anymore, just joy.

~~~
pjmlp
Agreed, specially since C++11 provides better mechanisms for writing safe code
if one needs to stay in C++ world.

Now C is a different matter.

------
_pmf_
On another note: people claiming "C/C++" skills usually have neither.

~~~
checker659
Why do you say that?

~~~
nephorider
By definition C++ is a different language (contrary to Objective-C that was
"an extension to C"). It encompasses a lot (nearly all) of C but introduces
also new concepts. For example and besides the evident OOP features, all the
different types of casting, use of IO stream, default parameters...

------
guard-of-terra
C++ for C programmers:

RUN

~~~
antimagic
Surely that would be BASIC for C programmers?

------
checker659
I think "Thinking in C++" is a good book for C programmers to get started in
C++.

------
danso
OK I'm going to date myself here...when I studied comsci/CPrE in college, we
started out with C and moved to C++ and then to Java. I guess it doesn't speak
much for the depth of the classes that I found C++ pretty easy to get into and
used it in higher level courses, such as one involving Open GL.

I guess what I'm asking is... _who uses just C any more_? I can only guess
that if, by this point, your main expertise is C and you are still hacking
away at it, you're a hacker who is beyond the need for any introductory C++
course and who could probably learn it on your own. If you're a C-person and
just want to dabble in a more OOP language to do fun things, why wouldn't you
just jump into Python? The world of mostly-and-only-C-programmers seems to be
fairly small these days, and the ones who need to get into C++ -- in lieu of
what's out there --- seems even smaller

To reiterate my thoughts, here's a review from someone who has read the
recommended text book:

[http://www.amazon.com/For-Programmers-Third-
Edition-3rd/prod...](http://www.amazon.com/For-Programmers-Third-
Edition-3rd/product-
reviews/0201395193/ref=cm_cr_dp_synop?ie=UTF8&showViewpoints=0&sortBy=bySubmissionDateDescending#RZP1WC0D6AEL)

> _I was initially dismayed by the large number of negative reviews, but now
> that I 've completed this book I believe I understand why; this book is
> really intended for a very narrow target audience: very experienced C
> programmers with no knowledge of C++ -- i.e., Old Farts,... like me. Is
> there ANY school out there today teaching people C WITHOUT also teaching
> them C++? It seems unlikely, almost as unlikely as it would be to find a
> potential employer out there who is seeking Plain Old C programmers today.
> So if you are an Old C Dog like me looking to learn the "new" trick of C++,
> this book is for you and ONLY for you! I read it carefully and was able to
> pass a C++ test that I wouldn't have gotten a single answer right on before
> I read it. Anyone else looking to learn C++ would be better served by
> choosing C++ for Dummies or something similar._

~~~
KaeseEs
There are many, many people who use C and rarely or never use C++. Most
embedded work is done in C, the Linux and BSD kernels are in C, etc. There are
a variety of reasons for this, with audit-ability and debug-ability being two
big ones. Code space is also a reason, although there are ways to make C++
mostly behave the way you want it to on all but the teensy tiniest platforms
(although the resulting code is sometimes a questionable upgrade over just
writing the thing in C). A great number of language interpreters are also
written in C rather than C++ (cpython being one of them) - easier bindings are
one reason for this.

As another datum, where I went to school the intro to CS data structures and
algorithms courses were taught in C++ and the operating systems course was
taught in C. In my day to day work I use C and a tiny bit of assembly (more
reading than writing).

------
otikik
"Fly, you fools"

------
anon1385
>Please use a modern browser with JavaScript enabled to use Coursera.

One wonders how people who can't even create a static HTML page will manage to
teach people a complex language like C++.

~~~
jmarin
Because this University of California professor runs the entire Coursera
website.

~~~
anon1385
Well I don't know anything about who this organisation is or who in particular
is running the course because I can't view the website!

