Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What knowledge about C do you think does someone miss when he is using C++?

I have made the experience that a good C++ developer also automatically knows everything about C.



Naive C++ programmers tend to use pointers as if they were references. They do not seem to understand pointer arithmetic, pointers to functions, etc. They also do not seem to have a deep understanding of memory models, and tend not to understand memory alignment. They do not use bit-wise operators much, though it's more of a cultural thing than skills issue.

I have never met a competent C++ programmer that does not have at least some exposure to C as well. But I'd dare to guess, that such character would not understand the C preprocessor in any but the most trivial level.

[edit] I originally used the phrase "C with classes" crowd, in a rather derogatory way, to describe the people who never get to learn any of the languages well, and end up writing some sort of sanitized, structured-programming, algol derivative in (a subset of) C++ syntax.

While reading the rest of the comments, I remembered that "C, with classes" can also apply to C hackers that just use C++ to structure their C-styled code, and may take advantage of a few features of the language. I have edited the comment to clarify what I meant.


> I have made the experience that a good C++ developer also automatically knows everything about C.

Not even close in my experience. In college, we used C++ in our intro course. The addition of pass by reference, classes (with constructors and destructors), and the standard library (e.g. std:string) hides a lot of the common paradigms of C, and that's not even mentioning boost.

In my experience, people coming from C++ tend to write really bad C. Many of them have a poor understanding of the concept of pointers.

Once you get familiar with some good C design patterns, it's pretty easy to write clear, modular C. Knowing C++ is not a very effective measure of ability to use C.


Au contraire, a modern C++ developer probably knows nothing about C. Good C is like good assembly language: dense and performance-obsessed. No objects, no exceptions, no STL, bare bones and riddled with pointer manipulation and macros.


No objects = no structs?


There are structs in C, as well as unions, but they are data only - no methods.


Well, function pointers exist in C, though they are certainly a clumsy replacement for having methods (or first-class functions / closures / currying) built into the language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: