Live data from Hacker News

C++ For C Programmers

coursera.org

1–10 of 53 posts

Re: C++ For C Programmers

#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 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?

Re: C++ For C Programmers

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

Re: C++ For C Programmers

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

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

Re: C++ For C Programmers

#7
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…

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.

Re: C++ For C Programmers

#8
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 kind of like the way how Zed does the error handling:

http://c.learncodethehardway.org/book/ex20.html

Re: C++ For C Programmers

#9
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've done so little C++ so long ago that I may as well fall in the category of a C programmer who doesn't know C++. If I had spare time over the next 8 weeks I'd definitely do this as a refresher course.

Re: C++ For C Programmers

#10
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…

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.

Exceptions and RAII match well, actually. Managing resources via RAII means that when an exception is thrown, the destructors of local objects are invoked so they'll release resources they've acquired.

In fact, I'd argue that you very often have to use RAII with exceptions, since there's no 'finally' block on a try-catch statement and hence it's the easiest way to ensure stuff gets cleaned up (well, except for catch(...) and rethrowing, but that's kinda ugly).

Post reply on HN