Live data from Hacker News

C++ For C Programmers

coursera.org

31–40 of 53 posts

Re: C++ For C Programmers

#31
post #11
post #2

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.

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.

Here's a little secret, guys: It's not the language that is bad. Although a lot of things can go out of hands and most of the added features seem extremely "tacked on", at the end of the day, it's us, the programmers, that write the bad code. C++'s main problem is allowing people to write stupid code... but then again, stupid programmers are stupid programmers, no matter the language... plus, every mainstream language has a lot of stupid programmers using it :)

Still, if you look at the Chromium code, or the Doom 3 BFG Edition code, it's really neat and readable.

Re: C++ For C Programmers

#33
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...

> 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.

Re: C++ For C Programmers

#34
post #5

>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++.

Perhaps they want to do things that static HTML can't do?

As someone who has taken several Coursera classes (some bad, some very good), the site is a pile of crap. Most pages need far too many round-trips to load, and very few do anything "interesting". On my tablet I sometimes need to refresh pages several times to get them to load "all the way", because some request failed to fire or return or something. It works ok on the desktop, but on the whole it hasn't been thought out very well.

I'm trying to think of a page on their site where doing things "their way" (load a mostly empty page, fetch all the content later) is the right thing to do. Fittingly, I'm drawing a blank.

Re: C++ For C Programmers

#35
post #4

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…

>I find memory management a pain without RAII,

That statement is true. But, as you may be aware, it doesn't encompass quite a few use-cases. A lot of usecases require you to have fine control over performance and using RAII will cause random speed-bumps. for e.g. when a ref-counted smart pointer(s) goes out of scope and triggers 'heavy' destructors on held objects to free up resources - at a non-deterministic time.

Re: C++ For C Programmers

#36
post #28

I heard awful things about this course. Just check the reviews for it's textbook: 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"

"Accelerated C++" is a fantastic book if you wish to pick-up idiomatic C++ quickly.

Re: C++ For C Programmers

#37
post #13

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

Not quite. It's fairly common in an embedded world for a system engineer that uses C for low level programming and C++ for application/UI level.

Re: C++ For C Programmers

#38
post #4

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…

> anything really a pain without some sort of standard container library.

It's certainly not standard, but I wrote a nice little generic list library you might be interested in: http://github.com/udp/list

It uses GNU extensions, but can fallback on C++ instead if you need to build with MSVC.

Re: C++ For C Programmers

#39
post #4

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…

I use C++ because of the std containers (vector, map, set, etc). I don't have to roll my own and I'm free to think about the problem at hand rather than how to get the proper data container for this, that and the other.

Re: C++ For C Programmers

#40
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 
      (or the output of lesson 9) in every day code. 
       Introduction to the STL, , 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.

Post reply on HN